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


  1. 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.

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

  3. 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?

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

  2. 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

  • $\begingroup$ A slightly different angle but have you considered looking at lagged cointegration. If you believe that the series are related in some way does one cause the other. Can you receive a signal from a movement in one of the series. $\endgroup$
    – user22485
    Commented Dec 5, 2018 at 9:59
  • $\begingroup$ Note that $e$ will not have mean 0 in OLS regression that does not include a constant. $\endgroup$
    – Drew
    Commented Feb 2, 2019 at 1:50

2 Answers 2


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.


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:

  1. Calculate the difference $Pa-(\gamma \cdot Pb)$ at every time period on the test/simulation data
  2. 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$.

  • $\begingroup$ Kinda confused...To trade the spread I should test the cointegration as Y^ = γ⋅Pb + e? And for the ratio? $\endgroup$
    – TomDecimus
    Commented Feb 1, 2019 at 12:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.