Warning: Declaration of Suffusion_MM_Walker::start_el(&$output, $item, $depth, $args) should be compatible with Walker_Nav_Menu::start_el(&$output, $item, $depth = 0, $args = Array, $id = 0) in /home/betfairs/public_html/wp-content/themes/suffusion/library/suffusion-walkers.php on line 0

Tom Burrows

Jun 062011
 

rico hits milestone

rico has reached the first big mile stone and successfully logged over 5000 hands of betfair blackjack.

I want to have a minimum of 10000 hands recorded for analysing my betting strategies so I’m half way there! I think 10000 hands will give me a good idea of whether a strategy will return profit in the long run or not.

I’m still running rico from my laptop, turns out the hard drive had failed on my spare desktop, i haven’t turned it on in the last six months and didn’t even realise.

It turns out the strategy I posted last week, to lay ‘One or more has 5 cards’ pre-deal every time which would have made £100 in the first day, would have lost me £933.20 over the course of these 5000 hands. Total profit of £8746 but a loss of £9679.20.

May 272011
 

RICO the bot has now successfully logged 250 hands of blackjack with no errors. I’m still running the bot on my laptop so have disabled tweeting the output for the time being.

I’ve had an initial look at the figures and there are some strategies starting to form. One thing i have found interesting is the bet ‘One or more has 5 cards’, which has only won 9% of the time.

one or more players have 5 cards

starting a new game in betfair exchange turbo blackjackWhen a new game starts none of the cards are known so the prices always seem to be the same. To lay the bet ‘One or more has 5 cards’ you are always given a price of 7.4. Minimum bet with betfair on each selection is £2 so to lay this bet your liability is £12.80.

liability of laying on betfair

When you win, no one has 5 cards, you win £2, when you lose you pay out £14.80.

Running through the numbers on the basis that you place £2 on this bet every game during round 1 you get the following…

24 times the bet won costing you £14.80 a time = you pay out £355.20

252 total games – 24 where you lose = 228 games where you win, each game you win is £2.

228 * £2 = Total of £456.

£456 winnings – £355.20 losses = £100.80 total profit. Not bad for two days work.

It’s certainly not a perfect strategy and the dataset is not large enough yet for me to be happy with the percentages, but it is a start. I’ve started to look at other ways to improve it, if you bet on the same square in round 2, when the cards are known, the price fluctuates between 1.68 and 525. Place the bet when the price is lower than 7.4 equals less liability which in turn equals more profit but also means more risk of the bet winning.

May 272011
 

tweet twoo coding the tweet implementedI’ve finally managed to get the twitter output working and RICO was posting yesterday. I originally had the timer set to every 10 seconds, not sure if there is a twitter limitation to how quick you can post, in the end i decided to leave it at six hours.

I can take none of the credit, the best article and code i could find is at Coding the Wheel http://www.codingthewheel.com/archives/codingthetweet very easy to follow.

I ended up just dropping all their files and had it up and running in less than half an hour, even with the registration on http://dev.twitter.com

Thanks to the guys who wrote the article, saved me a massive headache.

May 262011
 

About two weeks ago i started working on a new bot which would pick up game states from Betfairs exchange blackjack and log them into a database. The idea being that the bot will run for a couple weeks logging data which can be used at a later date for analysing betting strategies and general testing when i’m offline.

It took a little longer than expected, mostly due to work commitments, but RICO is now online and logging data. Currently running on my laptop i can only log about an hour at a time, i will be moving it onto a spare desktop soon and then it can run 24 hours uninterrupted.

RICO blackjack bot datbase schemaThe backend is a SQL Server database, mySQL was nearly an option, but i use SQL Server daily and have been for about six years so just made more sense. It’s not often that i get to create a new database from scratch, normally i just have to put up with whats already there, i think i over egged the normalisation a little. Creating it all from scratch also refreshed some parts of SQL Server i haven’t used for a while, i had to google the syntax for adding foreign key constraints! shameful i know.

rico betfair exchange bot interfaceThe interface is nothing special. The aim is that once the application is started it can be left to get on with it, this also meant that i couldn’t do what i normally do and get hung up on pixel level alignment when arranging the components.

The code took a little longer although i was able to use a lot of the XML manipulation code from my first proof of concept. There were still a lot of cases which were not handled in the original incarnation and needed to be to handled stop the application crashing on empty strings or null references. I included error logging in a database table and also handling for network issues, again didn’t exist before. If the network is lost now the bot will cycle 100 times trying to reconnect and if all attempts fail it will turn itself off, no point killing the hard drive logging the same error message.

Originally i wanted to include output to twitter for logging, i can just check the twitter feed and see the status of the bot etc. Unfortunately this has not been included yet. Twitter have changed the way they allow updates from third party applications and it wasn’t worth investing too much time in to. I have a few examples and some code taken from a couple of sites so it’s not gone for good, but will not be ready straight away.

By logging games over a long period of time i should be able to build up a good representation of the truth, with that i can build a betting strategy that should regularly make profit. They say if you flip a coin 10 time you could get 7 heads and 3 tails, however flip it 10000 times and the results will be closer to 5000 heads and 5000 tails, representing the true 50% chance of either heads or tails.

So what kind of reports can be run on the data? The bot is logging every game state at the beginning of each round, logging a final game state once the winners have been decided and then stores the final XML game state should there be anything which has not been extracted. With that i think i can build reports on pretty much anything I can think of and as the database is in SQL Server it’s just a short hop and a skip to plug it into SSAS and look at some mining scenarios.

Couple of basic reports i knocked up in SQL…

Total times a bet wins and percentage

Number of times a bet wins and percentage that is of total

The starting hands for winning players

Starting hands for winning positions and their starting points

And finally a pivot to show the final available back and lay price for a bet and whether it won or lost per game

Pivot Table showing the last available back and lay price per bet win or lose

May 122011
 

I’ve been looking for guides on how to post to Twitter using C#. It seems a little while ago Twitter changed their authorisation methods and is now using oAuth. What that means is the internet is a litter of useless guides and tutorials all giving old out dated information.

Eventually I found some good guides but it looks like it is now a pretty convoluted process. First you need to register the app to generate a set of keys, which you post to a REST service that returns a pin, in the same session you then need to return the pin to authorise the application. Security wise it’s a lot better apparently but requires a bit more thought.

I’ll be leaving out the twitter interaction for the time being. At this time there is plenty to be getting on with without spending too much time on what is a non-essential part of code.

May 092011
 

I was working on my proof of concept code last week. and seem to have managed to corrupt the solution.

When originally programming I didn’t really bother with separation of logic or anything, as a proof of concept i thought that would be fine. However when i started re-arranging everything to cut out duplication and tidy up the code i seem to have broken it.

I now get the error message “An error was encountered while opening associated documents the last time this solution was loaded. Document load is being skipped during this solution load in order to avoid that error.”.

Now might be a good opportunity to re-start and spend a bit more time on getting the code neater.

May 092011
 

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.

first proof of conceptI 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.

Apr 262011
 

I’ve always enjoyed placing a good bet. Horses, dogs, football or poker, I’ve probably put money on most things. I stumbled across Betfair about a year ago after reading about some people making good money laying favourites on horse races. It seemed like an interesting concept but at the time i wasn’t very interested, I’d never really thought you could make a regular income from gambling.

I started playing Betfairs exchange turbo blackjack for a bit of fun, i enjoy playing blackjack in casinos and have a good understanding of basic strategy, although i don’t profess to be a card counter i understand the principles of hi-lo strategy. I found that when i was playing turbo blackjack i could take what i had learnt in casinos and with patience regularly make £10 – £15 profit a session.

I am a programmer by trade so it wasn’t long before i was thinking about automating my play. From playing online poker for a few years i knew that a lot of sites didn’t like you automating your play with software, Betfair on the other hand seems to actively encourage it. Betfair provide a developers API which allows programmers to tap into the game feeds as well as place bets on the exchange, it couldn’t be more perfect!

Betfair is a not a bookmaker like William Hill, Ladbrokes or Paddy Power, it is in fact a betting exchange. When you place a bet at a bookies the liability falls on them to pay should you win. Betfair on the other will match you up with another party who is prepared to take the liability while taking a small amount of commission for themselves. This means it is in Betfairs favour to have as much activity on a market as possible, boosting bets matched and therefore boosting their commissions.

My intentions are to develop an application which will play exchange turbo blackjack for me using the Betfair API to analyse the game and identify hands which i would normally play if i was sat at the computer. Placing continuously i should be able to build a steady stream of wins, which over time will amount to a decent regular income.

This blog is me documenting my progress. I hope you enjoy it and if you have any questions then let me know.

Tom