Automatic Betting
Guest article by Colin Magee from Betwise.
I’d been interested in automating the betting process for some time prior to the emergence of the Betfair API and writing Automatic Exchange Betting, but making the process reliable was a challenge. Betfair’s API created a robust way to programmatically access market data and place bets via the exchange, but there was still no good way to automate the selection of bets themselves. This required unreliable and/or manual processes to either export data from one of the traditional interactive racing databases, such as Raceform Interactive, or to write robots to scrape the web from online form sources (which was unsatisfactory for a number of reasons – grey area of site usage, changing page formats, incomplete data, to mention a few).
So, for the selections part of automating the betting process, Betwise created the Smartform database before publication of the book by licensing copious racing data for personal use back in 2007, designing it for automated updates from original sources (so no manual intervention was needed), and making it as easy as possible to create and run programs to do just about any aspect of form analysis – and output selections for automated betting.
Along with the Betfair API, the service completed the DIY betting automation picture. For sure, programming is not everyone’s cup of tea, but if a bettor has a manual betting process that can be well described, it is a good candidate for automation since any good betting strategy, automated or otherwise, begins with data.
An example I used in a magazine article just before the book was published illustrated just how simple the principles of automated betting can be. We looked at a straightforward case that can be considered at one particular racecourse to show how even analysis of a single variable could be turned into a useful automated strategy for certain types of races. For a more general approach to all races, of course, it makes sense to look at more sophisticated models for predicting performance which use multiple factors.
In this particular case, I looked at one of the more well-known draw biases in racing, at Chester Racecourse, and how this can be assessed for profitability and then turned into a profitable automated system.
The tight turns at Chester (perhaps the tightest as well as the oldest course in England covering a circuit of just over a mile) would seem to offer an obvious advantage to horses drawn low, closer to the inside rail, since they have far less ground to cover than horses drawn wide. However, that still leaves open exactly what that advantage is, under which conditions, and how profitable is following a low draw alone?
We started looking at different distances: if the effect of the draw is random we would expect to see a ratio of winning stall number to total field size close to 50%, given enough trials, with high and low draws balancing out. Wherever lower draws are significant, we would expect this number to run below that.
+-----------+------------+-------------------+---------------+------------+
| Distance | Number runs| Avg winning stall | Avg finishers | ratio |
+-----------+------------+-------------------+---------------+------------+
| 5f and 6f | 61 | 3.9016 | 12.0164 | 0.32469304 |
+-----------+------------+-------------------+---------------+------------+
| 7f and 8f | 67 | 6.5224 | 12.5821 | 0.51838671 |
+-----------+------------+-------------------+---------------+------------+
| 10f + | 68 | 6.4853 | 12.6324 | 0.51338766 |
+-----------+------------+-------------------+---------------+------------+
For the sprints category (5f and 6f), the low ratio of 32% shows us that of all races run at Chester with 10 finishers or more (averaging 12), the winner on average came from the lowest third of the draw.
Whilst the strike rate of lower numbers in the first category looked interesting, it is only an average, and does not tell us anything about which stalls in the top third are best, or whether the market typically takes account of this factor (i.e whether we have found a profitable angle). Breaking down the 61 sprint races in one Smartform query to show the strike rate of the winning stall number and add in the average starting price for each winner:
+--------------+---------+---------------+------------+
| Stall number |#winners | Avg Decimal SP| Profit |
+--------------+---------+---------------+------------+
| 1 | 15 | 7.449286 | 50.739286 |
| 2 | 10 | 6.975000 | 8.750000 |
| 3 | 8 | 6.375000 | -10.000000 |
| 4 | 7 | 8.313333 | -2.806667 |
| 5 | 5 | 7.140000 | -25.300000 |
| 6 | 5 | 12.100000 | -0.500000 |
| 7 | 3 | 9.000000 | -34.000000 |
| 8 | 3 | 12.000000 | -25.000000 |
| 9 | 1 | 8.000000 | -53.000000 |
| 10 | 3 | 13.666667 | -20.000000 |
| 12 | 1 | 17.000000 | -44.000000 |
+--------------+---------+---------------+------------+
The last column shows the historic profitability of backing each draw blind in sprints at Chester with larger fields over the period.
Not only is the win frequency directly related to the draw (the lower the better), but backing both stalls 1 and 2 blindly for every race produces a profit.
In fact, the level stakes profit is almost the same on stalls 1 and 2, at over 15 points on each to level stakes, since 2006, whereas before it that it is heavily biased to stall 1.
The research for this article was originally done before the last meeting at Chester in 2008, and published just afterwards. If we see how the same rules have performed since the research was carried out we get the following output:
+---------------------+------------+-------+-----------+------------+-------------+
| scheduled_time | winner | Stall | SP | num_runners | result |
+---------------------+--------------------+-------+-------+-------------+--------+
| 2008-09-13 15:30:00 | Angus Newz | 1 | 4.50 | 11 | 1 |
| 2008-09-13 15:30:00 | Look Busy | 2 | 2.50 | 11 | 2 |
| 2008-09-27 14:50:00 | Doughnut | 2 | 5.50 | 13 | 2 |
| 2008-09-27 14:50:00 | Aldermoor | 1 | 2.88 | 13 | 1 |
| 2008-09-27 17:00:00 | Wyatt Earp | 2 | 3.50 | 14 | 1 |
| 2008-09-27 17:00:00 | Methaaly | 1 | 10.00 | 14 | 3 |
| 2009-05-06 15:15:00 | Fyodor | 2 | NULL | 12 | NR |
| 2009-05-06 15:15:00 | Strike Up The Band | 1 | 4.50 | 12 | 2 |
| 2009-05-07 16:00:00 | Reel Credit Crunch | 2 | 17.00 | 11 | 2 |
| 2009-05-07 16:00:00 | Johnnyleary | 1 | 9.00 | 11 | 9 |
| 2009-05-07 16:35:00 | Lucky Numbers | 2 | 5.00 | 11 | 2 |
| 2009-05-07 16:35:00 | Invincible Heart | 1 | 4.50 | 11 | 1 |
| 2009-08-22 14:25:00 | Bertoliver | 2 | 4.00 | 11 | 1 |
| 2009-08-22 14:25:00 | Tyfos | 1 | 6.00 | 11 | 3 |
| 2009-09-26 17:00:00 | Bel Cantor | 2 | 9.00 | 14 | 2 |
| 2009-09-26 17:00:00 | Kingswinford | 1 | 6.50 | 14 | 3 |
+---------------------+--------------------+-------+-------+-------------+--------+
So, there were 8 races since and the “system” found 5. And it’s still a profitable system, yielding 4.33 points at Bookmaker SP (even more so at Betfair SP). This means 3 out of 8 races were not found (but sceptics should still note that these were won by 2 horses coming from stall 3 and one from stall 4).
Automatic Exchange Betting outlines code and approaches to bet on such a system automatically. In overview, the whole shebang can be programmed and then automated using scheduling facilities (available through any humble computer’s operating system) combined with access to the right data sources and, of course, provided that the bettor’s computer or server is constantly connected.
To make the daily selections in Smartform, the qualifying rules are implemented by a simple select statement where course=”Chester” and (stall_number=1 OR stall_number=2) and distance_yards < 1500
.
Programming the Betfair API gets trickier,
but if you imagine many such systems, then the benefits are clear. Moreover, if you imagine a real model involving multiple factors assessing every race, including assessing the market prices on every contender to strict criteria, you soon realise that what was not possible betting manually suddenly becomes realistic automatically.
Colin Magee wrote Automatic Exchange Betting, a comprehensive guide to how you can automate your selection process and betting through the use of databases and the Betfair API. His website Betwise provides access to a database with all the raw data you need to automatically find your selections.