okama.Portfolio.monte_carlo_wealth
- Portfolio.monte_carlo_wealth(distr='norm', years=1, n=100)
Generate portfolio wealth index with Monte Carlo simulation.
Monte Carlo simulation generates n random monthly time series. Each wealth index is calculated with rate of return time series of a given distribution.
Forecast period should not exceed 1/2 of portfolio history period length. First date of forecasted returns is portfolio last_date. First value for the forecasted wealth indexes is the last historical portfolio index value. It is useful for a chart with historical wealth index and forecasted values.
- Parameters:
- distr{‘norm’, ‘lognorm’, ‘t’}, default ‘norm’
Distribution type for the rate of return of portfolio. ‘norm’ - for normal distribution. ‘lognorm’ - for lognormal distribution. ‘t’ - for Student’s T distribution.
- yearsint, default 1
Forecast period for portfolio wealth index time series. It should not exceed 1/2 of the portfolio history period length ‘period_length’.
- nint, default 100
Number of random wealth indexes to generate with Monte Carlo simulation.
- Returns:
- DataFrame
Table with n random wealth indexes monthly time series.
Examples
>>> pf = ok.Portfolio(['SPY.US', 'AGG.US', 'GLD.US'], weights=[.60, .35, .05], rebalancing_period='month') >>> pf.monte_carlo_wealth(distr='lognorm', years=5, n=1000) 0 1 ... 998 999 2021-07 3895.377293 3895.377293 ... 3895.377293 3895.377293 2021-08 3869.854680 4004.814981 ... 3874.455244 3935.913516 2021-09 3811.125717 3993.783034 ... 3648.925159 3974.103856 2021-10 4053.024519 4232.141143 ... 3870.099003 4082.189688 2021-11 4179.544897 4156.839698 ... 3899.249696 4097.003962 2021-12 4237.030690 4351.305114 ... 3916.639721 4042.011774