Tuesday, 3 February 2009

Neural Network Assisted Trading System - NNATS

It has been some time since my last post – I have been distracted!

Over Christmas, I starting reading Adam Heathcote’s blog, Horse Racing Trader. He has set himself a challenge, that in 2009, he will make £150,000 from trading horseracing on the Betfair betting exchange. So far, in his first month, he has made well over £15,000 and is well on target to succeed.

I like three things about this challenge. Firstly, Adam is clearly very good at spotting trends and signals in the market, by analysing a stream of data provided by Betfair. Secondly, Betfair have published a web service API to allow you to interact with their exchange. Finally, any profits you make from Betfair are entirely tax-free!

This got me thinking that it might be worth pointing a neural network at the exchange and see if it could also spot the trends and signals that Adam is working with. Therefore, I opened a Betfair account, deposited £100 and started to hook up a neural network.

It took me a while to work out exactly I should be feeding into the network, and how I would identify the correct trading signals. However, after much trial and error, I seem to have something stable. I will not reveal exactly what the final configuration looks like just yet, but I will explain the basic mechanics of the trade.

How you make money from trading, rather than pure gambling, is quite easy to understand. Two terms you need to understand are “backing” and “laying”. By backing a horse, you are betting that it will win. By laying a horse, you are betting that it will loose. Betfair simply matches both sides of the bet.

To keep things simple, I only trade the favourite of an event and only ever on a falling market. A complete trade consists of placing a back bet at one price (odds) and a corresponding lay bet at a lower price.

The trades generally go something like this:

Back the favourite for £10 at decimal odds of 2.20
  • If the horse wins, I give the layer £10 and receive £22 in exchange. Therefore, I profit by £12.
  • If the horse loses, I give the layer £10 and receive nothing in exchange. Therefore, I lose £10.
Lay the favourite for £11 at decimal odds of 2.00
  • If the horse wins, the backer gives me £11 and receives £22 in exchange. Therefore, I lose £11.
  • If the horse loses, the backer gives me £11 and receives nothing in exchange. Therefore, I profit by £11.
As you can see, as long as I back and lay at the right amounts, I make the same amount of money regardless of whether the horse wins or loses. In the example above, in either case, I make £1 from a £10 stake, i.e. 10% profit on a single trade.

All well and good in theory, so I had to try it out for real. As you can see from my Betfair P&L screen below, on the first day I tried it, trading on ten different markets, and risking no more than £10, I made £5.91, or 59% profit. I was very happy with this result. At all times, I was in the loop, and actually making trades based on the network’s advice.



Since then, I have continued development, in the hope that NNATS will trade for me in a fully automated fashion, i.e. a money machine sitting in the corner of my room, quietly going about its business. This has not been without some scares, and the moral if the story is always debug your code before trading with real money. On one occasion, the stop loss feature fired at an inappropriate time and with a crazy expectation at which value I should close my position. Needless to say, I lost a few pounds on that trade!

Anyway, I shall continue to develop NNATS and report on its progress. Maybe one day I can stop working for a living…

John