Saturday, August 20, 2005

Late Summer Trading System Development

Late Summer seems to be the time of year when I become interested in developing technical trading systems. Last Summer I spent a lot of time working on technical trading systems in C#. I had one that used bollinger-bands to play counter-trend moves that showed some promise....but a lot more work needs to be done on that one. This is a task I haven't been interested in committing myself too so far, but it's on the ol' "to-do list".

A few weeks ago I was reading this thread on Elite Trader, about High Frequency Trading. There has been a lot of buzz recently about High Frequency Trading, because some famous hedge-fund manager with an incredible track-record recently announced a new fund that uses HFT strategies and he's accepting huge amounts of money. The buzz has got me thinking about HFT ideas. As far as I can tell, HFT is mostly intermarket arbitrage, statistical arbitrage, and liquidity providing strategies all done very rapidly on an intraday basis. They have an edge from processing information (including order book analysis) very rapidly using computers, and because they have a superior speed of execution.

I don't have access to intraday tick historical data, but I was thinking that maybe a liquidity providing strategy might work on a longer time-span, especially if the strategy buys and sells against the market direction when it is making slightly above average movements. My thought was that during such times the market might be slightly out of balance, and the strategy might be able to make a profit by taking the other side of the market herd's trade. The goal of the strategy was to be buying and selling at the fringes of the current volatility.

The system consists of two independant agents. A bullish contrarian and a bearish contrarian. They each make a decision on whether or not to buy or sell stock, and the program consolidates their trades into a net decision on how much stock to buy or sell. The agent's entry points are scaled by recent historical volatility (I was generally using 30 days). The system is intiated on the first day with both agents intiating a position. The bear agent shorts a unit of stock, and the bull agent buys a unit of stock. Both of their trades cancel each other out so no actual net-trade is made. This gives both agents a point of reference on which to make subsequent trades. Any time the stock price moves one daily standard-deviation in either direction away from the last trade on the agent's virtual book that agent initiates a new trade. Furthermore if the stock price has moved more than one daily standard-deviation that results in a profit for any trades in the agent's virtual book, the agent closes those trades for a profit. The 2 agent's trades are then consolidated and used to make a net trade on the real account. Every time the stock moves more than one daily standard deviation both agents make new positions, but one agent will be cancelling out his new position initiation with a profit taking on a previously opened trade so his book does not actually change.

The major problem for the system is trending markets. Eventually one agent will accumulate positions it will never be able to get out of because the stock will never reach those levels again. I tried several variations to deal with this. One system bought options and basically allowed the unprofitable options to expire while rolling the profitable ones forward. Another versions used various price-stop losses and time-based stop losses. Most of my time was spent writing code to handle the accounting. Since the system always has a position on the books which it is adding to or depleting from, it was hard to figure out a good way to pair the trades so that I could compute useful statistics for evaluating the system such as the winning trades percentage, losing trade percentage, expectancy, etc...It was easy to compute total PnL and do drawdown analysis though.

At times the system seemed like it was going to be wildly successful and I was quite excited. Always this turned out to be due to a bug or a data flaw which when fixed also erased the phantom profits. I was back-testing it on a just a few stocks. My final conclusion was that the system wasn't that great so I didn't bother to do a wide-scale backtest on hundreds of stocks, yet.

It looks like it might have some promise if one could somehow identify times when a stock isn't actively trending. I also am kicking around ideas for how to make the system adjust the strategy during trending markets as positions accumulate. In general the stop losses schemes didn't help the system much. They did mitigate losses during times when the system was taking large losses, but they also reduced the profits too much. Also, I realize that I need to change the entry/exit decisions to use the standard deviation for the time period elapsed since the last trade instead of the daily standard-deviation. I think this would cause the system to be puting on trades after the market has made more extreme moves which are typically good times to be accumulating positions for counter-trend systems like this. As it is now, the system is puting on trades often when nothing significant is really happening in the market. Someday maybe I'll test this strategy with intra-day data. With intra-day data the system would be implemented with limit orders at the price trigger points, and would profit from the bid/ask spread which would probably help the system out quite a bit.

It was an interesting idea. I am fascinated by the idea of simple agents interacting together to produce complicated behavior. This type of phenomena is called cellular-automata. I've successfully used cellular-automata ideas to solve some tricky image-processing problems in the past in my main business (computer graphics). I'm definately intrigued by the idea of using cellular-automata for trading. This may even inspire me to actually finish reading A New Kind Of Science which is supposedly a good book about cellular automata. Like most owners of this book, I haven't read past the first few chapters because it's the size of a phonebook and incredibly dull, but maybe it could spawn some new trading system ideas. I've read a lot of books in the past year about derivitive pricing, so my tolerance for boring books may be much higher than when I first attempted to read A New Kind of Science years ago.

0 Comments:

Post a Comment

Links to this post:

Create a Link

<< Home