okama.Portfolio.percentile_inverse_cagr

Portfolio.percentile_inverse_cagr(distr='norm', years=1, score=0, n=None)

Compute the percentile rank of a score (CAGR value).

Percentile rank can be calculated for given distribution type or for hsitorical distribution of CAGR.

If percentile_inverse of, for example, 0% (CAGR value) is equal to 8% for 1 year time frame it means that 8% of the CAGR values in the distribution are negative in 1 year periods. Or in other words the probability of getting negative result after 1 year of investments is 8%.

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

The rate of teturn distribution type. ‘norm’ - for normal distribution. ‘lognorm’ - for lognormal distribution. ‘hist’ - percentiles are taken from the historical data.

years: int, default 1

Period length (time frame) in years when CAGR is calculated.

score: float, default 0

Score that is compared to the elements in CAGR array.

n: int, optional

Number of random time series with the defined distributions (for ‘norm’ or ‘lognorm’ only). Larger argument values can be used to increase the precision of the calculation. But this will lead to slower performance. Is not required for historical distribution (dist=’hist’). For ‘norm’ or ‘lognorm’ distribution default value n=1000 is used.

Returns:
float

Percentile-position of score (0-100) relative to distribution.

Examples

>>> pf = ok.Portfolio(['SPY.US', 'AGG.US', 'GLD.US'], weights=[.60, .35, .05], rebalancing_period='year')
>>> pf.percentile_inverse_cagr(distr='lognorm', score=0, years=1, n=5000)
18.08
The probability of getting negative result (score=0) in 1 year period for lognormal distribution.