mdd

Defined in fynance.features.metrics

mdd(X, raw=False, axis=0, dtype=None)[source]

Compute the maximum drawdown for each X’ series.

Maximum peak-to-trough decline observed over the full series. A standard tail-risk indicator: it captures the worst loss an investor would have endured, regardless of horizon. Reported in relative terms by default (fraction of peak); use raw=True for an absolute decline. For the full drawdown path use drawdown; combined with annual return, it gives the Calmar ratio (calmar).

Drawdown (:func:~`fynance.features.metrics.drawdown`) is the measure of the decline from a historical peak in some variable [5] (typically the cumulative profit or total open equity of a financial trading strategy).

Parameters:
Xnp.ndarray[np.dtype, ndim=1 or 2]

Time-series of prices, performances or index.

rawbool, optional
  • If True then compute the raw drawdown.

  • Else (default) compute the drawdown in percentage.

axis{0, 1}, optional

Axis along wich the computation is done. Default is 0.

dtypenp.dtype, optional

The type of the output array. If dtype is not given, infer the data type from X input.

Returns:
dtype or np.ndarray[dtype, ndim=1]

Value of Maximum DrawDown for each series.

See also

drawdown, calmar, sharpe, roll_mdd

Notes

Let DD the drawdown vector:

\[MDD = max(DD_{1:T})\]

Where, \(DD_t = \begin{cases}max(X_{1:t}) - X_t \text{, if raw=True} \\ 1 - \frac{X_t}{max(X_{1:t})} \text{, otherwise} \\ \end{cases}\), \(\forall t \in [1:T]\).

References

Examples

>>> X = np.array([70, 100, 80, 120, 160, 80]).astype(np.float64)
>>> mdd(X)
0.5
>>> mdd(X.reshape([6, 1]))
array([0.5])