Skip to content

Commit f8bbe79

Browse files
committed
test: change test to mocking
1 parent ec9f87f commit f8bbe79

15 files changed

+1375
-1035
lines changed

main.py

Lines changed: 50 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import warnings
1+
# import warnings
22

33
import pandas as pd
44
from matplotlib import pyplot as plt
@@ -8,53 +8,65 @@
88
import os
99

1010
os.environ["PYTHONWARNINGS"] = "ignore::FutureWarning"
11-
warnings.simplefilter(action="ignore", category=FutureWarning)
11+
# warnings.simplefilter(action="ignore", category=FutureWarning)
1212

1313
pd.set_option("display.float_format", lambda x: "%.2f" % x)
1414

15-
rs = ok.Rebalance(
16-
period="year",
17-
# abs_deviation=0.10,
18-
# rel_deviation=0.40
15+
# weights_div = [.07, 0.08, .10, .35, .15, .05, .20]
16+
reb = ok.Rebalance(period='year', abs_deviation=None, rel_deviation=None)
17+
assets = ['SBGB.MOEX', 'BOND.MOEX', 'OBLG.MOEX', 'EQMX.MOEX', 'GC.COMM', 'BTC-USD.CC', 'RUS_PR.RE']
18+
19+
portf_div = ok.Portfolio(
20+
assets,
21+
ccy='RUB',
22+
# weights=weights_div,
23+
symbol="portf_div.PF",
24+
rebalancing_strategy=reb,
25+
inflation=True
1926
)
20-
weights = [0, 0, 1, 0]
21-
pf = ok.Portfolio(
22-
['RGBITR.INDX', 'RUCBTRNS.INDX', 'MCFTR.INDX', 'GC.COMM'],
23-
weights=weights,
24-
# first_date='2014-06',
25-
ccy="RUB",
26-
inflation=True,
27-
rebalancing_strategy=rs,
28-
symbol="My_portfolio.PF",
29-
)
30-
pf.dcf.discount_rate = 0.09
27+
28+
print(portf_div.describe())
29+
30+
31+
32+
# pf.dcf.discount_rate = 0.09
3133
# # Percentage CF strategy
3234
# cf_strategy = ok.PercentageStrategy(pf) # create PercentageStrategy linked to the portfolio
3335
#
3436
# cf_strategy.initial_investment = 83_000_000 # initial investments size
3537
# cf_strategy.frequency = "year" # withdrawals frequency
3638
# cf_strategy.percentage = -0.09
3739

38-
# # Indexation CF strategy
40+
# Indexation CF strategy
3941
# cf_strategy = ok.IndexationStrategy(pf)
4042
#
4143
# cf_strategy.initial_investment = 10_000_000
4244
# cf_strategy.frequency = "year"
4345
# cf_strategy.amount = 10_000_000 * 0.05
4446
# cf_strategy.indexation = 0.09
47+
#
48+
# pf.dcf.cashflow_parameters = cf_strategy
49+
#
50+
# pf.dcf.mc.period = 50
51+
# pf.dcf.mc.number = 100
52+
# pf.dcf.mc.distribution = "norm"
53+
54+
55+
# print(pf.dcf.monte_carlo_survival_period().describe())
56+
4557

4658
# Cut Whithdrawals if Drawdown CWID strategy
47-
cf_strategy = ok.CutWithdrawalsIfDrawdown(pf)
48-
49-
cf_strategy.initial_investment = 10_000_000
50-
cf_strategy.frequency = "none"
51-
cf_strategy.amount = -10_000_000 * 0.05 / 12
52-
cf_strategy.indexation = 0.09
53-
cf_strategy.crash_threshold_reduction = [
54-
(.10, .20),
55-
(.20, .50),
56-
(.40, 1),
57-
]
59+
# cf_strategy = ok.CutWithdrawalsIfDrawdown(pf)
60+
#
61+
# cf_strategy.initial_investment = 10_000_000
62+
# cf_strategy.frequency = "none"
63+
# cf_strategy.amount = -10_000_000 * 0.05 / 12
64+
# cf_strategy.indexation = 0.09
65+
# cf_strategy.crash_threshold_reduction = [
66+
# (.10, .20),
67+
# (.20, .50),
68+
# (.40, 1),
69+
# ]
5870

5971
# d = {
6072
# "2015-06": -35_000_000,
@@ -73,7 +85,7 @@
7385
# # cf_strategy.time_series_dic = d
7486
# # cf_strategy.time_series_discounted_values = False
7587

76-
pf.dcf.cashflow_parameters = cf_strategy # assign the cash flow strategy to portfolio
88+
# pf.dcf.cashflow_parameters = cf_strategy # assign the cash flow strategy to portfolio
7789

7890
# w = cf_strategy.calculate_withdrawal_size(
7991
# last_withdrawal=0,
@@ -134,12 +146,12 @@
134146

135147

136148
# pf.dcf.mc.plot_qq(bootstrap_size_var=2000, zoom_to_left_tail=50, figsize=(10, 10))
137-
pf.dcf.set_mc_parameters(
138-
distribution="norm",
139-
distribution_parameters=(2, None),
140-
period=100,
141-
mc_number=1_000,
142-
)
143-
pf.dcf.mc.plot_hist_fit(bins=100)
144-
plt.show()
149+
# pf.dcf.set_mc_parameters(
150+
# distribution="norm",
151+
# distribution_parameters=(2, None),
152+
# period=100,
153+
# mc_number=1_000,
154+
# )
155+
# pf.dcf.mc.plot_hist_fit(bins=100)
156+
# plt.show()
145157

0 commit comments

Comments
 (0)