Programming for Betfair

Programming for Betfair, a guide to creating sports trading applications, is now available on Amazon. You do not need any previous programming experience to follow the book, just a logical mind. Both beginner and expert programmers have completed the book. Programming for Betfair teaches you all you need to know about programming your own trading applications.

Why Would I Want This Book?

Yes, there is plenty of third-party software out there but a lot of this software is geared to manual trading and even then, trading in a certain style. You may have your own trading strategies, which cannot be implemented with third-party software. Algorithmic trading is best done with software that you have crafted yourself. Also, you may not want third-party software to be able to implement your ideas otherwise other traders will happen upon your strategies.

In the long-term there is a great cost-saving to be had from producing your own trading software. Betfair does charge a £299 one-off access fee for receiving live data through API-NG. However, you can receive free delayed data (with a one to sixty seconds delay) whilst you develop your own software and strategies. Betting functions are always in realtime whether you use live data or not. Also, with the delayed key you will still have access to the lastMatchTime so you will know at which time the lastPriceMatched was struck.

Most third-party trading software has a subscription fee that has to be paid every month and eventually you will pay a lot more than Betfair's API-NG live access charge. You can always work through this book, test some ideas and then decide if you want live access to the data at a later date.

What will the book teach me?

Using the freely available Visual Studio programming environment I show the reader how to build an application that gets prices from and places bets automatically into Betfair's exchange.

Also, the reader can build databases from Betfair data for offline analysis. Data can be saved whilst the trading application is running and then converted into a CSV format for a spreadsheet where it can be manipulated, charted and analysed for the creation of trading rules.

After working through the book the reader should have all the tools needed to start building their own trading bots.

There is also a chapter on improving access to the charts on Betfair's website. Charts can be grouped together for comparison and updated automatically to keep the trader up to date with the latest trends in the market place. The final chapter touches on some advanced techniques such as the creation of trading indicators, volume analysis (specifically VWAP - volume weighted average price), low-latency optimisation, arbitrage, machine learning, Monte Carlo methods and more.

With this book you will be able to create trading bots using your own trading systems. You won't have to give away any of your trading secrets through asking a third-party to include the exact functionality that you require in their software.

Some Screen Captures from the Book

Betfair's visualisers are used to demonstrate how JSON is used to communicate between the reader's computer and Betfair's servers. The reader is then gently led through the creation of JSON request strings and the processing of JSON response strings into raw data for use by the application.


The price engine with a bet placement control for experimenting with various bet types. The user is then shown a non-graphical way of inserting bets into the exchange for automated trigger betting with bots.


A ChartBot can easily be created for multiple views of Betfair charts, side by side. They can also be set to auto-update.


The applications created in the book can build databases of data for offline analysis in a spreadsheet so that the user can analyse the data and build trading rules.


Contents

Preface
Introduction

Chapter 1 - A BASIC Approach
Join the Revolution
Microsoft Visual Basic
Google Chrome

Chapter 2 - Logging into Betfair
Session Tokens and Application Keys
The ToolBox
Changing a Control's Properties
Adding Another Form
The WebBrowser Control
The Betfair Visualisers

Chapter 3 - Understanding JSON
JavaScript Object Notation
JSON Parser
ListMarketCatalogue
Serialization and Deserialization
NewtonSoft.Json.dll

Chapter 4 - Off to Market
Sending a Request
Serializing a Visual Basic Object into JSON
Referencing Newtonsoft.Json.dll
Building a Visual Basic Request Object
Deserializing JSON into a Visual Basic Object
Running The Application

Chapter 5 - A GUI Feeling
Displaying the Contents of a JSON Response
The DataGridView Control
Building a Standalone Application
Further Work

Chapter 6 - Gathering Prices
Using the listMarketBook Method
Processing ListMarketBook Responses
The Timer Control
Further Work

Chapter 7 - Place Your Bets
Types of Trader
Placing a Bet Through the Visualiser
Sub £2 Bets
Greening Up (Hedging)
Betting Experiments
Monitoring Bets
Automated Trading
Further Work

Chapter 8 - Saving Data for Offline Analysis
Saving Data to Your Hard Drive
Processing Data for Offline Analysis
Data Visualisation with a Spreadsheet

Chapter 9 - Automating Betfair Charts
ChartBot
Creating a Form Programmatically
Using ChartBot
Further Work

Chapter 10 - Making The Most of It
Quantitative Analysis
Creating You Own Indicators
Volume Analysis
Trend Following
Fundamental Analysis
Arbitrage
Money Management
Optimising for Speed (Low Latency)
Machine Learning
Monte Carlo Methods
Concluding Remarks

Recommended Reading

Complete Listings

Is there an eBook? There will not be an eBook. I am a self-publisher with no facilities for creating eBooks. My book is printed on demand with no advance royalties from a publisher therefore I am dependent on all future sales. As I started coding in the early 1980s I am used to entering code from magazines and books. I feel that I learned more from that than today's generation who cut and paste their knowledge. There is a lot to be said for doing things slowly.

Need help with the book?

If you are looking for help on this page then you have not read the book properly. Start again from the very first page, read carefully and you will find the URL for the book's support page, where I provide updates and help beginners to find their typos.

With over 1000 satisfied readers, the code in this book (as of February 2017) still permits a trader to create their own applications for algo-trading and historic data capture.