Following the great post and resources by Dr. Aidan O'Mahony here & the Quantopian Lecture here, I have become very interested in experimenting using a Kalman Filter in my pairs trading. I've been working off these notes and have attempted to start with a smaller set of data, and then update the filter as I go using the .filter_update() method in the pykalman KalmanFilter. To sanity check that I'm doing this correctly, I have been comparing the data to the original data provided in the notebook by Dr. O'Mahony.
I clearly am doing something wrong in the iterative step of updating the filter as the Intercept is not updating correctly. I end up with an intercept that is exactly the slope (clearly wrong). In good news though, it looks like the slope is updating correctly when comparing it to the unaltered notebook. My next_means and next_covs matrices all come out with the same values for each element:
next_means -> [ 0.69888608 0.69888608]
next_covs -> [[ 0.00125334 0.00125334]
[ 0.00125334 0.00125334]]
This is probably a stupid mistake I'm making, I just can't spot it. Any help would be greatly appreciated!
*This notebook was cloned from the 'QuantCon 2016: Using the Kalman Filter in Algorithmic Trading', all credit to Dr. Aidan O'Mahony.