Learn / Track V / lesson 2 of 5
Mean reversion and the Ornstein–Uhlenbeck process
Betting that stretched prices snap back — the model, the z-score trade, and the risk that "cheap" gets cheaper.
Mean reversion is the opposite bet to momentum: when something has moved far from “normal”, expect it to come back. It works on the right objects — spreads, ratios, short-horizon returns — and fails dangerously on the wrong ones.
The Ornstein–Uhlenbeck process
The continuous-time model of a mean-reverting quantity is
- is the long-run mean the process is pulled towards,
- is the speed of reversion,
- is the noise.
The further is from , the stronger the pull. Its stationary distribution is normal with variance , and the half-life of a deviation is
In discrete time this is the AR(1) process from stationarity, with . You estimate by regressing on .
The z-score trade
Standardise the deviation:
using a rolling mean and standard deviation. A classic rule: short when , long when , exit when crosses 0. Bollinger Bands are this exact rule applied to price, and RSI-oversold entries are a cousin of it — which is why they dominate the mean-reversion section of the vault.
A rolling window much shorter than the half-life chases noise; much longer, and the mean it uses is stale. Estimating the half-life first and setting the window around it is one of the simplest ways to make a mean-reversion system less arbitrary.
Where mean reversion is real
- Spreads between related assets — the basis of pairs trading.
- Very short horizons — bid–ask bounce and liquidity provision create reversal over minutes to a day.
- Volatility itself — implied volatility reverts much more reliably than price.
- Funding rates and basis in crypto perpetuals, pulled back by arbitrageurs (see carry).
Single asset prices over medium horizons are mostly not mean-reverting; they behave closer to random walks with momentum.
The risks
Mean reversion has the negative skew that momentum avoids: many small wins and occasional large losses, when a “deviation” turns out to be a regime change. The spread that was 2σ cheap becomes 5σ cheap because one company is going bankrupt, or a stablecoin is losing its peg.
- A stop in z-score or price, even though it fights the logic of the trade.
- A time stop: if the trade hasn’t reverted within two or three half-lives, the model is probably wrong.
- A regime filter: stand aside when volatility spikes or the relationship’s stationarity test fails.
- Never average down without a hard limit. That is how mean reversion becomes martingale.
Put it to work
Build this idea
A spec is not a trading system. Paste this into your coding agent and AgenKit runs a specialist team — architecture, test-first build, risk gates, review — with paper trading on by default.
/agenkit build a mean-reversion bot that trades a z-score of price versus its rolling mean, with half-life estimation, a time stop, a volatility circuit-breaker, and paper trading by default- npx agenkit install engineering-kit in your project
- Paste the command into your agent and approve each phase
- Get tests, backtest, risk controls and a paper-trading switch