Annualized Quantile Returns against Benchmark

perfana.monte_carlo.returns.annualized_bmk_quantile_returns_m(data, weights, bmk_weights, quantile, freq, geometric=True, rebalance=True, interpolation='midpoint')[source]

Compares the annualized returns against a benchmark at the specified quantiles.

The benchmark components must be placed after the portfolio components in the simulated returns cube.

Parameters
  • data (ndarray) – Monte carlo simulation data. This must be 3 dimensional with the axis representing time, trial and asset respectively.

  • weights (Union[Iterable[Union[int, float]], ndarray, Series]) – Weights of the portfolio. This must be 1 dimensional and must match the dimension of the data’s last axis.

  • bmk_weights (Union[Iterable[Union[int, float]], ndarray, Series]) – Weights of the benchmark portfolio.

  • quantile (Union[float, Iterable[float]]) – Quantile or sequence of quantiles to compute, which must be between 0 and 1 inclusive

  • freq (Union[str, int]) – Frequency of the data. Can either be a string (‘week’, ‘month’, ‘quarter’, ‘semi-annual’, ‘year’) or an integer specifying the number of units per year. Week: 52, Month: 12, Quarter: 4, Semi-annual: 6, Year: 1.

  • geometric (bool) – If True, calculates the geometric mean, otherwise, calculates the arithmetic mean.

  • rebalance (bool) – If True, portfolio is assumed to be rebalanced at every step.

  • interpolation

    This optional parameter specifies the interpolation method to use when the desired quantile lies between two data points i < j:

    • linear: i + (j - i) * fraction, where fraction is the fractional part of the index surrounded by i and j.

    • lower: i.

    • higher: j.

    • nearest: i or j, whichever is nearest.

    • midpoint: (i + j) / 2.

Returns

The returns of the portfolio over the benchmark at the specified quantiles

Return type

float or array_like of floats

Examples

>>> from perfana.datasets import load_cube
>>> from perfana.monte_carlo import annualized_bmk_quantile_returns_m
>>> cube = load_cube()
>>> weights = [0.25, 0.18, 0.13, 0.11, 0.24, 0.05, 0.04]
>>> bmk_weights = [0.65, 0.35]
>>> freq = "quarterly"
>>> q = 0.25
>>> annualized_bmk_quantile_returns_m(cube, weights, bmk_weights, q, freq)
-0.010792419409674459
>>> q = [0.25, 0.75]
>>> annualized_bmk_quantile_returns_m(cube, weights, bmk_weights, q, freq)
array([-0.01079242, -0.0025487 ])