Previous topic


Next topic



fynance.features.metrics.roll_calmar(X, period=252.0, w=None, axis=0, dtype=None, ddof=0)

Compute the rolling Calmar ratio of each X’ series.

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

Time-series of price, performance or index.

period : int, optional

Number of period per year, default is 252 (trading days per year).

w : int, optional

Size of the lagged window of the rolling function, must be positive. If w is None or w=0, then w=X.shape[axis]. Default is None.

axis : {0, 1}, optional

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

dtype : np.dtype, optional

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

ddof : int, optional

Means Delta Degrees of Freedom, the divisor used in calculations is t - ddof, where t represents the number of elements in time axis. Default is 0.

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

Series of rolling Calmar ratio.


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})}\).




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 ])