okama.Portfolio.monte_carlo_returns_ts

Portfolio.monte_carlo_returns_ts(distr='norm', years=1, n=100)

Generate portfolio monthly rate of return time series with Monte Carlo simulation.

Monte Carlo simulation generates n random monthly time series with a given distribution. Forecast period should not exceed 1/2 of portfolio history period length.

First date of forecaseted returns is portfolio last_date.

Parameters:
distr{‘norm’, ‘lognorm’}, default ‘norm’

Distribution type for rate of return time series. ‘norm’ - for normal distribution. ‘lognorm’ - for lognormal distribution.

yearsint, default 1

Forecast period for portfolio monthly rate of return time series. It should not exceed 1/2 of the portfolio history period length ‘period_length’.

nint, default 100

Number of random rate of return time series to generate with Monte Carlo simulation.

Returns:
DataFrame

Table with n random rate of return monthly time series.

Examples

>>> pf = ok.Portfolio(['SPY.US', 'AGG.US', 'GLD.US'], weights=[.60, .35, .05], rebalancing_period='month')
>>> pf.monte_carlo_returns_ts(years=8, distr='norm', n=5000)
             0         1         2     ...      4997      4998      4999
2021-07 -0.008383 -0.013167 -0.031659  ...  0.046717  0.065675  0.017933
2021-08  0.038773 -0.023627  0.039208  ... -0.016075  0.034439  0.001856
2021-09  0.005026 -0.007195 -0.003300  ... -0.041591  0.021173  0.114225
2021-10 -0.007257  0.003013 -0.004958  ...  0.037057 -0.009689 -0.003242
2021-11 -0.005006  0.007090  0.020741  ...  0.026509 -0.023554  0.010271
           ...       ...       ...  ...       ...       ...       ...
2029-02 -0.065898 -0.003673  0.001198  ...  0.039293  0.015963 -0.050704
2029-03  0.021215  0.008783 -0.017003  ...  0.035144  0.002169  0.015055
2029-04  0.002454 -0.016281  0.017004  ...  0.032535  0.027196 -0.029475
2029-05  0.011206  0.023396 -0.013757  ... -0.044717 -0.025613 -0.002066
2029-06 -0.016740 -0.007955  0.002862  ... -0.027956 -0.012339  0.048974
[96 rows x 5000 columns]