roll_mdd¶
Defined in fynance.features.metrics
- roll_mdd(X, w=None, raw=False, axis=0, dtype=None)[source]
Compute the rolling maximum drawdown for each X’ series.
Where 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[dtype, ndim=1 or 2]
Time series (price, performance or index).
- wint, optional
Size of the lagged window of the rolling function, must be positive. If
w is Noneorw=0, thenw=X.shape[axis]. Default is None.- 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:
- np.ndrray[dtype, ndim=1 or 2]
Series of rolling maximum drawdown for each series.
See also
mdd,roll_calmar,roll_sharpe,drawdown
References
Examples
>>> X = np.array([70, 100, 80, 120, 160, 80]) >>> roll_mdd(X, dtype=np.float64) array([0. , 0. , 0.2, 0.2, 0.2, 0.5]) >>> roll_mdd(X, w=3, dtype=np.float64) array([0. , 0. , 0.2, 0.2, 0. , 0.5]) >>> X = np.array([100, 80, 70, 75, 110, 80]).astype(np.float64) >>> roll_mdd(X, raw=True, w=3, dtype=np.float64) array([ 0., 20., 30., 10., 0., 30.])