Showing newest posts with label Trading. Show older posts
Showing newest posts with label Trading. Show older posts

Saturday, 11 July 2009

A Profitable Strategy Abandoned

As NNATS continues to evolve, it is not making money that is the problem; it is being able to make lots of money.

The biggest problem I have now is how to scale up. My bet sizes have increased significantly, however, the number of days and number of markets on which I trade has reduced. For some reason, Saturday and Sunday punters seem to suit NNATS best. On these days, there is a constant stream of money coming into the markets in a nice predictable way. On the contrary, NNATS especially hates Mondays, which is thin and unpredictable.

I have experimented with a number of trading strategies, but for now have settled on pure scalping.

A couple of months ago, however, I experimented with a strategy, which I named “Aggressive NNATS”. The plan was simple; back any selection whose lay price was at least three times the back price. NNATS would always try to place a back bet at the front of the queue, so for instance if the current lay price was 1000, it would place a back bet at 990. You would be surprised how many other bots out there appear to be running similar strategies. Together, NNATS and the other bot would play a game of chicken, and quickly chase the price down to a level where one of them would give up.

I did not really expect to be matched at such outrageous odds but, every now and then, it would happen. At that point, NNATS would lay the selection a pip ahead of the current back price and net a healthy profit. Of course, getting the lay matched could also sometimes be a problem, but NNATS would keep moving it out until somebody bit.

The following three screen shots show some particularly memorable examples from my P&L.







Why would I give this up? The answer is scale. This strategy is great if you want to make a fifty or a hundred pounds a week, but I am now aiming for a hundred pounds a day. The outrageous profits from “Aggressive NNATS” do not happen often enough to be a viable proposition.

Still if anybody wants to make a few quid a week, this is an easy way to do it..!

John

Thursday, 30 April 2009

Weight of Money

Many of you have asked what sort of inputs I use for NNATS and how these can be used either independently or to feed a neural network for further analysis. In the next few posts, I will share some of these with you.

To get the ball rolling, let us start with the backbone of any Betfair trading bot, the “weight of money” indicator. This indicator is a very good place to start, as intuitively it is easy to understand, it is easy to calculate and it provides an output in the range of zero to one, which I always like.

Quite simply, the weight of money indicator provides a measure of how much money is available to back compared to how much is available to lay – or to look at it another way, sellers verses buyers. In theory, if there are more sellers than buyers then the price will fall and if there are more buyers than sellers then the price will rise.

Take this set of prices presented to us on the Betfair interface:



On the left we have the money available to back and on the right the money available to lay.

The weight of money is calculated simply by dividing the sum of all available back money by the total of all available money, i.e.

(62 + 420 + 402) / (62 + 420 + 402 + 62 + 36 + 46) = 0.8599 or 85.99%

Generally, the way to use this value is as follows:
  • 0% to 33% means the price will move down.
  • 33% to 66% means the direction is uncertain.
  • 66% to 100% means the price will move up.
A few moments later, the price had moved up a tick, as predicted, and as seen below:



I certainly would not use this indicator by itself, but is does provide a very good feeling about where the market may move to next.

Hope this is useful.

John

Saturday, 25 April 2009

NNATS Evolves

It has been a while since my last post – as always, I am time starved! Any free time I’ve had has been spent, almost obsessively, developing NNATS.

It has taken hundreds of hours of coding and fair few lost pounds, but NNATS now operates completely unattended and is able to make small yet consistent profits. I cannot believe how hard it has been! The screenshot below shows the profit and loss for the last week. Not the stuff retirements are made of, but not bad either.



There are so many scenarios that we humans cope with automatically, but to NNATS is a completely new opportunity to lose money – these all have to be coded around.

My trading strategy has changed enormously since the early days, when I was trying to get NNATS to emulate human behaviour. NNATS has some real limitations compared to its human prey, but some great advantages too.

The main disadvantage is that NNATS cannot watch TV! A horse’s price can move out wildly leading up to a race if it looks jittery or has trouble going into the stalls, and of course, NNATS cannot see this happening. It can react to the price change and close a losing position, but this normally wipes out any profit from a few races, so why take the pain? Therefore, NNATS stops trading a market half an hour before the start, which means that is misses the high liquidity period during those last few minutes, which is a shame.

Now for the advantages. NNATS is an aggressive scalper and has adapted to trade in the lower liquidity portion of a market, before it hits TV. It will start trading as soon the market becomes available and will continue trading up to 30 minutes before the start. There are definitely some parallels here with evolution. NNATS has had to adapt to survive, and rather than evolve into a tiger, NNATS has become a patient predator – more like a crocodile.

Another advantage that NNATS has is that it trades all available markets in parallel, which means it has a pool of several hundred horses from which to choose.

However, the most significant evolutionary change is that NNATS no longer requires its neural network. The network served its purpose. It was fantastic for indentifying the useful indicators and the relationships between them, but this has now been replaced by hard coded logic.

One of the most significant indicators is the “weight of money”, which when used in conjunction with other signals is very powerful. The other thing the network indentified is the relationship between the runners. If something is moving out very strongly, then normally something is also moving in, and vice versa.

My plan going forward is to leave NNATS running for a few weeks, actively trading and capturing data. It is only by making trades, comparing expected outcomes against actuals, that I can gather enough information to feed a second-generation network. This network will make NNATS a stronger trader by learning from its mistakes.

In the meantime, I will post more articles about other areas of neural networks. I have some ideas bubbling away…

Thanks for reading and keep visiting.

John

Wednesday, 25 February 2009

NNATS Goes on a Diet

If you read my last post, you will know that my goal is to build a fully automated trading system, assisted by a neural network, which will trade on the Betfair exchange – I call this system NNATS (Neural Network Assisted Trading System)

Since my last post, NNATS has matured a lot. I have learnt much more about the Betfair exchange, its API and about how to make (and lose) money.

In the beginning, NNATS had in excess of a hundred analogue input neurons. However, thanks to some clever pre-processing and my greater understanding of what is actually important, NNATS now has only one analogue input neuron (inverse of the current price) and twenty-three binary input neurons (on/off technical indicators).

The neural network supporting NNATS consists of four layers, comprising of the twenty-four input neurons mentioned already, six hidden neurons, two hidden neurons and one output neuron. The penultimate layer is deliberately two-dimensional, so that I can visualise what the network is doing – see my previous blog on this subject.

Using the network visualiser, I am quickly able to see how network training is progressing and tune as appropriate. The most significant thing to note is that I am not looking for an exact fit, as market price movements are probabilistic.

In the screenshot of the network visualiser below, the green points represent market conditions that have previously resulted in at least 25% profit. The red points represent market conditions where 25% profit could not be achieved.



The landscape is divided by a single hyper-plane. The hyper-plane defines a region, the “profit zone”, where NNATS believes there is a high probability of achieving at least 25% profit from a single trade. You will notice that there are still a few red points in the “profit zone” – this is because the market is probabilistic and cannot be predicted with 100% certainty. However, the number of green points in the “profit zone” far exceeds the number of red points, which means that profits should outweigh losses.

The other significant change I have made to NNATS is to remove completely the human trading interface - and subsequently me from the trading process. I had originally built myself a trading interface similar to Bet Angel, complete with trading ladders and charts. However, I have since discovered that I am my own worst enemy, and cannot prevent myself from overruling NNATS. The only time I have ever lost significant amounts of money is when I have ignored the advice provided by NNATS – therefore I have made the bold move to remove myself entirely.

Initial testing against trading simulations looks very promising. I just need to do some final plumbing and refinements before I trade for real again – all I lack is time. Work is very busy at the moment, and I’m about to go on yet another skiing holiday – it’s a tough life :-)

Once I have started trading for real, I will start posting P&Ls on this blog.

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