Drawdown Statistics

perfana.monte_carlo.risk.drawdown_m(data, weights, geometric=True, rebalance=True)[source]

Calculates the drawdown statistics

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.

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

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

Returns

A named tuple containing the average maximum drawdown and the drawdown path for each simulation instance.

Return type

Drawdown

Examples

>>> from perfana.datasets import load_cube
>>> from perfana.monte_carlo import drawdown_m
>>> data = load_cube()[..., :7]
>>> weights = [0.25, 0.18, 0.13, 0.11, 0.24, 0.05, 0.04]
>>> dd = drawdown_m(data, weights)
>>> dd.average
-0.3198714473717889
>>> dd.paths.shape
(80, 1000)