In the early days of Gamblotron I added two main indicators: Bollinger Bands, and MACD. It's high time I added some more, Wikipedia alone lists several dozen, the more the merrier!
Today, therefore, I am going to introduce the next indicator inspired from the world of Technical Analysis: the Relative Strength Index. (Also known as RSI for short, not to be confused with repetitive strain injury.) As the name suggests, it's a measure of strength; which, in this context, means the strength of the price movement (i.e. the speed of the price movement). It's relative because it compares a exponential moving average of the upward strength with an exponential moving average of the downward strength. A score of 50 means a flat market; a score higher than that is a rising market, a score lower is a falling market.
The theory goes that if a market moves too fast, then it is quite likely to change direction. If true then a score of 80 or more (the number is, of course, a parameter and can be changed depending on circumstance) indicates that a market is overbought and is likely to go down (a signal that a bet should be layed); a score of 20 or lower indicates that a market is oversold and likely to go up (a signal that a bet should be backed).
A classical interpretation of RSI would use close-to-close data (i.e. the closing price of the current day's trading compared with the closing price of the previous day). Since Gamblotron is a sport betting bot, working on markets measures in hours (minutes in extreme cases) which are continually open (barring suspensions at Betfair's whim) then close-to-close doesn't really apply. For each "day" or data a pair of values is produced, one measuring the upward strength, the other the downward - only one of these will have a value, the other will be zero, there are no negative numbers.
The final index is therefore calculated:
if ema_of_u == 0 and ema_of_d == 0:
return 50
else:
return 100 * (ema_of_u / (ema_of_u + ema_of_d))
To adapt this to the world of sport betting I will need to introduce an artificial window, a period of time against which I can compare start and end prices to measure the "strength". It is also important that the previous values (when calculating the EMA) do not overlap each other, or the current window.
The final problem with RSI, mostly introduced by my compramises in the previous section rather than a fundamental problem with it as a statistic, is that the produced signal can be fairly noisy. This is due to bad-luck in choosing extreme values as fenceposts, this makes a line plotting RSI look more noisy than it ought to be. (This isn't so much of a problem in stock markets as closing prices are generally reached at an auction, rather than just picking an arbitary last trade; it would be a problem if applying RSI as an hour-by-hour basis.) To counter-act this I decided to produce multiple RSI statistics, each derived from multiple non-overlapping windows, which was then smoothed with a moving average. For example, if thw window size was one minute, then I would produce 60 concurrent RSIs each offset by one second, I would use the average of these numbers as my indicator.
So, what is the point of using Relative Strength Index? That, like most things, is best explained in a graph (the event used is the European Grand Prix):
- Period Size - the size of the window.
- Number of Periods - the amount of non-overlapping windows in the past to use to calculate the exponential moving average.
- The "oversold" and "overbought" lines - which determine when to signal a bet to be placed.
The results, when tested against the data for the European Grand Prix, using the same rules as before - i.e. limit trading to the top-six qualifiers:
If Kazuki Nakajima wins: -0.55 If Any Other Driver wins: -0.55 If Nick Heidfeld wins: -0.55 If David Coulthard wins: -0.55 If Mark Webber wins: -0.55 If Nico Rosberg wins: -0.55 If Sebastien Bourdais wins: -0.55 If Adrian Sutil wins: -0.55 If Rubens Barrichello wins: -0.55 If Jenson Button wins: -0.55 If Sebastien Vettel wins: 381.95 If Kimi Raikkonen wins: 19.70 If Fernando Alonso wins: -0.55 If Felipe Massa wins: 3.27 If Nelsinho Piquet wins: -0.55 If Heikki Kovalainen wins: 449.45 If Giancarlo Fisichella wins: -0.55 If Lewis Hamilton wins: 28.70 If Timo Glock wins: -0.55 If Jarno Trulli wins: -0.55 If Robert Kubica wins: -0.55
Since Felipe Massa won, this would have meant a profit of £3.27. Not exactly going to make me rich, but still better than the Bollinger Band version. It didn't quite manage to cover itself though, a freak result would have produced loss of 55 pence (although events leading to a freak result would have presented more opportunities for trading, so it's impossible to say for certain).
The moral of this story is that RSI is clearly better at damage limitation than Bollinger Band based trading signals. It actually fell for the same false signal as the Bollinger Band version, backing Kovalainen at mad odds (200); if it wasn't for that it would have produced a balanced book. If I had limited it to just the top two qualifiers, the worst case would have been a £5.06 profit (on a maximum exposure of £5 - i.e. doubled my money), the actual profit (i.e. the payout on Massa winning) would have been £8.88.
Next Steps
This then, is interesting, it prioritises a few things on my list of improvments, and also adds some new ones!
It confirms what I've known for a while, there is nothing to be gained from trading on every selection in a race. Too many have no real chance, and therefore stupid odds; or are so thinly traded there is no opportunity to take profit. However, limiting the selection too aggressively in advance can also be quite bad; for example, it was the price movements on Timo Glock during the Hungarian Grand Prix that locked in the most profit, his odds were all over the place 30, 200, 12, 500, 30 again... and if a first-lap crash took out half the field then there's literally nothing to bet on. What I need therefore is a way of programatically making the decision on which selections to bet on, something based on depth of available money, something like that. I'll have to try and few and see what's best.
The new issues are that I think I may have been too quick to dismiss football (soccer) as a target for this bot. The graphs from the European Grand Prix are similar to a lot of the football ones, and not like previous Formula One graphs at all (this also means I need more F1 testing before I try and run it again). Something like RSI might work well on football. I need to give it a test, more than one in fact, quite a lot, I'll leave that until some future date!, there are too many issues for that now!
But it still wont work on completely boring events, the only way a set of profitable settings was found for the European Grand Prix was because the odds fluctuated after an announcement was made of a stewards investigation. The other side of that coin is that it doesn't take too much to create a profit, which is definitely good news.
But I still need a way of choosing optimal parameters before the event starts, it's much easier to sit here and decide "that's what I should have chosen" after the fact. It is quite time consuming to repeatedly test settings trying to find optimal values, I'm beginning to think I need an alternative approach here as well; I need to either: a) make the testing process automatic, build some kind of fitness function and get it to test itself!; or b) research some of the self-adapting indicators out there, there are some but the mathematics are well beyond my level, I'll have to enrol myself for a mathematics degree...
Conclusion
There is, as always, much more research to be done (and it gets bigger every time I look at it); it's high time to give it a rest for a bit, I'm giving myself a headache...
I'll look into the trading selection filter next, at some point next week.



0 comments:
Post a Comment