Wednesday, January 9, 2013

Algorithmic Trading System Update 1/9/2013

The holidays have made me pretty lazy. I haven't updated my trades in the tracker because I recently traded my first futures contracts. My system doesn't currently handle futures trades, so I'll have to add an enhancement before I can update it for the site.

My algo system is coming along nicely. Here's the breakdown of progress: I amaze myself in terms of how quickly that this is coming along.

Since I had a change of heart and decided to build a backtesting system, data suddenly became a problem. I've written a handy little tool which will scrape the web for some data and store it in flat files. I will likely combine this data with what I have stored in the database during live trading. Data is useless without having a framework to analyse it. I've added some code to calculate moving averages and momentum.

I think I've designed an absolutely beautiful backtesting system. I write an algorithm once, and then specify the Live Engine or the Backtesting Engine. The Live Engine will use live data while the Backtesting Engine will load data from the flat files. Both engines then send the price data through the same algorithm. This eliminates almost all implementation risk. The remaining risk lies in the differences between the engines. The Live Engine actually has to send orders to my brokerage through the API, so the code is obviously different than the Backtesting Engine.

The speed is fabulous also. I was able to run 5 years worth of SPY tick data through a toy algorithm using 8 threads in about 1 minute and 10 seconds. This particular algorithm closes out all trades at the end of day, which is why I could split it over different threads. However, it's easy to see that even if I could only use 1 thread, it wouldn't take more than 10 minutes. I've generally been hearing that it takes a couple of hours to run an algorithm on 10 years worth of tick data. I'm hoping that I can maintain something similar to the current performance even when the algorithms have some more code in it.

I've added some more necessary infrastructure to my system. Some nice things are that any errors that occur automatically get emailed to me, so that I can know to have a look. As mentioned above, I think did a incredible job with the design. This is proven by the ability to have low implementation risk and fast backtesting.

Order Entry
My system is finally connected to my brokerage account for sending orders. Currently, I'm connected to the fake money account. Since all of the interfaces are the same, it means that I only have to change the account name to have it connect to my real money account. I mentioned in a previous post that I wanted this system to require manual intervention. It looks like my brokerage and API provides this already. There is an option to only placed onto the queue in my account without actually sending it. Combined with my email alerts, this provides a perfect way for me to approve trades as the system spits them out.

To Do List
The next thing to do is the reconciliation of orders and positions. If I never turn off my system, I suppose I would never need to perform reconciliations. However, this won't be the case. So in order for this to work, I will need to make sure the outstanding orders and positions on my brokerage account match those of my algo system.

No comments:

Post a Comment