Dutching and then hedging automatically
Posted in Betfair bot for this week, algorithm and strategy by formbet
Something I like to do is pick 2 or sometimes 3 horses in each race to 'dutch' from the top 2 or 3 on my ratings ie. secure a profit no matter which one of the 2 or 3 selections wins.
However, I often take this one step further by putting a lay bet 'in play' on each of the dutched runners, say at a fixed price of 1.31 for exampe to recoup the entire dutch stake. This way, if one of the horses gets in contention, then gets matched at 1.31 and for some reason goes on to lose the race, I have made sure I get back the entire dutch stake. If it goes on to win then I reduce my profit but this is something I am willing to sacrifice. Sometimes even 2 selections will get matched at 1.31 and one goes on to win so you actually make more profit. It is quite a good strategy but quite time consuming to do race by race so I would love to automate it.
So my idea of an example bot would be the following -:
1) Input a list of 2 or 3 horses in each race.
2) 2-3 minutes before each race, have the bot automatically dutch the runners for a set stake, say 20GBP at the current back odds.
3) Once dutch bets have been matched then place a lay bet 'in-play' on each runner at 1.31 for 20GBP.
This sounds quite complicated but it is something I do manually at the moment so I would imagine that it could be automated somehow. I look forward to seeing if it can make 'bot of the week' and if any other questions please ask.
Dave
Tuesday, September 08, 2009
Betfair bot for dutching and hedging
Actually is more suitable to implement this betfair bot strategy by some bespoke solution, simply because you have to select your horses you want to dutch and then an action bot, in this case the dutching bot must take some way your selections and place dutching bets on them.
The Bfexplorer PRO tool: Execute my strategy on selections supports similar feature, but in this case using of your selections was meant by a slightly different way. An action bot is executed on each selection, when dutching we need selections and only one action bot.
So betfair bot script when executed by the tool: Execute my strategy on selections, has to read the list of selections you want to dutch and blocks execution of the rest of bots. After dutching bets are fully matched and market is turned at in-play bot places lay bets at preset odds.
What is not so clear in your specification is dutching type, as you can dutch by: required profit, total stake or payout. Your hedging criteria is not so clear as well, because dutching stakes depends on odds, so just hedge by the same stake, total stake to dutch could get different results:
Bot uses following parameters:
The dutching calculation uses Stake parameter as required profit. You can download the source code of this betfair bot.
Tuesday, September 08, 2009
Dutching / Recoup stake critera
Many Thanks Stefan
I managed to execute the bot ok 'eventually' although I notice it is placing 2 lays in running on the same horse instead of on both runners, can this be fixed ?
To answer your questions, what I was exactly after was the following...
I would have liked to have dutched by 'total stake' so that I am staking the same amount in each race.
As far as the lay is required I would just like to lay 'both' horses at 1.31 for the total dutch stake.
So for example...
Total Dutch Stake = 20pts
Horse A 5/1 = 13.33pts
Horse B 10/1 = 6.67pts
Then when bets are matched place 2 lays in-play....
Horse A 20pts lay 1.31
Horse B 20pts lay 1.31
So not exactly hedging...but if one horse hits 1.31 and actually loses, you at least get stake back...hope that makes sense and thanks again for your work on this.
It will make my life easier to dutch my top-rated runners automatically :-)
Dave
Tuesday, September 08, 2009
The betfair bot source code
I do not think there is any problem in the code, just have a look at method: PlaceHedgingBets
private void PlaceHedgingBets() { BetType betType = RunnerProperty.BetType == BetType.Back ? BetType.Lay : BetType.Back; double odds = RunnerProperty.Odds; double stake = RunnerProperty.Stake; int marketId = MarketId; List bets = new List(); foreach (Runner runnerToBet in runnersToBet) { BetBase bet = new BetBase(marketId, runner.SelectionId, runner.AsianLineId, betType, odds, stake); bets.Add(bet); } PlaceBets(betType, bets); }Tuesday, September 08, 2009
Hmm strange, I'm not that familiar with code (still have to learn) but I notice also in your example above the screenshots it placed 2 lays at 1.31 on the same runner Blue Ridge Lane so I am not sure why this is happening ?
Dave
Tuesday, September 08, 2009
Yes you are right, it should be: PlaceHedgingBets
private void PlaceHedgingBets() { BetType betType = RunnerProperty.BetType == BetType.Back ? BetType.Lay : BetType.Back; double odds = RunnerProperty.Odds; double stake = RunnerProperty.Stake; int marketId = MarketId; List bets = new List(); foreach (Runner runnerToBet in runnersToBet) { BetBase bet = new BetBase(marketId, runnerToBet.SelectionId, runnerToBet.AsianLineId, betType, odds, stake); bets.Add(bet); } PlaceBets(betType, bets); }Tuesday, September 08, 2009
Sorry Stefan,
I must be missing something...both code above looks the same. I was expecting it to place a lay for the total dutch stake on both runners so that if any one of them hits 1.31 the stake is recouped.
Also how to change to total dutch stake across 2 runners instead of target profit ?
Sometimes both horses get matched at 1.31 which is a double bonus as you get a stake back on both horses ;-)
Thanks again
Dave
Wednesday, September 09, 2009
Betfair bot source code for dutch calculation for total stake
As I said my code implements three types of dutch bet calculation. If you want to dutch for total stake use following code:
private bool DoPlaceDutchBets() { DutchingCalculation calculation = new DutchingCalculation(monitoredMarket.MarketId, runnersToBet); BetType betType = RunnerProperty.BetType; /* bool status = calculation.CalculateForRequiredProfit(runnersToBet, betType, RunnerProperty.Stake); */ bool status = calculation.CalculateForTotalStake(runnersToBet, betType, RunnerProperty.Stake); if (status) { PlaceBets(betType, calculation.PlaceBets); } return status; }Wednesday, September 09, 2009
That works perfectly, thanks for explaining and for the quick response Stefan...much appreciated.