6. Performance and risk metrics that actually matter
Level 12: Backtesting and Real Risk Metrics
In trading, assessing a strategy's effectiveness and risk is crucial. Performance metrics help you judge profitability and consistency; risk metrics reveal potential vulnerabilities. Let us go through the main ones in each family.
Part 1: performance metrics
1. Return measures
- Total P/L: assesses the overall profit or loss of the strategy.
- Average P/L: indicates the average profit or loss per unit of time.
- Hit rate: the proportion of winning trades to losing ones.
2. Risk-adjusted measures
- Sharpe ratio: measures excess return per unit of risk. In plain code: you subtract the risk-free rate from the strategy's return, divide by the standard deviation of returns, and annualize. It has limitations, such as assuming that future patterns will mimic past ones.
import numpy as np
excess = daily_returns - daily_risk_free_rate
annual_sharpe = np.sqrt(252) * excess.mean() / excess.std()- Sortino ratio: a variant of the Sharpe that focuses on the standard deviation of negative returns. It penalizes only the volatility that hurts.
downside = excess[excess < 0]
annual_sortino = np.sqrt(252) * excess.mean() / downside.std()- Calmar ratio: compares the average annual return of the last three years with the maximum drawdown of the same period.
3. Relative return measures
- Up/Down Capture Ratio: compares the fund's return with the benchmark's during the benchmark's up and down moves.
- Up/Down Percentage Ratio: measures how often the fund beats the benchmark in its positive and negative periods.
Part 2: risk metrics
1. Basic risk metrics
- Variance: indicates how much the return deviates from the expected one, reflecting the asset's volatility.
- Maximum drawdown: the largest peak-to-trough loss, expressed as a percentage.
equity_curve = (1 + daily_returns).cumprod()
rolling_max = equity_curve.cummax()
drawdown = equity_curve / rolling_max - 1
max_drawdown = drawdown.min()2. Relative risk measures
- Correlation coefficient: the strength and direction of the linear relationship between two variables.
- Beta: measures a portfolio's volatility relative to the market.
3. Tail risk measures
- VaR (Value-at-Risk): estimates the potential loss over a defined period and at a given confidence level.
- CVaR (Conditional VaR): averages the losses that exceed the VaR, offering a more complete assessment of risk.
var_95 = np.percentile(daily_returns, 5)
cvar_95 = daily_returns[daily_returns <= var_95].mean()Understanding and implementing these metrics lets you evaluate and refine strategies, balancing the pursuit of profitability with prudent risk management. Always consider the limitations and the applicability of each metric so that they fit your style and your objectives.
Why total return is not enough
Two strategies with the same 80% cumulative return can be entirely different universes if one achieved it with a 12% maximum drawdown and the other with a 55% one. And there is a piece of arithmetic worth burning into memory: recovering from a 40% fall requires a subsequent 66.7% rise; from a 50% fall, 100%. Losses and gains are not symmetric.
And a warning about the Sharpe: it punishes upside volatility just as much as downside volatility, and it implicitly assumes that standard deviation describes risk well. A strategy that systematically sells out-of-the-money options can display a very high Sharpe for years, with small and extremely regular returns, while accumulating an exposure that materializes in a single catastrophic session. The Sharpe does not see that tail; maximum drawdown and CVaR do.
To go deeper into this lesson
- Sharpe ratioin the glossary
- Sharpe ratio, max drawdown and CAGR: the basicsguide