Metrics
On this page
Sharpe and Sortino Ratios
The Sharpe ratio measures average return per unit of total volatility. It shows whether the portfolio curve advances steadily or only at the cost of large swings. The Sortino ratio follows the same logic, but only considers downside volatility. It penalizes adverse phases without penalizing positive moves. In this context, Sharpe and Sortino are used to rank backtests from the actual portfolio equity path tracked by the engine.
The engine computes them from the portfolio equity curve. It starts from the initial capital, then records portfolio equity at each close of the backtest’s main timeframe. Returns are then computed from one close to the next on that series. Sharpe uses the full volatility of those returns. Sortino only keeps downside volatility. That series is not artificially rebuilt on another timeframe before the ratios are computed. The ratios are first computed on the backtest’s native timeframe, whether it is 15m, 1D, or 4W.
Internally, the engine keeps constant-time running aggregates on that native-timeframe return series and derives the final ratios from those aggregates when they are requested.
The ratios are then annualized. You can access these values through the sharpe_ratio and sortino_ratio variables in objectives. They make backtests running on different timeframes easier to compare while remaining consistent with the engine’s actual portfolio tracking during the run.
Sharpe Specification
The Sharpe ratio uses a standard definition with the risk-free rate fixed at 0, applied to the close-to-close return series of portfolio equity sampled on the backtest’s native timeframe.
- Source series: initial capital, then portfolio equity at each close of the main timeframe
- Elementary return:
- Risk-free rate:
0 - Mean return:
- Standard deviation:
- Annualization: , using a
24/7crypto year of365days
Sortino Specification
The Sortino ratio uses a standard definition with a downside target fixed at 0, applied to the same close-to-close return series of portfolio equity, again on the backtest’s native timeframe.
- Source series: initial capital, then portfolio equity at each close of the main timeframe
- Elementary return:
- Downside target:
0 - Downside component:
- Downside deviation:
- Annualization: , using a
24/7crypto year of365days
For a 4W timeframe, the nominal duration used is 28 fixed days, not a calendar month.
When the calculation is undefined, the returned value is NaN, notably when there are fewer than two valid returns, when previous equity is less than or equal to 0, when an observation is not finite, or when the relevant volatility is zero.
Calmar Ratio
The Calmar ratio measures annualized return per unit of maximum drawdown. It shows whether portfolio performance was achieved without going through overly deep declines.
In this context, Calmar is used as a ranking metric for optimization. It compares compounded annual growth to the maximum drawdown observed over the effective backtest period.
Calmar Specification
- Formula:
- CAGR: , using a
24/7crypto year of365days and the effective backtest duration
This design keeps Calmar aligned with the finalized backtest window used by the engine and avoids rebuilding a second drawdown series from stored equity samples.
When the calculation is undefined, the returned value is NaN. This happens notably when initial capital is less than or equal to 0, final capital is less than or equal to 0, elapsed duration is less than or equal to 0, maximum drawdown percent is less than or equal to 0, or any intermediate value is not finite.