Skip to content
All library documents

Stochastic Control for Ornstein–Uhlenbeck Pairs Trading

Code Stratmill research code

Summary

This implementation describes a pairs-trading method based on modeling the log price relationship between two stocks as an Ornstein–Uhlenbeck process. It constructs the spread as the difference between the stocks’ log prices, fills missing observations forward, and estimates the model parameters by maximizing a likelihood for the joint spread and second-stock price changes. The estimated quantities include mean reversion, long-run spread mean, spread and stock volatility, drift, and correlation.

Portfolio weights are computed from a closed-form stochastic control solution associated with a Hamilton–Jacobi–Bellman equation and power utility on terminal wealth. The model also reports the spread’s mean-reversion half-life. The document presents code and its connection to a published methodology, but gives no empirical trading results or transaction-cost treatment. Its assumptions include an OU spread and fitted parameters from historical data; the implementation alone does not establish that a pair is stable or profitable out of sample.

Key ideas

  • The model represents the log-price spread of two stocks as an Ornstein–Uhlenbeck process.
  • It estimates spread and asset parameters by maximizing a joint likelihood.
  • A closed-form stochastic control solution converts the fitted model into portfolio weights under power utility.
  • The estimated mean-reversion rate is used to calculate a spread half-life.
  • The code does not provide out-of-sample results or account for transaction costs.

Tags

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.