Skip to main content
Back to Tutorial
StarterUSMean Reversion6 min readUpdated 2026-03-22

Mean Reversion on S&P 500 · the entry-level quant strategy

Short-term mean reversion with a z-score signal and a breadth-based regime gate. The cleanest first strategy for learning portfolio construction.

If you only learn one quant strategy, this should be it. The logic is transparent, the cost model matters, and the failure modes teach you why regime filters exist at all.

Fork the template to follow along:
TemplateUSMean Reversion
Mean Reversion on S&P 500

Z-score reversion on 5-day returns with breadth gate

Sharpe
1.42
Return
+16.9%
Max DD
−9.8%
Forks
86

Why this works

Equities oscillate: a name that drops -2σ in a week tends to rebound within the next five trading days, on average. The market-breadth gate is what separates a Starter tutorial from a dangerous one — without it, you buy the dips during a genuine downtrend and compound the loss. This is the canonical first strategy to learn portfolio construction and transaction cost modelling.

Common pitfalls

  1. Assuming the universe is static. S&P 500 membership changes ~20 names per year; use historical constituents.
  2. Skipping the breadth filter. On -3% days the McClellan oscillator goes sharply negative — that is when mean reversion fails, not succeeds.
  3. Modelling transaction cost at 1 bp. Realistic fill including spread + market impact on small-caps is 5–10 bp.

Try it yourself

Fork the template into your workspace. The entire configuration — code, parameters, backtest window, cost model — lands in a new private session. Tweak it, break it, and see how robust the edge actually is.

Backtest result

Sharpe
1.42
Return
+16.9%
Max drawdown
−9.8%
Win rate
+58.1%
Trades
312
Days
400

Equity curve

Strategy
Benchmark

Long names with z-score < -1.5 and positive McClellan oscillator. Hold for mean touch or 5 days. Equal-weighted basket of 30 names maximum.

Ready to learn?

Fork it into your workspace.

The whole template — code, parameters, backtest config — lands in a new private session. Tweak it, run it, break it, learn.