Skip to content

bartchr808/Quantopian_Pairs_Trader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 

Repository files navigation

Quantopian_Pairs_Trader

Read my Medimum article about this project here!

This is my implementation of a Pairs Trading Algorithm on the algorithmic trading research/competition platform Quantopian so I can dive deeper and learn more about Pairs Trading and implementing trading algorithms. Some tests/measures I'm currently learning about and using include:

Current Results

Currently, my implementation will be able to run on arbitrary amount of possible pairs that a user could provide. However, for current testing purposes, I have only been testing on two possible pairs (and hardcoded some logic that assumes that such as how I record values on the graph). Those two pairs are Microsoft (MSFT) + Apple (AAPL), and McDonalds (MCD) + Yum! Brands (YUM) which owns chains like KFC, Pizza Hut, and Taco Bell. The former can be seen in the lower graph with the label "_tech" and the latter with the label "_food" with corresponding Z and hedge ratio values.

Current Results Graph

I had my algorithm run for 13 years from January 1, 2004 to January 1, 2017. However, I'm planning on seeing how extensible my algorithm is to different time periods and different combination of pairs. From the few tests I have done so far, this seems true and I haven't "overfitted" my algorithm by making it only work in a specific instance.

Issues/Next Steps

  • Reduce the drawdown and beta and get the leveraging under control.
  • Quantopian has deprecated version of Statsmodels python library which doesn't have the KPSS test available. I'll need to manually add it myself.
  • Look into cleaning up how I'm currently returning a completely new pair object in process_pair and replacing the old pair in the for-loop in my_handle_data.
  • Haven't looked at using Kalman filters for determining hedge ratios. Not sure if I need to or if the way I did it sufficient.
  • Need to look into how Quantopian's order_target_percent function works when I have several different pairs and not one or two (e.g. will the first opening order take up my entire portfolio?) .

About

Quantopian Pairs Trading algorithm implementation.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages