The Claude Quant PlaybookDownload ebookDownload ebook

Mean-reversion half-life

advancedTime series5 of 8

In an Ornstein–Uhlenbeck process the expected gap from the mean shrinks exponentially. The half-life says how long you should expect to wait for half of it to close.

Build a trading system with Claude.Download ebook

01The formula

the value of the spread at time t
the long-run mean the spread is pulled back to
the speed of reversion per day
the size of the daily random noise
Brownian motion: the random part
the half-life: the time for the expected gap to halve

02See it move

03Where it is used

04Why traders use it

A spread that reverts is only tradable if it reverts fast enough. The half-life turns the abstract speed κ into a number of days you can plan around.

05Worked example

With κ = 0.100 per day, the half-life is 6.9 days. A gap of 3.0 is expected to shrink to 1.50 after one half-life; the simulated paths averaged 1.56 on that day. In discrete daily steps this is an AR(1) with φ = 0.9048.

06How it is built

  1. Ignore the noise for the average: .
  2. Solve the equation: .
  3. Set the gap to half its starting value: , so .
  4. Sampled once a day the process is an AR(1) with , so you can estimate from a regression of today's spread on yesterday's.

07The common mistake

Expecting each trade to close in one half-life. It is the time for the average gap to halve; with noise, individual paths often overshoot or take several half-lives.

08In Python and LaTeX

import numpy as np
kappa = 0.1
print(round(np.log(2) / kappa, 2), round(np.exp(-kappa), 4))  # 6.93 days, phi 0.9048
dX_t = -\kappa\,(X_t - \mu)\,dt + \sigma\,dW_t \;\Rightarrow\; E[X_t] - \mu = (X_0 - \mu)\,e^{-\kappa t}, \qquad t_{1/2} = \frac{\ln 2}{\kappa}

09Where it fits

Rather not code the maths yourself? Describe your trading idea and let AI build the bot.

Build a bot with AgenKit

The worked example and the model run the same code, so every number matches. Models simplify markets on purpose. This is education, not financial advice.