Wednesday, 30 September 2015

Python code for the two trading rules in "Systematic Trading"

This is a brief post aimed at those who have already bought a copy of "Systematic Trading" (by the way thanks!)

As you've probably noticed I've included excel sheets here explaining the two trading rules I describe in the book - exponentially weighted moving average crossover ("EWMAC") and Carry ("Carry").

Since I also have the python code for these rules, I thought I might as well share it. You can find it here:

https://github.com/robcarver17/systematictradingexamples/blob/master/ewmac.py

and

https://github.com/robcarver17/systematictradingexamples/blob/master/carry.py

I've added these links to the 'info' page on the book's website.

If there is any other code you'd like to see let me know. I've already been asked about bootstrapping, so don't worry, that is coming.

3 comments:

  1. Very inspirational! Congrats on the book, I just bought the kindle-version.
    You might receive some questions from me in the near future....
    All the best,
    --S

    ReplyDelete
  2. Hi,

    Nice blog. Just a Quick one.
    What's your trading frequency?
    And when/how do you decide how/when to close your position?

    ReplyDelete
    Replies
    1. My average holding period is a few weeks. I don't 'close' positions, instead I have a continous forecast of what the optimal position should be; I then trade if that changes.

      Delete