|
1 | | -import warnings |
| 1 | +# import warnings |
2 | 2 |
|
3 | 3 | import pandas as pd |
4 | 4 | from matplotlib import pyplot as plt |
|
8 | 8 | import os |
9 | 9 |
|
10 | 10 | os.environ["PYTHONWARNINGS"] = "ignore::FutureWarning" |
11 | | -warnings.simplefilter(action="ignore", category=FutureWarning) |
| 11 | +# warnings.simplefilter(action="ignore", category=FutureWarning) |
12 | 12 |
|
13 | 13 | pd.set_option("display.float_format", lambda x: "%.2f" % x) |
14 | 14 |
|
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 |
19 | 26 | ) |
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 |
31 | 33 | # # Percentage CF strategy |
32 | 34 | # cf_strategy = ok.PercentageStrategy(pf) # create PercentageStrategy linked to the portfolio |
33 | 35 | # |
34 | 36 | # cf_strategy.initial_investment = 83_000_000 # initial investments size |
35 | 37 | # cf_strategy.frequency = "year" # withdrawals frequency |
36 | 38 | # cf_strategy.percentage = -0.09 |
37 | 39 |
|
38 | | -# # Indexation CF strategy |
| 40 | +# Indexation CF strategy |
39 | 41 | # cf_strategy = ok.IndexationStrategy(pf) |
40 | 42 | # |
41 | 43 | # cf_strategy.initial_investment = 10_000_000 |
42 | 44 | # cf_strategy.frequency = "year" |
43 | 45 | # cf_strategy.amount = 10_000_000 * 0.05 |
44 | 46 | # 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 | + |
45 | 57 |
|
46 | 58 | # 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 | +# ] |
58 | 70 |
|
59 | 71 | # d = { |
60 | 72 | # "2015-06": -35_000_000, |
|
73 | 85 | # # cf_strategy.time_series_dic = d |
74 | 86 | # # cf_strategy.time_series_discounted_values = False |
75 | 87 |
|
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 |
77 | 89 |
|
78 | 90 | # w = cf_strategy.calculate_withdrawal_size( |
79 | 91 | # last_withdrawal=0, |
|
134 | 146 |
|
135 | 147 |
|
136 | 148 | # 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() |
145 | 157 |
|
0 commit comments