Backtesting Formulas Reference
The key formulas used to evaluate a backtest, gathered in one place, each with every variable defined and its standard textbook form noted.
Backtesting Formulas Reference: The core backtesting formulas are: CAGR as the geometric annual growth rate; the Sharpe ratio as excess return over total volatility; the Sortino ratio as excess return over downside deviation; the Calmar ratio as CAGR over maximum drawdown; the information ratio as active return over tracking error; maximum drawdown as the largest peak-to-trough decline; the Ulcer index as the root-mean-square of drawdowns; profit factor, payoff ratio and expectancy from the trade record; the recovery factor as net profit over maximum drawdown; the Kelly fraction as the growth-optimal bet size; and risk of ruin as the probability of hitting a capital floor. Each below is the standard definition, and any result computed from them excludes real trading costs unless the underlying returns already include them.
These are standard textbook definitions. Small variations exist between sources (for example whether the Sharpe uses a risk-free rate or zero, or whether drawdown is measured on returns or log-equity); where that happens it is noted. Every result is only as trustworthy as the return or trade series fed in, and all of them exclude brokerage, STT and slippage unless those costs are already reflected in the returns.
Return and growth
| Formula | Definition | Variables |
|---|---|---|
| CAGR = (End ÷ Start)^(1 ÷ years) − 1 | Compound annual growth rate; the geometric annualised return. | End = ending equity; Start = starting equity; years = length of period in years. |
| Total return = (End − Start) ÷ Start | Absolute percentage gain or loss over the whole period. | End, Start as above. |
| Annualised return = (1 + total return)^(1 ÷ years) − 1 | Return rescaled to a one-year basis. | years = period length in years. |
| Geometric mean = (Π(1 + rt))^(1 ÷ n) − 1 | Compounded average return per period; always ≤ arithmetic mean. | rt = return in period t; n = number of periods; Π = product over all periods. |
Risk-adjusted return
| Formula | Definition | Variables |
|---|---|---|
| Sharpe = (Rp − Rf) ÷ σp, annualised × √N | Excess return per unit of total volatility. | Rp = portfolio return; Rf = risk-free rate; σp = standard deviation of portfolio returns; N = periods per year (252 daily, 52 weekly, 12 monthly). |
| Sortino = (Rp − Rf) ÷ σdown | Excess return per unit of downside deviation only. | σdown = standard deviation of returns below the target (often 0 or Rf). |
| Calmar = CAGR ÷ |MaxDD| | Return per unit of worst peak-to-trough loss, usually over 3 years. | MaxDD = maximum drawdown as a fraction. |
| Information ratio = (Rp − Rb) ÷ TE | Consistency of active return over a benchmark. | Rb = benchmark return; TE = tracking error, the standard deviation of (Rp − Rb). |
To annualise a Sharpe computed on per-period returns, multiply by √N. This assumes returns are roughly independent across periods; positive autocorrelation makes the annualised figure overstated.
Drawdown and downside
| Formula | Definition | Variables |
|---|---|---|
| Drawdownt = (Peakt − Equityt) ÷ Peakt | Decline from the running high-water mark at time t. | Equityt = equity at t; Peakt = highest equity up to t. |
| MaxDD = max over t of Drawdownt | The largest such decline over the whole test. | as above. |
| Ulcer index = √( (1 ÷ n) × Σ Dt² ) | Root-mean-square of percentage drawdowns; penalises deep and long declines. | Dt = percentage drawdown at t; n = number of periods; Σ = sum over all t. |
| Recovery to par = 1 ÷ (1 − D) − 1 | Gain needed to recover a drawdown of depth D. | D = drawdown as a fraction (0.20 → a 25% gain is needed). |
Trade-based metrics
| Formula | Definition | Variables |
|---|---|---|
| Profit factor = gross profit ÷ gross loss | Currency won per unit lost across all trades. | gross profit = sum of all winning trades; gross loss = absolute sum of all losing trades. |
| Payoff ratio = AvgWin ÷ AvgLoss | Size of the average winner relative to the average loser. | AvgWin = mean of winning trades; AvgLoss = mean absolute value of losing trades. |
| Win rate = wins ÷ total trades | Fraction of trades that closed profitable. | wins = number of winning trades; total = number of trades. |
| Expectancy = (Win% × AvgWin) − (Loss% × AvgLoss) | Average profit or loss per trade. | Win% = win rate; Loss% = 1 − Win%; AvgWin, AvgLoss as above. |
| Expectancy (in R) = mean of all R-multiples | Size-independent edge, in units of initial risk. | R-multiple = trade P&L ÷ initial risk (1R). |
| Recovery factor = net profit ÷ |MaxDD amount| | How many times the strategy earned back its worst decline. | net profit = total profit over the test; MaxDD amount = the deepest peak-to-trough loss in currency. |
Sizing and survival
| Formula | Definition | Variables |
|---|---|---|
| Kelly fraction f* = W − (1 − W) ÷ R | Growth-optimal bet fraction for a known edge; use a fraction of it in practice. | W = win probability; R = payoff ratio (AvgWin ÷ AvgLoss). |
| Position size = (Equity × risk fraction) ÷ (stop distance × point value) | Quantity that risks a fixed fraction of equity to the stop. | risk fraction = fraction risked per trade; stop distance = points to the stop; point value = currency per point per unit. |
| Risk of ruin (simple model) ≈ ((1 − edge) ÷ (1 + edge))^u | Probability of reaching the capital floor; falls sharply as bets shrink. | edge = 2W − 1 for even-payoff bets; u = units of capital (equity ÷ risk per trade). |
The Kelly and risk-of-ruin formulas assume a stable, accurately estimated edge and independent trades, which live markets rarely provide. They are best read as comparative guides, smaller bets mean lower ruin, rather than precise probabilities, which is why practitioners trade well below the mathematically optimal size.
A worked illustration (India, illustrative only)
Suppose a strategy grew ₹5,00,000 to ₹7,35,000 over 3 years. CAGR = (7,35,000 ÷ 5,00,000)^(1 ÷ 3) − 1 ≈ 13.7%. If its worst drawdown was 18%, Calmar ≈ 0.137 ÷ 0.18 ≈ 0.76. If trades won 55% of the time with an average win of ₹8,000 and average loss of ₹5,000, expectancy = (0.55 × 8,000) − (0.45 × 5,000) = 4,400 − 2,250 = ₹2,150 per trade, and payoff ratio = 8,000 ÷ 5,000 = 1.6. These figures exclude brokerage, STT and slippage and are for education only, never a claim of achievable returns.
Frequently asked questions
How do I annualise the Sharpe ratio?
What is the difference between the Sharpe and Sortino formulas?
Why does a 50% drawdown require a 100% gain to recover?
What does the Kelly formula actually tell me?
Do these formulas include trading costs?
Is the risk-of-ruin formula a precise probability?
Last reviewed 11 July 2026. Educational content only — not investment advice.