Sunday, March 24, 2013

Algorithmic Trading System Update 3/24/2013: Backtester Screenshot

I'm picking up more and more speed and getting closer and closer to being able to go live. I've just completed my pairs trading algorithm over the weekend and was able to backtest properly. With additional effort put into infrastructure, I was able to add a nice user interface to let me do things more easily. I have been able to cointegrate a lot of pairs without modifying any code. I will be putting a couple of pairs into my automated trading system for forward testing starting tomorrow. 

I've added a screenshot of the backtesting tool. Sorry, but I've removed the tickers that tickers that I was backtesting. The very top section is a quick way to let me enter 2 tickers and perform a cointegration. Another button lets me merge the tick data together into a single stream. Merging a couple of years of tick data takes about half an hour and a lot of disk space, so I only do this if necessary. Once the merging is completed, I click the backtest button, which will run a generic algorithm for the 2 tickers in the date range. Actually, I run the backtest 12 times with one click in multiple threads. Each backtest contains different values for the number of standard deviations of the spread before firing the spread. There is also a parameter for how many standard deviations before closing the trade, and how many days from the current day to rerun the cointegration for the new hedge ratio.

When clicking on a row in the top grid, the bottom grid will show all of the trades that were fired in the bottom grid. Opening trades have 0 pnl, and closing trades will have a non-zero pnl. The chart on the bottom right will update with the equity curve, which is the running pnl of the backtest. This allows me to quickly select the set of parameters which performed the best during the backtest. With only 3 parameters, I'd like to think that I am not overfitting.

The screenshot shows I still have a bit to do. I haven't completed the Sharpe ratio and Max Drawdown calculations, so they all show 0.

The best part is that since my backtesting code is exactly the same as the code which will fire trades during live trading, the only thing that I need to do is solidify the best performing parameters.

No comments:

Post a Comment