← Back to Algorithmic Glossary

Calmar Ratio in Python

A risk-adjusted return metric that compares annualized returns against maximum drawdown.

Definition

The Calmar Ratio, introduced by Terry Young in 1991, measures the relationship between a strategy's annualized return and its maximum drawdown over a rolling 3-year period. Unlike volatility-based ratios, it anchors risk to the worst-case observed loss, making it particularly relevant for trend-following and CTA (Commodity Trading Advisor) strategies where drawdown duration matters as much as depth.

Quantitative Formula

Calmar=RannualizedMDDCalmar = \frac{R_{annualized}}{|MDD|}

Where RannualizedR_{annualized} is the compound annualized growth rate (CAGR) of the strategy over the period, and MDD|MDD| is the absolute value of the Maximum Drawdown — the largest peak-to-trough decline observed.

Why It Matters in Backtesting

A strategy returning 40% annually with a 60% max drawdown has a Calmar of 0.67 — most allocators would reject it. A strategy returning 20% with a 10% drawdown has a Calmar of 2.0 — far more deployable. In backtesting, the Calmar Ratio exposes strategies that curve-fit to bull markets by hiding their catastrophic drawdown profile.

Python Implementation

import numpy as np
    import pandas as pd

    def calculate_calmar_ratio(returns: pd.Series, trading_days: int = 252) -> float:
        """Calculates the Calmar Ratio from a daily returns series."""
        cumulative = (1 + returns).cumprod()
        peak = cumulative.cummax()
        drawdown = (cumulative - peak) / peak
        max_drawdown = drawdown.min()
        annualized_return = returns.mean() * trading_days
        return annualized_return / abs(max_drawdown) if max_drawdown != 0 else 0.0

Test this in a live environment

Stop running Jupyter notebooks locally. Paste this Calmar Ratio code directly into Valetha's Strategy Lab and run a full historical backtest in seconds.

Open the Python Strategy Lab

Ready to find your edge ?

Start for Free