Just put effort on pairs trading for a while and implemented an algo with cointegration and ECM. I have learned a lot from it while some basic ideas still puzzles me, sharing my work here, hope someone can give me a light. Found a good topic by Delaney herehow-to-build-a-pairs-trading-strategy-on-quantopian and I found some details is quite different from my understanding.
- For hedge_ratio, I am using ECM to simulate instead of using OLS directly. I found ECM hedge_ratio has less variance, but the ECM maybe not exist sometimes because hedge_ratio can be negtive value or ECM donot pass T-test. My solution is to avoid trading during this period as it happens rarely. [Still wondering which hedge_ratio is better by theory?]
- For Zscore, there is a subtle difference, I am using a static hedge ratio to calculate the spread in the moving window, While Delaney is using dynamic hedge ratio and saved historical spreads. I have compared the 2 kinds of Zscores and seems they are relavant, and I still prefer my Zscore because it looks more reliable in a long run
- As known, the hedge_ratio and spread mean/std is gonna be different after invested a pair. And we are re-calculating the Zscore after that, so there could be risk for a invested pair because the model is changed. I am thinking if we should lock the hedge_ratio and spread mean/std when investing a pair, and use the same param to calc Zscore for the same pair until exiting the positions
- For ECM and Zscore, it is better to use log(Price), while the real Price is positioned.this will introduce errors in the calculation of real return,I just noticed it but not sure how much it impact,
- To select suitable pairs, I am making a bundle of indicators to help. but it turns out not a very good idea because it is hard to choose from multiple indicators, is there good approach to select some good pairs?
Thanks in advance for reading and giving comments on the tedious notes