|
2 | 2 |
|
3 | 3 | import okama as ok
|
4 | 4 | # Portfolio WithDrawls
|
5 |
| -# weights = [0.32, 0.31, 0.18, .19] |
6 |
| -# portf = ok.Portfolio(['RGBITR.INDX', 'RUCBTRNS.INDX', 'MCFTR.INDX', 'GC.COMM'], |
7 |
| -# ccy="RUB", |
8 |
| -# weights=weights, |
9 |
| -# inflation=False, |
10 |
| -# symbol="retirement_portf.PF", |
11 |
| -# rebalancing_period='year', |
12 |
| -# cashflow=-150_000, |
13 |
| -# initial_amount=39_000_000, |
14 |
| -# discount_rate=0.01 |
15 |
| -# ) |
16 |
| - |
17 |
| -# print(portf.discount_rate) |
18 |
| -# print(portf) |
19 |
| -# print(f"{portf.get_cagr()}") |
20 |
| -# print(f"{portf.initial_amount_pv=}, {portf.cashflow_pv=}") |
21 |
| -# print(f"{portf.survival_period=}") |
22 |
| -# print(f"{portf.survival_date=}") |
23 |
| -# portf.wealth_index.plot() |
24 |
| -# |
25 |
| -# portf.plot_forecast_monte_carlo(distr="norm", years=30, backtest=True, n=100) |
| 5 | +weights = [0.32, 0.31, 0.18, .19] |
| 6 | +portf = ok.Portfolio(['RGBITR.INDX', 'RUCBTRNS.INDX', 'MCFTR.INDX', 'GC.COMM'], |
| 7 | + ccy="RUB", |
| 8 | + weights=weights, |
| 9 | + inflation=True, |
| 10 | + symbol="retirement_portf.PF", |
| 11 | + rebalancing_period='year', |
| 12 | + cashflow=-200_000, |
| 13 | + initial_amount=39_000_000, |
| 14 | + discount_rate=None |
| 15 | + ) |
26 | 16 |
|
27 |
| -# s_periods = portf.monte_carlo_survival_period(distr="lognorm", years=25, n=10) |
28 |
| -# print(f"медиана {s_periods.quantile(50 / 100)}") |
29 |
| -# print(f"первый порцентиль {s_periods.quantile(1 / 100)}") |
30 |
| -# print(f"99й порцентиль {s_periods.quantile(99 / 100)}") |
31 |
| -# print(f"минимум {s_periods.min()}") |
32 |
| -# print(f"среднее {s_periods.mean()}") |
| 17 | +print(portf.discount_rate) |
| 18 | +print(portf) |
| 19 | +print(f"{portf.get_cagr()}") |
| 20 | +print(f"{portf.dcf.initial_amount_pv=}, {portf.dcf.cashflow_pv=}") |
| 21 | +print(f"{portf.dcf.survival_period=}") |
| 22 | +print(f"{portf.dcf.survival_date=}") |
| 23 | +portf.dcf.wealth_index.plot() |
33 | 24 |
|
34 |
| -# plt.show() |
| 25 | +portf.dcf.plot_forecast_monte_carlo(distr="norm", years=30, backtest=True, n=100) |
| 26 | + |
| 27 | +s_periods = portf.dcf.monte_carlo_survival_period(distr="lognorm", years=25, n=10) |
| 28 | +print(f"медиана {s_periods.quantile(50 / 100)}") |
| 29 | +print(f"первый порцентиль {s_periods.quantile(1 / 100)}") |
| 30 | +print(f"99й порцентиль {s_periods.quantile(99 / 100)}") |
| 31 | +print(f"минимум {s_periods.min()}") |
| 32 | +print(f"среднее {s_periods.mean()}") |
| 33 | + |
| 34 | +plt.show() |
35 | 35 |
|
36 | 36 | # Rolling / Expanding Risk
|
| 37 | + |
37 | 38 | # al = ok.AssetList(['DJI.INDX',
|
38 | 39 | # 'BND.US'
|
39 | 40 | # ])
|
|
46 | 47 | # pf = ok.Portfolio(['SPY.US',
|
47 | 48 | # 'BND.US'
|
48 | 49 | # ])
|
49 |
| -rf3 = ok.Portfolio( |
50 |
| - ["BND.US", "VTI.US", "VXUS.US"], |
51 |
| - weights=[0.40, 0.40, 0.20], |
52 |
| - rebalancing_period="year", |
53 |
| -) |
54 |
| -print(rf3.recovery_period) |
| 50 | +# rf3 = ok.Portfolio( |
| 51 | +# ["BND.US", "VTI.US", "VXUS.US"], |
| 52 | +# weights=[0.40, 0.40, 0.20], |
| 53 | +# rebalancing_period="year", |
| 54 | +# ) |
| 55 | +# print(rf3.recovery_period) |
0 commit comments