Write Your Own Betfair Software

In addition to trading via Betfair's website, Betfair also permits access to its servers via an API. Access to Betfair's API is free of charge but there are limits to the amount of data you can download. For unlimited access there is a charge of £200 per month.

Still, free access to the Betfair API is enough to build an effective piece of software and you can then decide if it is worth spending £200 a month for full access.

On the Betfair Developer Program (BDP) forum there is a lot of help for those starting out on coding their own software. With Betfair now migrating from the old SOAP based API-6.0 to the JSON based API-NG I recommend that users read the API-NG forum on the Betfair Developer Program website. My initial thoughts are that API-NG is a vast improvement over API-6.0.

I have also written a few articles myself on this blog about coding using API-NG under Visual Basic. However, this list is incomplete as I now write API-NG articles for SmartSigger magazine, a monthly magazine that covers many aspects of sports betting mathematics and coding.

Because API-6.0 will cease to work in April 2015 I can no longer recommend the excellent thread, started by user Mumbles0 elsewhere on the forum, that has helped many Betfair users to write their own software, myself included. I include the list of his articles at the bottom of this page solely for those still coding with the old API. If you are about to begin coding then I suggest you save time use API-NG.

You might like to consider buying Automatic Exchange Betting, which covers many aspects of trading on Betfair and programming using Betfair's API. Although the code is in Perl it can be easily ported to another language.

Automatic Exchange Betting covers the construction of an automated system and goes a long way into system building using odds lines, weight of money, average prices etc. The book is very detailed and will give the reader a deep understanding of automated exchange trading and program development.

Another book that details the construction of an automated betting system is Calculated Bets: Computers, Gambling and Mathematical Modeling to Win. Written by Professor Steven Skiena, Calculated Bets details the professor's successful modelling Jai Alai matches, developing a trading strategy using Monte Carlo methods and then implementing bet automation.

Designing your trading software

Rather than trying to code the ultimate trading platform straight away, you should first build simple single-task tools to handle repetitve tasks. You can then add your own metrics for manipulating Betfair data. After that you might want to automate betting and position tracking. Finally, you can code a bot that does all of the above whilst acting under your own trading rules.


Betfair is currently rolling out API-NG, a JSON based replacement for the current SOAP based API-6.0. My first impressions are that this is a much easier API to understand and code with. Having had to read and modify Mumbles0's code to suit my needs, this time I have coded an API-NG application quite easily by myself.

I would recommend anyone writing Betfair trading software now to start doing so with API-NG as any programs running on API-6.0 will not function after April 2015.

Click on the Betfair API-NG topic for a current list of tutorials that I have written about the API so far.

I am now writing a column in SmartSigger magazine detailing the use of API-NG for bot programming. Each month I explain how to use an aspect of API-NG in a simple bot programmed in Visual Basic. I recommend SmartSigger, the only betting magazine written by pro-bettors.

VB.NET Implementation of a Trading Platform using API-6.0

Step 1. Build a Test Form #2
Step 2. Connecting to the Global service #3
Step 3. Saving the Session Token #4
Step 4. Typical API call: getActiveEventTypes #5
Step 5. Accessing an Exchange API #6
Step 6. Unpacking Response Strings #7
Step 7. Restrictions of the Free API #8
Step 8. Using a Call Timer #9
Step 9. Making Async API Calls #10
Step 10. Calling getCompleteMarketPricesCompressed #12
Step 11. A Look at Multithreading #13
Step 12. Getting a List of Runners #23
Step 13. Enabling gzip Compression #28
Step 14. Calling getMarketPricesCompressed #60
Step 15. Using TreeView to show events and markets #67
Step 16. Unpacking Removed Runners #87
Step 17. Sorting Runner Info Arrays #103
Step 18. Horse Racing - Today’s Card #174
Step 19. Placing a Bet #181
Step 20. Monitoring Bet Status #200
Step 21. Cancelling a Bet #204
ListBox for marketIds #214
Step 22. Changing the bet size and price #232
Step 23. Changing a Bet #240
Step 24. Calling getMarketTradedVolumeCompressed #258
Step 25. Accessing Australian Markets #272
Processing data from 2 async calls #302
Handling async calls for multiple markets #326
Step 26. Array fundamentals #334
Step 27. Understanding Object References #335
Step 28. Placing Multiple Bets with placeBets #340
Event time sorting #385
Step 29. Adding controls to a form at run time #397
Step 30. Saving your project’s settings #421
Step 31. Using the TabControl for multi-markets #471
Step 32. Displaying Prices in the Runner Grid #475
Step 33. Selecting a runner #479
Step 34. Using Excel with VB2010 #748
Step 35. Using Excel with VB2010 (continued) #749
Step 36. Handling Excel events #751

No comments:

Post a Comment