fynance.features.metrics.calmar¶
-
fynance.features.metrics.
calmar
(X, period=252, axis=0, dtype=None, ddof=0)¶ Compute the Calmar Ratio for each X’ series.
Parameters: - X : np.ndarray[dtype, ndim=1 or 2]
Time-series price, performance or index.
- period : int, optional
Number of period per year, default is 252 (trading days per year).
- 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
, whereT
represents the number of elements in time axis. Default is 0.
Returns: - dtype or np.ndarray([dtype, ndim=1])
Values of Calmar ratio for each series.
See also
Notes
Calmar ratio [3] is the compouned annual return (
annual_return
) over the maximum drawdown (mdd
). Let \(T\) the number of time observations, DD the vector of drawdown:\[calmarRatio = \frac{annualReturn}{MDD}\]With, \(annualReturn = \frac{X_T}{X_1}^{\frac{period}{T}} - 1\) and \(MDD = max(DD_{1:T})\).
Where, \(DD_t = 1 - \frac{X_t}{max(X_{1:t})}\), \(\forall t \in [1:T]\).
References
[3] https://en.wikipedia.org/wiki/Calmar_ratio Examples
Assume a series of monthly prices:
>>> X = np.array([70, 100, 80, 120, 160, 105, 80]).astype(np.float64) >>> calmar(X, period=12, ddof=1) array(0.6122449) >>> calmar(X.reshape([7, 1]), period=12) array([0.51446018])