okama.Portfolio.percentile_wealth

Portfolio.percentile_wealth(distr='norm', years=1, percentiles=[10, 50, 90], today_value=None, n=1000)

Calculate percentiles for portfolio wealth indexes distribution.

Portfolio wealth indexes are derived from the rate of return time series of a given distribution type.

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

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

yearsint, default 1

Investment period length to calculate wealth index. It should not exceed 1/2 of the portfolio history period length ‘period_length’.

percentileslist of int, default [10, 50, 90]

List of percentiles to be calculated.

today_valueint, optional

Initial value of the wealth index. If today_value is None the last value of the historical wealth indexes is taken. It can be useful to plot the forecast of wealth index togeather with the hitorical data.

nint, default 1000

Number of random time series to generate with Monte Carlo simulation (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’).

Returns:
dict

Dictionary {Percentile: value}

Examples

>>> pf = ok.Portfolio(['SPY.US', 'AGG.US', 'GLD.US'], weights=[.60, .35, .05], rebalancing_period='year')
>>> pf.percentile_wealth(distr='hist', years=5, today_value=1000, n=5000)
{10: 1228.3741255659957, 50: 1491.7857161011104, 90: 1745.1130920663286}
Percentiles values for the wealth index 5 years forecast if the initial value is 1000.