I was reading the Betfair API documentation for a couple of weeks before beginning the proof of concept, I even printed certain bits off to read on the tube to work. There is a really useful user manual here… At 152 pages it is a big read but you can certainly filter out what you need and then user it as a reference for later.
I created the first proof of concept in about three evenings while working away in Norway. When I’m in a country where the price of a beer is £11 a pint i don’t mind the odd night staying in and hammering out some code.
As ever when I’m working on something i got too hung up on the interface and appearance, although I think it is a good replication of the Betfair interface, it wasn’t really needed and probably took up most of the development time.
The Betfair API uses HTTP requests for interaction and game states are returned as XML, the next task was to write an XML parser which could take the returned game state and use it to update the interface. The main point was for it to be quick so as to not leave the interface hanging while everything was being updated. I didn’t fully test it but i had the refresh rate running every couple of seconds and it was fine, sometimes loading the game state before the Betfair website.
After the interface was complete it was time to begin working on the analyses and bet logic. As this was an initial proof of concept i did not fully implement the place bet functionality. I didn’t want to lose everything on a rogue application! Instead the software kept track of the hands it would have placed a bet on and if it won or lost it would update the session wallet based on the odds at which the bet would have been placed. I believe this is called ‘paper play’ and tipsters do the same when testing new strategies, it allows you to keep track of results without ending up in the red.
The first rule implemented was not complicated at all, it had 2 parameters the upper and the lower, which could be tweaked based on how risky I wanted to be. I could have spent ages working out various calculations but to start with i was excited to get it up and running and see what would happen.
The first set of results were posted on the twitter feed, the plan will be to have the bot update the twitter feed itself when it’s fully automated, then i can just subscribe to the feed and be updated on the progress from anywhere. I did some tweaks of the parameters between runs but didnt make any big changes. The results were as follows…
Day1 Demo Run 1 – Games Analysed: 110; Rules Active: 1; Games played: 27 (Win: 21 Lose:6); Total Profit: 8.22; Total Loss: 12.00; P&L: -4.22
Day 1 Demo Run 2 – Games Analysed: 216; Rules Active: 1; Games played: 44 (Win: 37 Lose:7); Total Profit: 14.14; Total Loss: 14.00; P&L: -0.14
Day 2 Demo Run 1 – Games Analysed: 47; Rules Active: 1; Games played: 19 (Win: 17 Lose: 2); Total Profit: 7.22; Total Loss: 4.00; P&L: 3.22
Day 2 Demo Run 2 – Games Analysed: 693; Rules Active: 1; Games Played: 277 (win:222 lose:55); Total Profit: 117.13; Total Loss; 110.00; P&L: 7.13
The longest run was day 2 demo 2 which was run over a 24 hour period. The £117.13 profit would have been brilliant if not for the £110 loss. It’s certainly a good start though.
I think the next step is to come up with some additional rules and continue the demo and tweak parameters until i get something with fewer losses.