For a pairs trade, when calculating the zscore should I include the intercept point in the calculation:

spread = price2 - (gradient * price1) - intercept
zscore = (spread - average)/standard_deviation

or should I exclude the intercept:

spread = price2 - (gradient * price1)
zscore = (spread - average)/standard_deviation

I then check the zscore and trade accordingly:

if zscore > 2.5:
  sell qty2
  buy qty2
elif zscore < -2.5:
  buy qty2
  sell qty1

Also, should the spread calculation include the gradient:

spread = price2 - (gradient * price1)


spread = price2 - price1


  • $\begingroup$ No it does not. This is a different but related question. Thanks $\endgroup$ Commented Jan 9, 2023 at 14:54
  • 2
    $\begingroup$ It shouldn't make a difference whether you include the intercept or not. When you calculate the Z-score you are subtracting the mean as your first step. If you "forgot" to subtract intercept in your definition of spread then it will be removed when subtract mean. You should be able verify this by running the calculation both ways and seeing that the answer is the same $\endgroup$ Commented Jan 9, 2023 at 19:28
  • $\begingroup$ Thanks Jamie for the answer I needed. $\endgroup$ Commented Jan 10, 2023 at 0:08


Browse other questions tagged or ask your own question.