|
11 | 11 | warnings.simplefilter(action="ignore", category=FutureWarning) |
12 | 12 |
|
13 | 13 | pd.set_option("display.float_format", lambda x: "%.2f" % x) |
14 | | -ef = ok.EfficientFrontierReb( |
15 | | - ['SPY.US', 'AGG.US', 'GLD.US'], |
16 | | - rebalancing_strategy=ok.Rebalance(period='year'), |
17 | | - ccy='USD', |
18 | | - first_date='2020-01', last_date='2025-03', full_frontier=True, verbose=True) |
19 | | -glob = ef.global_max_return_portfolio |
20 | | -cagr = glob['CAGR'] |
21 | | -print(cagr) |
22 | | - |
23 | | -pf = ef.minimize_risk(cagr) |
24 | | -print(pf) |
| 14 | + |
| 15 | + |
| 16 | +# ef = ok.EfficientFrontierReb( |
| 17 | +# ['SPY.US', 'AGG.US', 'GLD.US'], |
| 18 | +# rebalancing_strategy=ok.Rebalance(period='year'), |
| 19 | +# ccy='USD', |
| 20 | +# first_date='2020-01', last_date='2025-03', full_frontier=True, verbose=True) |
| 21 | +# glob = ef.global_max_return_portfolio |
| 22 | +# cagr = glob['CAGR'] |
| 23 | +# print(cagr) |
| 24 | +# |
| 25 | +# pf = ef.minimize_risk(cagr) |
| 26 | +# print(pf) |
25 | 27 |
|
26 | 28 | # w = ef.minimize_risk(0.184914755913651) |
27 | 29 | # print(w) |
|
58 | 60 | # |
59 | 61 | # print(pf.dividend_yield_annual) |
60 | 62 |
|
61 | | - |
62 | | -# assets = ['RGBITR.INDX', 'MCFTR.INDX', 'GC.COMM'] |
63 | | -# weights = [0.60, 0.35, 0.05] |
64 | | -# assets = ['RGBITR.INDX', 'MCFTR.INDX'] |
65 | | -# weights = [0.50, 0.50] |
66 | | -# pf = ok.Portfolio(assets, weights=weights, |
67 | | -# first_date="2015-01", |
68 | | -# last_date="2020-01", |
69 | | -# ccy='RUB', |
70 | | -# inflation=True) |
| 63 | +pf2 = ok.Portfolio(first_date="2015-01", last_date="2024-10") |
| 64 | +d = { |
| 65 | + "2018-02": 2_000, # contribution |
| 66 | + "2024-03": -4_000 # withdrawal |
| 67 | +} |
| 68 | +ts = ok.TimeSeriesStrategy(pf2) |
| 69 | +ts.time_series_dic = d # use the dictionary to set cash flow |
| 70 | +ts.initial_investment = 1_000 # add initial investments size (optional) |
| 71 | +pf2.dcf.cashflow_parameters = ts |
| 72 | +print(pf2.dcf.wealth_index) |
| 73 | +# assets = ['RGBITR.INDX', 'RUCBTRNS.INDX', 'MCFTR.INDX', 'GC.COMM'] |
| 74 | +# weights = [0.16, 0.40, 0.25, 0.19] |
| 75 | +# # assets = ['RGBITR.INDX', 'MCFTR.INDX'] |
| 76 | +# # weights = [0.50, 0.50] |
| 77 | +# pf = ok.Portfolio(assets, weights=weights, ccy='RUB', inflation=False) |
71 | 78 | # pf.rebalancing_strategy = ok.Rebalance( |
72 | 79 | # period="none", |
73 | 80 | # abs_deviation=0.10, |
|
103 | 110 | # pc = ok.PercentageStrategy(pf) |
104 | 111 | # pc.initial_investment = 10_000 |
105 | 112 | # pc.frequency = "year" |
106 | | -# pc.percentage = -0.55 |
| 113 | +# pc.percentage = -0.12 |
107 | 114 | # |
108 | 115 | # pf.dcf.cashflow_parameters = pc |
109 | 116 | # |
|
116 | 123 | # solution = pf.dcf.find_the_largest_withdrawals_size( |
117 | 124 | # goal="maintain_balance_pv", |
118 | 125 | # percentile=20, |
119 | | -# tolerance_rel=0.05, |
| 126 | +# tolerance_rel=0.10, |
120 | 127 | # threshold=0.05, |
121 | 128 | # iter_max=20 |
122 | 129 | # ) |
|
0 commit comments