1
$\begingroup$

I'm trying to define and track the spread between two time series (data available here), for the purpose of learning pair trading basics.

When running a cointegration test the two series seem to be cointegrated (using python's statsmodels.tsa.stattools.coint the results are (-3.3744261541141616, 0.04527140003070947, array([-3.98694225, -3.38584874, -3.07883012])), and when generating a scatter plot the relation looks linear without much noise.

enter image description here

Most posts I've read recommend computing the spread by regressing one time series on the other (for an initial 'train' time window) and then extracting the coefficient and using it to subtract between the two (after multiplying one of them by it).

When I do that the results of the OLS are rsquared=0.88 coeff=2.554344 (using python's statsmodels.api.OLS) but the spread on the time period that's outside of the one the OLS was computed on drifts apart without converging back. On the other hand when I subtract the two time series (beyond the initial period used to compute the OLS) the difference seems to be bounded narrowly. See following plot (Blue line is the OLS spread, Orange line is simple subtraction)

enter image description here

My question is - given that the simple subtraction yields a pretty consistent spread (in and out of sample), why isn't the in-sample regression able to extrapolate well on out of sample data?

$\endgroup$
1
$\begingroup$

If my understanding is correct, then you are asking why in-sample coefficient is not working for out-of-sample data.

  1. It is hard to tell whether two stocks are co-integrating without specific reason.

  2. Although Stock A and Stock B are co-integrating with some coefficient, if you took regression on some particular time period, you might get some different coefficient. This is because regression always tries to find of the best fit.

  3. Possibly, there may be some events announced that change co-integrating relation.

$\endgroup$
2
  • $\begingroup$ Thanks for answering! it helped me clarify what I'm trying to ask - given that a simple subtraction yields a pretty consistent spread (in and out sample), wouldn't you expect an in-sample regression to be able to extrapolate well on out-sample data? $\endgroup$
    – oshi2016
    Jul 5 '20 at 14:41
  • 2
    $\begingroup$ @oshi2016 Assume that two stocks are co-integrating, that depends on how much difference and time period you accept. The orange line in your plot seems co-integrating and stable, but if you took smaller sample for example Jan 19 to May 19 you would not see this relation anymore. Also, price of stock B in your data was about 3 times lower than stock A in 2016 but this ratio changes to around 1.5 in 2018 and almost one to one relation since 2019. This would make StockA - StockB look more stable than your regression result. $\endgroup$
    – spar7453
    Jul 5 '20 at 15:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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