How to make laying bot for betfair horse racing to hedge possible loss?
Posted in Bfexplorer Products by Demagog
Hello,
I am a beginner.
Help please. As I can make the following:
To choose all Horse racing of today and for 30 seconds prior to the beginning
to stake Lay on a favorite, if chances are in a range from 2 up to 4 in the sum 10 $.
And after the beginning of racing in 70 seconds if the favorite has not changed to close
this rate. Or that it is even better to make distribution of losses.
Then to pass to following racing.
Thanks.
Friday, August 20, 2010
Betfair bot script for the Bot Executor
Any software is able to execute just features the software implements, nothing more or nothing less.
The Bfexplorer PRO offers the trading bot: Place bet and close position, or just Place bet and Close position or Close position on the outcome bots, if you would like to create the chaining bot settings from the mentioned bots.
Unfortunately neither this trading bot nor bots for closing position implement the feature you require in your betting strategy, and that is to check if the favorite on which you executed a bot is still the favorite after some time expired. That means that such betfair bot script has to be programmed, so this way you would be able to extend the existing bots functionality. If you are Bfexplorer PRO subscriber I will try to find some spare time in this weekend, to program such betfair bot script for the Bot Executor.
Tuesday, August 24, 2010
Betfair bot script: HorseRacingBetFavoriteCheckPositionInPlayBot
I created betfair bot script Bfexplorer.Scripting.HorseRacingBetFavoriteCheckPositionInPlayBot extending the bot functionality of the buil-in bfexplorer bot PlaceBetBot:
public class HorseRacingBetFavoriteCheckPositionInPlayBot : PlaceBetBot { private byte runnerOrder; private bool closeMyPosition; public HorseRacingBetFavoriteCheckPositionInPlayBot( IBetfairService betfairService, MonitoredMarket monitoredMarket, Runner runner) : base(betfairService, monitoredMarket, runner) { stopWhenBetPlaced = false; if (botCanRun) { runnerOrder = GetRunnerOrder(); ShowRunnerOrder(runnerOrder); } } public override void DoYourJob() { base.DoYourJob(); if (betPlaced && !closeMyPosition && GetIsTheRaceXSecondsInRace()) { byte myRunnerOrder = GetRunnerOrder(); ShowRunnerOrder(myRunnerOrder); if (runnerOrder == myRunnerOrder) { closeMyPosition = true; } else { Stop(); return; } } if (closeMyPosition) { switch (tradingState) { case TradingState.WaitingForTrade: ClosePosition(); break; case TradingState.BackingInProgress: case TradingState.LayingInProgress: CancelAllBetsIfNecessary(true); break; case TradingState.BackingBetDone: case TradingState.LayingBetDone: AddMessage(string.Format( "Your position was closed for: {0}", betStakeCalculation.GetProfitLoss()) ); Stop(); break; default: break; } } } protected override void BotJobDone() { // Close bet type betType = RunnerProperty.BetType == BetType.Back ? BetType.Lay : BetType.Back; // The PlaceBetBot done its job DoSetBetPosition(); } protected override void DoSetBetPosition() { if (betPlaced) { BetsForSelectionStatusAndLastBetId betMatchCriteria = new BetsForSelectionStatusAndLastBetId( runner.SelectionId, runner.AsianLineId, BetStatus.Matched, lastBetId); betStakeCalculation.SetBetPositionForBetMatchCriteria( monitoredMarket, betMatchCriteria.Match); } else { base.DoSetBetPosition(); } } private bool GetIsTheRaceXSecondsInRace() { MarketDetails marketDetails = monitoredMarket.MarketDetails; return marketDetails.IsInPlay && DateTime.Now >= marketDetails.MarketStarted.AddSeconds( RunnerProperty.MinOddsDifference); } private byte GetRunnerOrder() { RunnersSortedCollection runners = new RunnersSortedCollection(); runners.SortByType = RunnersSortedCollection.SortType.ByLastPriceMatched; runners.Initialize(monitoredMarket); long myRunnerId = RunnerId; byte myRunnerOrder = 1; foreach (Runner myRunner in runners) { if (myRunner.Id == myRunnerId) { break; } else { myRunnerOrder++; } } return myRunnerOrder; } private void ShowRunnerOrder(byte myRunnerOrder) { AddMessage(string.Format("The runner order is: {0}", myRunnerOrder)); } private void ClosePosition() { BetPrice betPrice = betType == BetType.Back ? runner.BestPriceToBack : runner.BestPriceToLay; if (betPrice != null) { double odds = betPrice.Price; double stake = betType == BetType.Back ? betStakeCalculation.GetStakeAmountToBack(odds) : betStakeCalculation.GetStakeAmountToLay(odds); PlaceBet(betType, odds, stake); } } }You can download the source code of this betfair bot, unzip and copy the betfair bot script file into the MyBots folder.
The bot uses all parameters the PlaceBetBot and additional parameter: MinOddsDifference, where you have to set the time at which bot checks the runners order and eventually closing your position.
Set the MyBot parameter MyBotClassName to:
Bfexplorer.Scripting. HorseRacingBetFavoriteCheckPositionInPlayBot
Wednesday, August 25, 2010
Hello,
I have made all as you have written, but unfortunately the robot with a name "HorseRacingBetFavoriteCheckPositionInPlayBot" in the list has not appeared.
You could not describe in more detail as I should start this robot?
Thanks.
Wednesday, August 25, 2010
Test any new betfair strategy in the bfexplorer practice mode
I actually left the link to other articles which describe use of betfair bot script.
http://bfexplorer.net/Search.aspx/ForumArticles?searchText=MyBotClassName
On the site you can find as well how to use this bot in fully automated solution utilizing either the Trade opportunity lookup tool, or the Execute my strategy on selections tool.
You can execute the bot manually using the tool: Bot Executor.
Make first test in the practice mode only, and I hope you know what your strategy requirements are, as you want to run your strategy at in-play markets where odds moves very rapidly.