Skip to content
All library documents

Cointegration Residuals and Ratio Pair Trading

Article Quant Q&A · Author: TomDecimus

Summary

The document discusses how to turn an Engle–Granger cointegration test into a pairs trade. It estimates a hedge ratio by regressing one asset’s price on the other without an intercept, forms the residual spread as the first price minus the hedge-ratio-weighted second price, and applies an Augmented Dickey–Fuller test to that spread. It emphasizes that the traded spread must match the series used in the test: a price difference model calls for trading the price difference, while a log-based model describes a different relationship.

One proposed entry method uses Bollinger bands on the residual spread, selling above the upper band and buying below the lower band. The example scales paired positions as the spread moves farther beyond successive bands. The discussion provides conceptual guidance rather than empirical results or a complete trading specification. It does not address transaction costs, parameter stability, stationarity test assumptions, or risk controls, and it leaves sizing and execution details unresolved.

Key ideas

  • The hedge ratio comes from regressing one asset price on the other.
  • The residual spread is the first price minus the hedge-ratio-weighted second price.
  • Test the same spread definition that the trading rule will use.
  • A proposed mean-reversion rule enters paired positions when the residual crosses Bollinger bands.

Tags

Full text
# Cointegration and Ratio Pair Trading


# Cointegration and Ratio Pair Trading












I'm having some confusion doing Engle-Granger Cointegration test and then trade the ratio.

Methodology:

- Run an OLS fit for A and B price time series without a constant. Therefore, $\hat{Y} = \gamma \cdot P_b + e$ where $\hat{Y}$ is the estimated stock A price and $P_b$ the price of stock B. The coefficient $\gamma$ would be the hedge ratio. Note that $e$ should have mean of 0 as white noise.

- Get the residuals $S_t$ which is $Y - \hat{Y} = P_a - \gamma \cdot P_b = S_t $

- Run ADF test over the $S_t$ series to determine if series are cointegrated.

If they are in fact cointegrated, how should the trades be made?

- Compute the real ratio between the stock A and B prices $P_a/P_b$

- Go long $1 \cdot A$ and short $\gamma \cdot B$? And viceversa if the signal is go short.

If I want to trade the spread, should I model the OLS as $ln(A) = -\gamma\cdot ln(B) + e $ ?

Thanks guys

## Answer by numerairX (score 1)

https://quant.stackexchange.com/a/42922

> If I want to trade the spread, should I model the OLS as $ln(A)=−γ⋅ln(B)+ \epsilon$?

It depends on how you define your spread. If you used log return as spread then use log return in OLS also. If you use price diff as spread then use price in OLS.

## Answer by Varun (score 1)

https://quant.stackexchange.com/a/43836

No. In the above equation, you mentioned the spread as the ratio of prices and not of log prices. Also, you verified the spread's cointegration using $A - \gamma \cdot B$ and not $A/B$ as the input for the ADF test, so you cannot use $ln(A)-ln(B)$. If you do this, it means you want to check the spread $Pa/Pb$ for cointegration.

So, if you want to trade the spread do this:

- Calculate the difference $Pa-(\gamma \cdot Pb)$ at every time period on the test/simulation data

- Whenever the spread exceeds the upper or lower Bollinger band you sell or buy the spread respectively.

And you stack your buy and sell orders arithmetically. Meaning you buy 1 lot on $A$ and sell $\gamma$ on $B$ when the spread crosses first standard deviation. When it crosses second standard deviation you buy 2 lots on $A$ and sell $2\cdot \gamma$ on $B$.

Shown in full with attribution under the source's licence. Licence: CC BY-SA 4.0 (Stack Exchange)

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