roll_calmar¶
Defined in fynance.features.metrics
- roll_calmar(X, period=252., w=None, axis=0, dtype=None, ddof=0)[source]
Compute the rolling Calmar ratio of each X’ series.
- Parameters:
- Xnp.ndarray[dtype, ndim=1 or 2]
Time-series of price, performance or index.
- periodint, optional
Number of period per year, default is 252 (trading days per year).
- 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.- 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.
- ddofint, optional
Means Delta Degrees of Freedom, the divisor used in calculations is
t - ddof, wheretrepresents the number of elements in time axis. Default is 0.
- Returns:
- np.ndarray[dtype, ndim=1 or 2]
Series of rolling Calmar ratio.
See also
roll_mdd,roll_sharpe,calmar
Notes
Calmar ratio [3] is the rolling compouned annual return (
roll_annual_return) over the rolling maximum drawdown (roll_mdd). Let \(T\) the number of time observations, DD the vector of drawdown, \(\forall t \in [1:T]\):\[\begin{split}calmarRatio_t = \frac{annualReturn_t}{MDD_t} \\ \\\end{split}\]With, \(annualReturn_t = \frac{X_t}{X_1}^{\frac{period}{t}} - 1\) and \(MDD_t = max(DD_t)\), where \(DD_t = 1 - \frac{X_t}{max(X_{1:t})}\).
References
Examples
Assume a monthly series of prices:
>>> X = np.array([70, 100, 80, 120, 160, 80]).astype(np.float64) >>> roll_calmar(X, period=12) array([ 0. , 0. , 3.52977926, 20.18950437, 31.35989887, 0.6122449 ])