I have recently had much fun with “Simple Trading Systems using Simple Python Code”.
I have back tested and traded relatively simple systems using daily data for almost 20 years now. For many years I relied on two excellent but ultimately limiting commercially available packages: Trading Blox and Mechanica.
I then branched out into using Python since I got fed up paying licence fees and being limited by other people’s architecture. I have no back ground in coding but I have been engaged in financial markets for 40 years – my entire career. Much of that trading my own book.
For many years I traded futures using various trend following methods but for whatever reason that is no longer producing the over-sized profits it once did.
I therefore turned to looking at whatever caught my fancy and using simply Python code in Jupyter Notebooks, I set out to test various ideas out on historical data.
I recently came across a very simple version of a mean reversion system on Quantopian which was designed simply to illustrate the dangers of over fitting.
I was much taken by the simplicity of the code and decided to play about with it. The results you will find on my gist:
Currently there is no fixed fractional position sizing and investment is made using single shares in the relevant stock and (optionally) pyramiding the position.
There is currently no provision made for slippage or commission.
Both of the “disadvantages” are easily rectified and I shall probably post updates at some stage.