okama.PortfolioDCF.monte_carlo_survival_period

PortfolioDCF.monte_carlo_survival_period(threshold=0)

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

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

Parameters:
thresholdfloat, default 0

The percentage of the initial investments when the portfolio balance considered voided. This parameter is important to use in cash flow strategies with a fixed whtdrawal percentage (PercentageStrategy).

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])
>>> # set Monte Carlos parameters
>>> pf.dcf.set_mc_parameters(
...        distribution="t",  # use Student's distribution (t-distribution)
...        period=50,  # make forecast for 50 years
...        number=200  # create 200 randow wealth indexes
...    )
>>> # Set Cash Flow parameters
>>> pc = ok.PercentageStrategy(pf)  # create PercentageStrategy linked to the portfolio
>>> pc.initial_investment = 10_000  # add initial investments size
>>> pc.frequency = "year"  # set cash flow frequency
>>> pc.percentage = -0.20  # set withdrawal percentage
>>> # Assign the strategy to Portfolio
>>> pf.dcf.cashflow_parameters = pc
>>> s = pf.dcf.monte_carlo_survival_period(threshold=0.10)  # the balance is considered voided at 10%
>>> s.min()
np.float64(10.5)
>>> s.max()
np.float64(33.5)
>>> s.mean()
np.float64(17.9055)
>>> s.quantile(50 / 100)
np.float64(17.5)