okama.PortfolioDCF.monte_carlo_survival_period

PortfolioDCF.monte_carlo_survival_period(distr='norm', years=1, n=20)

Generate a survival period distribution for a portfolio with cash flows by Monte Carlo simulation.

It’s possible to analyze the distribution finding “min”, “max” and percentiles to see for how long will last the investment strategy - possible longevity period.

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

Distribution type for the rate of return of portfolio.

yearsint, default 1

Forecast period for portfolio wealth index time series.

nint, default 100

Number of random wealth indexes to generate with Monte Carlo simulation.

Returns:
Series

Survival period distribution for a portfolio with cash flows.

Examples

>>> pf = ok.Portfolio(
    ['SPY.US', 'AGG.US', 'GLD.US'],
    weights=[.60, .35, .05],
    rebalancing_period='year',
    initial_amount=300_000,
    cashflow=-10_000
)
>>> s = pf.dcf.monte_carlo_survival_period(
    distr="norm",
    years=10,
    n=100,
)
>>> s.min()
2.2
>>> s.max()
3.6
>> s.mean()
2.737
>> s.quantile(50 / 100)
2.7