Tail Loss Statistics

perfana.monte_carlo.risk.tail_loss(data, weights, threshold=-0.3, rebalance=True)[source]

Calculates the probability and expectation of a tail loss beyond a threshold

Threshold by default is set at -0.3, which means find the probability that the portfolio loses more than 30% of its value and the expected loss.

Notes

The return values are defined as follows:

  • prob

    Probability of having a tail loss exceeding the threshold

  • expected_loss

    Value of the expected loss for the portfolio at the threshold

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.

  • threshold – Portfolio loss threshold.

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

Returns

A named tuple containing the probability and expected loss of the portfolio exceeding the threshold.

Return type

TailLoss

Examples

>>> from perfana.datasets import load_cube
>>> from perfana.monte_carlo import tail_loss
>>> data = load_cube()[..., :3]  # first 3 asset classes only
>>> weights = [0.33, 0.34, 0.33]
>>> loss = tail_loss(data, weights, -0.3)
>>> loss.prob
0.241
>>> loss.expected_loss
-0.3978210273894446