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

Wednesday, 3 June 2009

NNATS - It's No Fluke!

I couldn't sleep, so thought I would make good use of the time by catching up with replies to blog comments - sorry it's taken so long!

Whilst I'm here, another quick update on NNATS. I've continued to increase the bet size and continue to make money. In the last week, I'm £78.66 up, which is representative of recent history.



I've given a copy of NNATS to a friend, so it will be interesting to see whether his bot competes with my bot or, more hopefully, they reinforce each other's trades...

John

Saturday, 16 May 2009

Linear Regression in C#

When looking at time series data, such as a stream of prices, it can often be useful to establish a general trend and represent this with a single number. This can be achieved using a linear regression calculation.

Take this series of prices:
4.8, 4.8, 4.5, 3.9, 4.4, 3.6, 3.6, 2.9, 3.5, 3.0, 2.5, 2.2, 2.6, 2.1, 2.2

If you plot on an Excel graph and add a linear trend line, you should get something like this:



We can do the same thing in code:

using System;

 

class Regression

{

    static void Main(string[] args)

    {

        double[] values = { 4.8, 4.8, 4.5, 3.9, 4.4, 3.6, 3.6, 2.9, 3.5, 3.0, 2.5, 2.2, 2.6, 2.1, 2.2 };

 

        double xAvg = 0;

        double yAvg = 0;

 

        for (int x = 0; x < values.Length; x++)

        {

            xAvg += x;

            yAvg += values[x];

        }

 

        xAvg = xAvg / values.Length;

        yAvg = yAvg / values.Length;

 

        double v1 = 0;

        double v2 = 0;

 

        for (int x = 0; x < values.Length; x++)

        {

            v1 += (x - xAvg) * (values[x] - yAvg);

            v2 += Math.Pow(x - xAvg, 2);

        }

 

        double a = v1 / v2;

        double b = yAvg - a * xAvg;

 

        Console.WriteLine("y = ax + b");

        Console.WriteLine("a = {0}, the slope of the trend line.", Math.Round(a, 2));

        Console.WriteLine("b = {0}, the intercept of the trend line.", Math.Round(b, 2));

 

        Console.ReadLine();

    }

}



Now you have the slope of the trend line, this can be used as an input for neural networks analysing time series data. I use something similar in NNATS…

For a complete explanation of linear regression see Wikipedia.

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