Appendix: Cross-Cutting Reference
The stuff that silently corrupts backtests if you get it wrong: annualization, return math, performance metrics, and the standard list of biases.
Annualization Factors
Multiply (or scale √ for volatility) by the periods-per-year for your bar frequency.
| Bar frequency | Periods/year (returns) | Vol scaler (√periods) |
|---|---|---|
| Daily (equities/futures) | 252 | √252 ≈ 15.87 |
| Daily (crypto, 24/7) | 365 | √365 ≈ 19.10 |
| Weekly | 52 | √52 ≈ 7.21 |
| Monthly | 12 | √12 ≈ 3.46 |
| Hourly (crypto 24/7) | 8,760 | √8760 ≈ 93.6 |
Rules.
- Returns scale linearly; volatility scales with √time. .
- (geometric) — not simple multiplication for compounded series.
- Match the factor to the data: annualizing daily-crypto vol with √252 understates it.
Return & Growth Math
Simple vs Log Returns
- Simple: . Aggregates across assets (portfolio return = weighted sum).
- Log: . Aggregates across time (sum of log returns = total log return). Symmetric, better for stats/vol.
- Algo: Use log returns for time-series modeling & vol; convert to simple for portfolio aggregation. Never mix.
CAGR
. Smooths the path — hides drawdowns and volatility.
Compounding
, continuous: .
Performance & Risk Metrics
Sharpe Ratio
Def. Excess return per unit of total volatility. Formula. , then to annualize. Algo. Use excess returns (subtract risk-free). Sensitive to non-normal returns; high Sharpe on short samples is often overfit.
Sortino Ratio
Def. Like Sharpe but penalizes only downside volatility. Formula. , where uses only returns below target (usually 0). Algo. Fairer for asymmetric/positively-skewed strategies; report alongside Sharpe.
Max Drawdown (MDD)
Def. Largest peak-to-trough equity decline. Formula. . Algo. The number that determines if you can survive the strategy psychologically & financially. Track duration of drawdown too.
Calmar Ratio
Def. Return relative to max drawdown. Formula. . Algo. Good single number for trend/futures strategies where drawdown is the binding risk.
Volatility (realized)
, annualized via . Use sample std (ddof=1) for estimates; be explicit about ddof to match libraries.
Beta
Def. Sensitivity of an asset's returns to the market. Formula. . Algo. Estimate over a rolling window; β is unstable across regimes.
Value at Risk (VaR) / CVaR
Def. VaR = loss not exceeded with confidence X over horizon; CVaR = average loss beyond VaR. Formula. Historical: the Xth percentile of the return distribution. CVaR = mean of the tail beyond it. Algo. VaR ignores tail shape; CVaR (expected shortfall) is the coherent risk measure — prefer it for sizing.
Win Rate vs Expectancy
Def. Win rate alone is meaningless without payoff size. Formula. . Algo. A 40%-win strategy with 3:1 winners beats a 70%-win strategy with 1:3 winners. Optimize expectancy, not win rate.
Position Sizing
Kelly Criterion
Def. Growth-optimal bet fraction. Formula. , where b = win/loss payoff ratio, p = win prob, q = 1−p. For continuous: . Algo. Full Kelly is too aggressive (estimation error → ruin); use fractional Kelly (¼–½). Overestimating edge is catastrophic.
Volatility Targeting
Def. Scale position so portfolio hits a target volatility. Formula. . Algo. Standard in CTA/managed futures; rebalance on a schedule, use lagged vol to avoid lookahead.
ATR-based Sizing
Def. Size by the asset's recent range so each trade risks a fixed $ amount. Formula. , stop_distance often . Algo. Normalizes risk across instruments of different volatility/price.
Backtesting Biases (the canonical failure list)
| Bias | What it is | Guard |
|---|---|---|
| Lookahead | Using info not available at decision time (today's close, restated fundamentals, future bars) | Shift signals by ≥1 bar; use point-in-time data |
| Survivorship | Universe excludes dead/delisted names → inflated returns | Use a delisting-inclusive universe |
| Overfitting | Tuning params to past noise | Out-of-sample/walk-forward test; minimize free params; deflated Sharpe |
| Data snooping | Testing many strategies, reporting the winner | Adjust for multiple testing; hold out a final test set |
| Survivorship in data | Index reconstitution, currency redenominations | Use vintage index membership |
| Transaction costs | Ignoring commission, spread, slippage, market impact | Model realistic per-trade costs; stress-test 2–3× |
| Liquidity | Assuming you can fill at the quoted price/size | Cap participation; model partial fills |
| Restatement/revision | Fundamentals & macro get revised | First-print / as-reported (vintage) data |
| Time-zone / timestamp | Mismatched bar timestamps across sources | Normalize to one TZ; verify open/close alignment |
Slippage & Cost Model (minimum viable)
The fill price crosses the spread and adds impact/latency slippage; the total cost then sums commission, that slippage, and any borrow/funding on shorts/perps.
- Rule of thumb: if a strategy only works with zero costs, it doesn't work. Always include a cost model before trusting a backtest.
- Crypto perps: add funding cash flows per interval. Futures: add roll costs. Options: per-leg spread + commission.
Data Hygiene Checklist (before any backtest)
- Prices split/dividend adjusted (equities) — or you'll trade phantom gaps.
- Continuous futures: know the stitch method; recompute returns per contract if unsure.
- Fundamentals/macro keyed to release date, not period date.
- Timestamps in a single, explicit timezone.
- NaN/warm-up windows dropped, not forward-filled into signals.
- Annualization factor matches bar frequency (252 vs 365 vs intraday).
- Signals shifted ≥1 bar (no same-bar lookahead).
- Costs, slippage, and (where relevant) funding/borrow modeled.
- Out-of-sample period reserved and untouched until the end.