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

FormulaDefinitionVariables
CAGR = (End ÷ Start)^(1 ÷ years) − 1Compound annual growth rate; the geometric annualised return.End = ending equity; Start = starting equity; years = length of period in years.
Total return = (End − Start) ÷ StartAbsolute percentage gain or loss over the whole period.End, Start as above.
Annualised return = (1 + total return)^(1 ÷ years) − 1Return rescaled to a one-year basis.years = period length in years.
Geometric mean = (Π(1 + rt))^(1 ÷ n) − 1Compounded average return per period; always ≤ arithmetic mean.rt = return in period t; n = number of periods; Π = product over all periods.

Risk-adjusted return

FormulaDefinitionVariables
Sharpe = (Rp − Rf) ÷ σp, annualised × √NExcess 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) ÷ σdownExcess 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) ÷ TEConsistency 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

FormulaDefinitionVariables
Drawdownt = (Peakt − Equityt) ÷ PeaktDecline from the running high-water mark at time t.Equityt = equity at t; Peakt = highest equity up to t.
MaxDD = max over t of DrawdowntThe 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) − 1Gain needed to recover a drawdown of depth D.D = drawdown as a fraction (0.20 → a 25% gain is needed).

Trade-based metrics

FormulaDefinitionVariables
Profit factor = gross profit ÷ gross lossCurrency 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 ÷ AvgLossSize 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 tradesFraction 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-multiplesSize-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

FormulaDefinitionVariables
Kelly fraction f* = W − (1 − W) ÷ RGrowth-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))^uProbability 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?
Multiply the per-period Sharpe by the square root of the number of periods in a year: √252 for daily returns, √52 for weekly, √12 for monthly. This assumes returns are roughly independent across periods; if they are positively autocorrelated, the annualised figure is overstated.
What is the difference between the Sharpe and Sortino formulas?
They share the same numerator, excess return (Rp − Rf), but differ in the denominator. Sharpe divides by the standard deviation of all returns, penalising upside and downside equally. Sortino divides only by downside deviation, the standard deviation of returns below a target, so it does not penalise favourable volatility.
Why does a 50% drawdown require a 100% gain to recover?
Because gains compound on a reduced base. The recovery formula 1 ÷ (1 − D) − 1 with D = 0.50 gives 1 ÷ 0.50 − 1 = 1, that is a 100% gain. Losing half your capital leaves you needing to double what remains just to return to par, which is why deep drawdowns are so damaging.
What does the Kelly formula actually tell me?
For a known edge, f* = W − (1 − W) ÷ R gives the bet fraction that maximises long-run growth, where W is the win probability and R the payoff ratio. It is a theoretical ceiling: full Kelly produces severe drawdowns and assumes the inputs are exact, so practitioners use a fraction such as half- or quarter-Kelly.
Do these formulas include trading costs?
No. They are standard definitions computed from a return or trade series. If that underlying series already had brokerage, STT, exchange fees, GST and slippage subtracted, the metrics are net of costs; otherwise they are gross and therefore optimistic. Always state which, because it changes the meaning entirely.
Is the risk-of-ruin formula a precise probability?
No. The simple closed form assumes fixed even payoffs, a constant edge and independent trades, none of which strictly holds in markets. It is best used comparatively, to show that smaller position sizes lower ruin probability, rather than as an exact figure. Real edges drift, so practitioners size well below what it permits.

Last reviewed 11 July 2026. Educational content only — not investment advice.

Educational content only — not investment advice. See our Risk Disclosure and Methodology.