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