Skip to content

Commit 57ceed8

Browse files
committed
refactor: Move DCF methods to PortfolioDCF class
1 parent fee3ef2 commit 57ceed8

File tree

4 files changed

+386
-219
lines changed

4 files changed

+386
-219
lines changed

main.py

Lines changed: 35 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -2,38 +2,39 @@
22

33
import okama as ok
44
# 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+
)
2616

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()
3324

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()
3535

3636
# Rolling / Expanding Risk
37+
3738
# al = ok.AssetList(['DJI.INDX',
3839
# 'BND.US'
3940
# ])
@@ -46,9 +47,9 @@
4647
# pf = ok.Portfolio(['SPY.US',
4748
# 'BND.US'
4849
# ])
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

Comments
 (0)