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.
Z-score reversion on 5-day returns with breadth gate
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
- Assuming the universe is static. S&P 500 membership changes ~20 names per year; use historical constituents.
- Skipping the breadth filter. On -3% days the McClellan oscillator goes sharply negative — that is when mean reversion fails, not succeeds.
- 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
Equity curve
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.
Related tutorials
What is mean reversion, and when does it stop working?
From the textbook z-score to gamma-driven intraday fades, a tour of when price snaps back — and when it does not.
How to read a backtest report without fooling yourself
A checklist for evaluating any strategy you did not write yourself. Required reading before forking.
SPY GEX Fade · trading options microstructure
An intraday fade strategy built on dealer gamma exposure, executed with a 3-minute trigger. Teaches why positioning data beats price data.
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.