I've been trying to wrap my head around cointegration. Currently I use the log returns of both stocks A and B, calculate the spread given by:

$S = log(A) - n*log(B)$ where $n$ is the Hedge Ratio calculated from a rolling OLS. In the results I've read I've operated under the assumption that if the spread falls below a certain point then long A and short B and vice versa. I believe this is a dollar neutral hedge?

My confusion lies in the Hedge ratio part whereby I'm not sure how to interpret it. I've seen an example that says long A and short $n$ stocks of B. However, I sometimes get negative values of $n$, i.e log returns are inversely correlated. How do I interpret this?

  • $\begingroup$ A negative $n$ would mean that the stocks are diverging. In that case you don't want to pair trade them. $\endgroup$
    – nbbo2
    May 8, 2021 at 19:52
  • 5
    $\begingroup$ @noob2 I don't think so. It just means you want to short negative amount of stock = going long both A and B. This is common with say inverse ETFs, but could be a sign of unstable regression coefficients for the ordinary stocks. $\endgroup$
    – LazyCat
    May 12, 2021 at 13:10

1 Answer 1


Did you check for cointegration b/w A and B before running the regression? You should not get a negative hedge ratio for 2 assets that are deemed to be co-integrated with a sufficient confidence level.

If they are infact cointegrated, try increasing the look back period for calculation of rolling hedge ratio from OLS, might be the case that beta is negative for a certain small time period.

  • $\begingroup$ I did check for cointegration yes. Good idea, I didn't think of upping the look back period. What do you think is a reasonable time? I'm currently using hourly ohclv data with a window of 100hrs. Suppose I should probably backtest for the optimal value but I don't want to overfit $\endgroup$ May 12, 2021 at 9:26
  • $\begingroup$ What timeframe did you check cointegration for? If you are working with hourly data it is definitely possible to get false positive cointegration results $\endgroup$ May 12, 2021 at 10:53
  • $\begingroup$ A range, a year once and 2 weeks another time $\endgroup$ May 12, 2021 at 11:28

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.