1. “It reverts” is only half the picture
A mean-reverting spread that snaps back in an hour and one that takes three weeks are completely different trades, even if their charts look identical at a glance. One sets a holding period you can trade around the same session; the other ties up capital and margin for a month and quietly changes your Sharpe, your stop, and your capacity. So the useful description of a reverting series is not the binary “it mean-reverts” — it is a speed and a timescale, plus a read on where the spread stands relative to its own mean this instant.
That is exactly what these three numbers give you: the mean-reversion speed, the half-life, and the z-score. Note they operate on a level series — a price spread, a pair residual, a basis — not on a return series like most of our volatility tooling.
2. The Ornstein–Uhlenbeck clock
Model the spread as a discrete Ornstein–Uhlenbeck process — the continuous-time mean-reverting process of Uhlenbeck and Ornstein (1930), and the workhorse of the pairs-trading literature. In discrete steps it is simply an AR(1) written around a long-run mean μ:
yₜ − yₜ₋₁ = κ · (μ − yₜ₋₁) + εₜ
The single parameter κ is the speed of mean reversion per step: the strength of the pull back toward μ. A large κ yanks the spread home quickly; a small one lets it wander. When κ is zero the pull vanishes and the series is a random walk; when it is negative the “pull” is actually a push and the series trends or diverges. Everything a trader wants to know about the timescale is encoded in that one number.
3. Half-life: the number you actually trade on
Speed in “per-step” units is hard to feel. The intuitive form is the half-life — the number of bars a deviation from the mean takes to decay halfway back:
half-life = ln 2 / κ
This is the practitioner's timescale (popularised for pairs trading by, among others, Ernest Chan). A half-life of three bars is a fast, high-turnover mean-reverting trade; a half-life of forty bars is a slow, patient one. It directly sizes decisions the strategy has to make anyway: how long to hold, how wide to set a time-based stop, how to scale the position so the expected reversion outruns costs. If κ ≤ 0 the series does not revert at all and the half-life is infinite — a clean, honest answer rather than a misleading finite number.
4. Measuring the speed with one regression
Estimating κ takes a single ordinary least-squares regression — no optimiser, no library of distributions. Regress the one-step change in the spread, Δyₜ = yₜ − yₜ₋₁, on its own lagged level, yₜ₋₁. The slope of that line is −κ:
Δyₜ = a + b · yₜ₋₁ + εₜ → κ = −b
The logic is direct: if the spread is high, a mean-reverting series tends to fall next (a negative change), so higher levels line up with more negative changes — a negative slope b, and hence a positive speed κ = −b. A flat slope means no reversion; a positive slope means the deviations feed on themselves. It is the same estimator that underlies the augmented Dickey–Fuller stationarity test, stripped down to the one coefficient a trader needs.
5. The z-score: when to pull the trigger
Speed and half-life tell you whether the spread is worth trading and for how long. They do not tell you to act now. That is the job of the z-score — the latest observation expressed as a number of standard deviations from the mean:
z = (yₜ − mean) / σ
This is the “s-score” at the heart of Avellaneda and Lee's Statistical Arbitrage in the U.S. Equities Market (2010): fade the extremes — go short the spread when z is strongly positive, long when it is strongly negative — and unwind as it decays back toward zero. The division of labour is clean: the z-score says when to enter and exit, while the half-life says how long the round trip should take and therefore how patient (or how alarmed) to be if the spread refuses to come back.
6. When the half-life blows out
The half-life is also a risk sensor. A pair whose historical half-life was five bars but is now estimating out to fifty is telling you the relationship is decaying — the cointegration is breaking — before the P&L makes it obvious. Watching the estimate drift is a far earlier warning than waiting for a stop to trip. Mean reversion, in other words, is not just an entry rule; it is a live diagnostic on whether the trade still exists.
These metrics sit alongside the regime tools we have written about before. The Hurst exponent and the variance ratio classify a series as trending, random-walk, or mean-reverting; the half-life and z-score go further and quantify how fast it reverts and how far it is from home right now. Read together they turn a vague “this looks mean-reverting” into a specific, tradable description — the raw material of the statistical-arbitrage playbook.
7. Computing it
Our open-source orderflow-metrics library ships all three, dependency-free, in TypeScript and Python:
import {
meanReversionSpeed,
halfLife,
zScore,
} from "orderflow-metrics";
// a spread pulled back toward its mean, sampled bar by bar
const spread = [3.0, 2.4, 2.0, 1.5, 1.3, 1.0, 0.7, 0.6, 0.4, 0.3];
meanReversionSpeed(spread); // 0.1785 — OU speed κ per bar (>0 = mean-reverting)
halfLife(spread); // 3.88 — bars to decay halfway back to the mean
zScore(spread); // -1.19 — latest point, in std-devs from the mean
// a trending series never reverts
halfLife([1, 2, 3, 4, 5]); // Infinity
The Python distribution exposes the same functions (mean_reversion_speed, half_life, z_score). They live beside the Hurst and variance-ratio regime diagnostics inside the wider market-microstructure toolkit we build in the open — install it from our open-source page (npm and PyPI, MIT-licensed).
8. Conclusion
A spread that reverts is only a trade once you have put numbers on it. The Ornstein–Uhlenbeck speed says how hard it is pulled home; the half-life turns that into a horizon you can size a position and a stop around; the z-score says how far from home it stands this instant, and therefore whether to act. Three numbers, one linear regression, one level series — and a mean-reverting chart becomes an entry, an exit, a holding period, and an early warning when the relationship starts to fail. Explore the rest of the toolkit in our quantitative research library, or read the implementation in our open-source metrics.