Risk Performance Benchmark

perfana.monte_carlo.risk.prob_under_perf(data, weights, bmk_weights, rebalance=True, terminal=False)[source]

Calculates the probability of the portfolio underperforming the benchmark at the terminal state

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.

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

  • terminal – If True, this only compares the probability of underperformance at the last stage. If False (default), the calculation will take into account if the portfolio was “ruined” and count it as an underperformance against the benchmark even though the terminal value is higher than the benchmark. If both portfolios are “ruined”, then it underperforms if it is ruined earlier.

Returns

A named tuple containing the probability of underperformance and loss

Return type

float

Examples

>>> from perfana.datasets import load_cube
>>> from perfana.monte_carlo import prob_under_perf
>>> data = load_cube()
>>> weights = [0.25, 0.18, 0.13, 0.11, 0.24, 0.05, 0.04]
>>> bmk_weights = [0.65, 0.35]
>>> prob_under_perf(data, weights, bmk_weights)
0.863