Tag Archives: automated betting

Interesting test results

I’ve been recoding my horse racing form bot (Bot 3), trying to get it to work without errors. It scrapes a lot of data for each race – runner form, jockey form, track data, going, weather. Having got it to a point where it runs okay with me sat in front of it, I decided to run it live on the VPS but without placing bets, allowing performance and data collection checks. To keep things separate I’m running this on Betdaq with a slow refresh and, as I’ve not used it for a while, I’ve added a short section of code to place some pointless bets based on where the market odds are, nothing to do with the bots purpose but hopefully keeps the exchange happy.

The results so far are good and the bot is gathering most of the data without error. Any missing data isn’t causing the bot to stop, however, I’d like it to make multiple attempts to gather it, so some adjustments are needed. The algorithm for choosing a selection to back or lay is operational but requires refining. I’m basically calculating my own ‘betting forecast’ and backing or laying a selection depending on how far away from my suggested odds it is trading.

The interesting part comes from the short bet placement code I added. Of the 12 bets it placed over the five days testing, only 1 of the selections won. Obviously I’d backed them all.

 

My theory for this code was – if I place bets in efficient markets (which I thought close-to-off horse racing markets were), I will likely lose at a rate around my commission (5%) plus half the spread position. Therefore stakes of £0.1 are a small price for testing.

I know the small sample is hardly proof but with average odds of 3, none greater than 3.5 and results at 12, I’m going to keep this little code running to see how it pans out and update the blog on results. It will be interesting to find out if I just happened to drop into the strategy during a 10 long losing streak.

My bot data

I was asked about my data here and here. This is the data I collect:-

MyDataExample

My bot collects data from each opening trade placed, attempted opening trade (unmatched) and when the market meets approx 90% criteria. The trigger includes a stoploss and tick-offset which are fired in response to the market so I don’t have any data relating to the point that they are placed.

I also record market suspension to help with analysis. I don’t record any other data about the market. If no trades are made in a market, I have no data.

The columns are as follows-

MyDataExample2

A = Market

B = Market ID

C = Time at last refresh

D = Seconds to off

E = Selection name

MyDataExample3

F thru Q = Best 3 back/lay prices (F,H,J,L,N,P) and volumes (G,I,K,M,O,Q)

MyDataExample4

R = Last price matched

S = Total matched for this selection

T = Trigger

U = My requested price

V = My stake

W = Total matched for this market

X = Timer output (time it takes for my code to run using excel’s timer)

The problem with data is how much is available. I’ve tried recording whole markets but you soon end up with megabytes of data that means nothing without refining. You first need an idea of what you want to find and then go about collecting the relevant data. For instance, I only record the data for my selection, not the other runners. You may only need data for the last 3 minutes before off, or only in-play, depending on how you want to trade. You could record prices in the morning and then at the off to look for trends. Without knowing what you want to target, data on its own is not much use. Because my data is so specific to my bot, it wont be any use to others without knowing the algorithm that picked it out.

EDIT:- below is a file of data recorded from one race. As Gruss passes the market to excel, I recorded each refresh to a sheet for each race. I only did it for a few days due to the size of the files. It’s about 280KB and taken from a day file which was 150MB in size.

recorded-data-to-share1

 

Week ending 03-07-16

Here are last weeks charts. Both performed well overall with similar mid week dips. The ratios are above average for both markets.

I’m going to leave the stakes as they are for now, having reduced them after previous losses. they are still a percentage of bank so will increase (or decrease) with balance.

Also, no US racing for now until I’m happy with dogs and Aus.

On a different note, these charts were produced automatically using VBA. The data is saved from Betfair in two files for each market and I’d been manually sorting, calculating and creating the chart. After a few hours learning some new techniques, I can download the P&L and History files, open the P&L and run a macro. Less than a second later and the chart is created, exported and saved in a separate file, ready for the blog. I really like automation .

160703

 

Aus160703

Weeks ending 26-06-16

My time is a bit limited with our new arrival (revealed here), which is why it’s been a month since my last results.

As I wasn’t keeping an eye on the bot, it went on a losing streak, hitting the minBalance level and stopped trading. Due to a coding error created after the previous error, Aus trading was also interrupted. After about a week of no trading, I finally noticed and restarted the Aus markets but left the  UK and US paused until I could look into any cause.

Having looked through all my data I can’t find any reason for the losses beyond “that’s what happens, win some, lose some”. Downward trends are to be expected as much as upward trends in the short term. I restarted the UK markets with reduced stakes at the beginning of the week. Time will tell.

160610

The trading that the Aus markets produced was below recent returns but positive.

Aus160623

I know why the US markets stopped trading before the others, the minBalance is set different and is auto adjusted periodically. However, this only auto adjusted upwards and didn’t cope with a loss just after adjustment – there wasn’t enough room to allow for regular losses and another error meant excel hit a run time error.

US160605

Weeks ending 29-05-16

These charts cover a two week period. The obvious feature in the UK chart was reported here. It was a loss of £58.51 on a losing Lay bet placed in error. The interesting thing is that for the period, the overall return only amounts to -0.078% of turnover. As a single event, it takes the greyhounds “bank” back to where it was on the 29th April. It could be worse.

160529week

The Aus markets performed well generally. Again there is a, relatively, large loss. I hadn’t noticed this until I did the chart but after what happened on the greyhounds I thought I’d look into it. The events leading to the loss of £5.70 were identical to those above. The trend without this is good though.

Aus160529week

The US markets have not done too well but I am not giving up on them just yet. They haven’t traded since the loss on the dogs due to a minimum balance limit being different for the US, which I hadn’t noticed. I’m going to make some fine adjustments to the entry triggers before restarting.

US160529week

Oscar has returned

After a short holiday caused by this event, Oscar is now back at work, emotionless but committed.

Mike suggested using the Take-SP option to avoid missing trading out.

BPT commented he’d previously used Back at 1.01 and Lay at 1000 to catch the best available odds.

As a way of getting the bot going again, it was quite easy to replace the 2nd-next-best-price with 1.01 and 1000, so this is what I’ve done for now. This is only a temporary fix as the greening is still calculating one refresh behind.

As I improve the greening code, I will include the Take-SP as a last resort. I think this is better as, although the odds may be off, it is taken straight away without entering the market directly. With the code improved, the use of this should be less often anyway.

Back off hols

Oscar needs a holiday

A large loss occurred today as a result of a bet placed in error. Although I’ve seen this before, the size of the loss made me investigate the problem.

Nearing the off time my bot stops trading and then there’s a break of 10 seconds to allow any bets placed to be matched. Then a greening algorithm runs 3 times, first to green at the available odds, then at 1 tick worse than available odds, finally at 2 ticks worse than available odds. The idea is to reduce any risk of leaving a bad position open.

On today’s event the first attempt placed a lay in error. This left 2 attempts to hedge out. Unfortunately both failed. Looking over my code, the greening part is probably the oldest. A quick look on the Gruss forum and the example code has been updated a few times, without me keeping up. The code I use is greening on old data. The most recent code greens on current data.

As the possibility of a similar error exists, I’m not prepared to carry on trading until I’ve fixed this code. Due to the amount of change required and testing I need to do, I’ve stopped Oscar and his American brother for now. Hopefully the coming Bank Holiday weekend will provide some opportunity to make the fix.

Hols bot

 

Trading mistakes

In reply to this post by Betfair Pro Trader, here are some mistakes I’ve made (I’ll keep it to trading else this could be quite long).

When I first started manual trading, there were the usual mistakes, jumping in after the move, trading just to be “in”, letting losers run, going in-play and the rest. My greatest (most costly) mistake was, after slowly building a decent bank, thinking that there must be something to the in-play markets. So off I went, both feet and brilliant, more money in one race than ever before. Then the next race, again big win. This was the way. I was writing my notice to my boss, booking a test drive and browsing the Seychelles. Next up, crash bang broke. How did I let this happen? Well, like Homer retrieving cans from a power line, surely doing the same thing again will result differently. It didn’t. After not making it to in-play millionaire status I returned to the less violent arena of pre-off trading, where I still dwell. The move to automation was due to an interest in coding, lack of time during the trading period and an idea that it would produce better consistency.

The mistakes in automation have been less costly. Usually due to rushing code into service or, early on in this adventure, making changes after only a few results. The way for me now is to code efficiently, test thoroughly and implement in stages. No rush for the long term.

There’s an easier way

When I download the bet history from Betfair, the “Bet placed” data is only to the minute and I need to know to the second to have any chance of matching up with the bet entry data. This is why I’ve been testing some new code trying to handle the MyBets data which seems to come in different on each update. It’s recording some rows of data multiple times which I can’t figure out but am sure is due to the jumbled nature in which it’s received.

But then, that little voice reminded me that when I view bets on my mobile, it does include the second it was placed. So I had a look at Betfair, again, and there it is, in My bets. Easily downloadable and workable.

This is how I was getting data from Bet History –

BetHistory mins

 

And this is how it comes from My bets, a bit more accurate –

BetHistory secs

 

I’ll try matching this with my bet entry data, only problem I can see is Betfair’s time and my time being different but I might be able to offset it. Something for another day now.