Level 2 · 110–120 h

Systematic strategies and rigorous backtesting

From hypothesis to honest backtest: statistics for trading, strategy families, vectorised and event-driven engines, and the validation that separates an edge from overfitting.

Fig. — Anchored and rolling walk-forward: five training and test windows (schematic)
03/08
Prerequisite
Solid pandas, OHLCV, returns and drawdown
Profile
Data analyst, technical discretionary trader

Statistics and econometrics for trading

  • 2.1.1 Hypothesis tests, p-values, bootstrap; multiple regression with robust errors (Newey-West).
  • 2.1.2 Stationarity: ADF, KPSS; differencing; fractional differencing.
  • 2.1.3 ARMA and ARIMA models; autocorrelation (ACF, PACF).
  • 2.1.4 Volatility: ARCH, GARCH, EGARCH, GJR (arch library).
  • 2.1.5 Cointegration: Engle-Granger, Johansen; mean-reversion half-life (Ornstein-Uhlenbeck).
  • 2.1.6 Kalman filter for dynamic hedge ratios.
  • 2.1.7 Regime detection: hidden Markov models (HMM), structural breaks.
  • 2.1.8 The multiple testing problem: Bonferroni, FDR, “factor zoo”.

Anatomy of a trading system

  • 2.2.1 The edge hypothesis: where it can come from (risk, behaviour, structure, information).
  • 2.2.2 Universe, signal, filter, entry, exit, sizing, risk management.
  • 2.2.3 Frequencies: intraday, swing, position; strategy capacity.
  • 2.2.4 Research journal and experiment log, to keep data snooping under control.

Strategy families

  • 2.3.1 Trend following (crossovers, Donchian and Turtle breakouts, time series momentum) and cross-sectional momentum or sector rotation.
  • 2.3.2 Mean reversion: RSI and Bollinger, intraday reversion, gaps.
  • 2.3.3 Pairs trading and statistical arbitrage: pair selection, distance, cointegration, Kalman.
  • 2.3.4 Carry (FX, roll yield in futures, bonds), seasonality and calendar effects.
  • 2.3.5 Factors (value, quality, low volatility, size; long-short) and event strategies (earnings, dividends, index rebalances).
  • 2.3.6 Introduction to market making: inventory, spread, adverse selection (Avellaneda-Stoikov model).
  • 2.3.7 Crypto-specific strategies (introduction): crypto momentum, funding and basis arbitrage (covered in detail in level 3).

Backtesting: engines and paradigms

  • 2.4.1 Vectorised backtest with pandas and NumPy from scratch, and its limits.
  • 2.4.2 Event-driven backtest from scratch: loop, portfolio, orders, fills.
  • 2.4.3 vectorbt: massive parameter sweeps, portfolio simulation.
  • 2.4.4 backtesting.py and backtrader (teaching tools; maintenance status).
  • 2.4.5 NautilusTrader: architecture (Rust and Python), data, strategies, the same code in backtest and live.
  • 2.4.6 LEAN/QuantConnect and Zipline-reloaded; bt for asset allocation.
  • 2.4.7 Cost modelling: broker commissions, spread, slippage, impact, financing, securities lending.
  • 2.4.8 Fill modelling: limit orders, queue, partial fills, gaps, stops.

Biases and validation

  • 2.5.1 Look-ahead, survivorship, selection, data snooping, narrative bias.
  • 2.5.2 In-sample and out-of-sample; anchored and rolling walk-forward.
  • 2.5.3 Combinatorial purged cross-validation (CPCV) for strategies.
  • 2.5.4 Deflated Sharpe Ratio and Probability of Backtest Overfitting (PBO).
  • 2.5.5 Monte Carlo: trade resampling, block bootstrap, signal permutations.
  • 2.5.6 Parameter sensitivity analysis (plateaus versus peaks); robustness across assets and periods.
  • 2.5.7 Synthetic data (GBM, GARCH, bootstrapping) for stress tests.
  • 2.5.8 “Honest backtest” checklist before moving to paper trading.

Performance metrics

  • 2.6.1 CAGR, volatility, Sharpe, Sortino, Calmar, Omega; maximum drawdown, duration, Ulcer Index.
  • 2.6.2 Win rate, payoff, expectancy, profit factor; alpha and beta, information ratio, turnover and capacity.
  • 2.6.3 Reports with QuantStats or pyfolio-reloaded; custom tearsheets.

Research on this site to practise this level

Practice

  1. Your first system in Python: moving-average crossover on SPYResearch-0018 · 7 min
  2. Zipline in Python - Part 1: Quant Stack and PipelineResearch-0011 · 11 min
  3. Zipline, Backtesting in Python 2: My First Data AnalysisResearch-0012 · 3 min
  4. Seasonality in Python II - BacktestingResearch-0025 · 8 min
  5. Intraday Seasonality IV - Field SearchResearch-0027 · 7 min
  6. Alpha Factors and Alpha Trading in PythonResearch-0007 · 5 min