okama.Portfolio.percentile_distribution_cagr

Portfolio.percentile_distribution_cagr(distr='norm', years=1, percentiles=[10, 50, 90], n=10000)

Calculate percentiles for a given CAGR distribution.

CAGR - Compound Annual Growth Rate. CAGR is calculated for each of n random returns time series of a given distribution. Random time series are generated with Monte Carlo simulation. CAGR time frame should not exceed 1/2 of portfolio history period length.

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

Distribution type for the rate of return of portfolio. ‘norm’ - for normal distribution. ‘lognorm’ - for lognormal distribution.

years: int, default 1

Time frame for portfolio CAGR. It should not exceed 1/2 of the portfolio history period length ‘period_length’.

percentiles: list of int, default [10, 50, 90]

List of percentiles to be calculated.

nint, default 10000

Number of random time series to generate with Monte Carlo simulation. Larger argument values can be used to increase the precision of the calculation. But this will lead to slower performance.

Returns:
dict

Dictionary {Percentile: value}

Examples

>>> pf = ok.Portfolio(['SPY.US', 'AGG.US', 'GLD.US'], weights=[.60, .35, .05], rebalancing_period='year')
>>> pf.percentile_distribution_cagr()
{10: -0.0329600265453808, 50: 0.08247141141668779, 90: 0.21338327078214836}
Forecast CAGR according to normal distribution within 1 year period.
>>> pf.percentile_distribution_cagr(years=5)
{10: 0.030625112922274055, 50: 0.08346815557550402, 90: 0.13902575176654647}
Forecast CAGR according to normal distribution within 5 year period.