I cloned Fawce's stat arb algorithm and tried to improve it some. This is still work in progress as you can see but I thought I post the code and see if other people might want to help out getting it to work.
What did I change from the original?
- added intercept to the estimation (sm.add_constant)
- adfuller test whether the residuals are stationary (implies cointegration) (commented out)
- ARMA model fit that might be able to predict which direction the spread is moving (commented out)
The reason the last two are commented out is that they seem to take too long to compute and the backtest time-out kicks in to cancel the backtest.
The results are not very promising so far, high volatility but I'm sure this can be leveraged.