Thursday, January 2, 2014

2013 Year End Algorithmic Trading System Performance Update

No matter how much code I write, there never seems to be an end to the list of things that keep coming up. Up until last week, I had no way to figure out my exact profits for my live trading. I had vague ideas based on looking at the trades that have been closed out, plus the unrealized profits of the existing positions. This number was precisely wrong because it does not include the dividends are paid out on my long positions and charged against me on my short positions. Trying to be as efficient as possible, I tried my best to reuse the same code which generates the equity curves from my backtests. My backtests don't have problems with dividends because I use split and dividend adjusted prices. Modifying the algorithm to handle dividends during the course of live trading was no easy task. After many hours of coding and tedious unit tests, I think it's finally done.

Live Trading Equity Curve for 2013

Alongside of just profits, I wanted to visualize how much activity was going on with all of the pairs. I wanted to see how many positions were opened at any given time. The below graphs are what I have finalized. The first chart is my equity curve for my live trading this year. Yes, that $8145 is in dollars of profit for December 31st 2013. It includes the effects of the inflows and outflows of dividends. The win percentage of 46.5% is a little worrying to me as it doesn't look right. I'll have to look into that. The pnl does look close enough to correct when compared to my hand calculations. There are two things which are not included in this equity curve, and I do not plan to add them in. They are margin interest and short interest, sometimes called hard-to-borrow fees. They are relatively small right now and not worth the effort (under $200 for this year). I may do this in the future.

The May to August period was my "toe in the water" testing phase. I took very small positions sizes (about $5k per leg), and I did not do all of the trades that my system generated. As long as there were bugs that I felt I needed to fix before doing more trading, I had to forgo trades. August was when I worked out enough bugs to feel confident enough to trade position sizes of $15k per leg.

From September to the end of 2013, you can see the number of opened positions hover around 20. With each leg counting as a position, this means that I had about 10 pairs active at any given time. You can see the "ramp up" of the position count from May to August as I started to make more and more of the trade generated by my system. 

There were some trades that I missed due to execution risk. As mentioned before, I've chosen not to allow my system to auto-fire the executions right now, although it is fully capable of doing so. When a trade is generated, it sends me an email and a text message so that I can verify that everything is fine. Usually this gives me a chance to check the spreads of the stocks. Most importantly, it prevents an infinite loop from firing trades repeatedly. This had always been my biggest fear of a fully automatic system. In fact, my system had entered an infinite loop 4 times in the course of this equity curve. Every time was my fault. I had written code incorrectly, or introduced a bug while trying to build new features. This is a risk that I imagine anyone running a system will have to deal with. I do have safeguards in place. I have one where it shuts down all of the algorithms when something goes wrong. That safeguard apparently had a bug in it too, and failed to prevent one of the infinite rapid fires. Had any of these times performed trades against my live account, I would have had substantial losses.

Not allowing auto-fire was the last defense. Its drawback is that for some of the trades, by the time I log on to check if the trade is ok, the trade is already gone. I haven't experienced any more of this bug in the past 2 months. I want to eventually run shorter time frame trades, which can only be achieved if I auto-fire. Time will eventually give me enough confidence to turn it on.

Lastly, my most recent backtests have yielded an equity curve which predicted a lot more profit. My live trading is capturing somewhere between 20% to 33% of what my backtests say I should be able to make, depending on how you look at the numbers. I'll have to do some research to find out what's a good percentage of capture.

No comments:

Post a Comment