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. One particular thread, started by user Mumbles0, has helped many Betfair users to write their own software. Myself included.

For those wishing to do likewise, I have a created a list of tutorials (see below) and useful posts from the Mumbles0 thread. The code is in Visual Basic but it can be easily modified to C# or some other language with some ingenuity.

I would also recommend that you read the entire thread for any snippets that might assist in extending your software. You may also find help if you are stuck with a problem that others have had.

Note that Betfair has now introduced API-NG (see below) and will phase out the current API-6.0 in November 2014. Rather than using SOAP as in API-6.0 the new API uses JSON and my initial thoughts are that it is a vast improvement.

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 good 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 little 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 trading rules.

API-NG

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 November 2014.

When I get the chance I will put up some code to demonstrate the ease of creating code with API-NG.

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

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