Clon
How to program a bot to save betfair charts
Posted in Bot programming by StefanBelo
Yesterday I read this Czech blog that discusses the use of betfair charts to analyze different betting or trading strategies. It is quite easy to program such betfair bot, so here there is my code:
class SaveBetfairChartsBot : Bot
{
private const string ChartFolderName = "My Charts";
private const string BetfairChartUK = "http://uk.site.sports.betfair.com/betting/LoadRunnerInfoChartAction.do?marketId={0}&selectionId={1}&asianLineId={2}";
private const string BetfairChartAUS = "http://au.site.sports.betfair.com/betting/LoadRunnerInfoChartAction.do?marketId={0}&selectionId={1}&asianLineId={2}";
private string chartsFolder;
public SaveBetfairChartsBot(IBetfairService betfairService,
MonitoredMarket monitoredMarket, Runner runner)
: base(betfairService, monitoredMarket, runner)
{
chartsFolder = Path.Combine(
betfairService.ApplicationDocumentPathName,
string.Format("{0}/{1}", ChartFolderName,
DateTime.Now.ToString("yyyy_MM_dd")));
if (!Directory.Exists(chartsFolder))
{
Directory.CreateDirectory(chartsFolder);
}
}
public override void DoYourJob()
{
base.DoYourJob();
string myChartsFolder = Path.Combine(
chartsFolder,
monitoredMarket.Description.Replace(':', '_'));
if (!Directory.Exists(myChartsFolder))
{
Directory.CreateDirectory(myChartsFolder);
}
int marketId = monitoredMarket.MarketId;
string betfairChartUrl =
monitoredMarket.ExchangeId == ExchangeId.UK ?
BetfairChartUK : BetfairChartAUS;
foreach (Runner myRunner in monitoredMarket.MarketDetails.Runners)
{
SaveRunnerChart(myRunner, marketId, betfairChartUrl, myChartsFolder);
}
ShowMessage(
string.Format("Saving charts for the market: {0}",
monitoredMarket.Description));
Stop();
}
private void SaveRunnerChart(Runner myRunner,
int marketId, string betfairChartUrl, string myChartsFolder)
{
ShowMessage(myRunner.Name);
try
{
WebRequest request = WebRequest.Create(
string.Format(betfairChartUrl,
marketId, myRunner.SelectionId, myRunner.AsianLineId));
using (WebResponse response = request.GetResponse())
{
using (Image image = Image.FromStream(response.GetResponseStream()))
{
image.Save(string.Format(
Path.Combine(myChartsFolder,
string.Format("{0}.png", myRunner.Name))), ImageFormat.Png);
}
}
}
catch (Exception exception)
{
ShowMessage(exception.ToString());
}
}
private void ShowMessage(string message)
{
betfairService.AddMessage(message, monitoredMarket.MarketId);
}
}
You can download the source code here, unzip the file and copy the betfair bot script and xml file to MyBots folder.
Bfexplorer PRO 2 - Place bet
Posted in Popis betfair robotov by Mir.
V Bot Criteria Editoru nastavím základní typ robota a to Place Bet. Je to robot co na základě podnětu (automatické či ruční spuštění) a za předpokladu splněných podmínek v Market Criteria a Selection Criteria umístí sázku na trh.
Nastavení:
Bot criteria name - uživatelské jméno robota. Robota si pojmenuj s ohledem na jeho užití a jeho vlastnosti. Jméno bude vidět v seznamu v okně Bot Executor. Jméno je používáno také pro spouštění složitějších akcí (např. když potřebuješ provést 4 různé roboty za sebou, jednoduše napíšeš pořadí jmen do spouštěče (Chain Execution) a oni se podle pořadí vykonají)
Bot Setup, Market Criteria, Selection Criteria - záložky Market Criteria a Selection Criteria jsou vysvětleny v tomto článku. Bot Setup je konkrétní nastavení robota. Tedy přesně CO bude vykonávat.
Bet - sázka
- BetType - typ sázky, který má robot umístit - Back nebo Lay.
- Maximum Odds - maximální kurz, na který bot umístí sázku.
- Minimum Odds - minimální kurz, na který bot umístí sázku.
- Odds - přesný kurz.
- PlaceBetInAllowedOddsRange - umístit sázku do zadaného rozsahu kurzů. Pokud je nastaveno True, tak je robotovi povoleno umisťovat sázky do zadaného rozsahu mezi kurzy Maximum Odds a Minimum Odds. Pokud je nastaveno False robot umisťuje sázku přesně na kurz zadaný v parametru Odds.
Bet attribute - vlastnosti sázky
- AllowPlacingBetInPlay - povolit umístění sázky v režimu In-Play; True - robot umístí sázku i během průběhu zápasu, dostihu atp., False - nikoli.
- AtInPlayKeepBet - Betfair všechny sázky umístěné na trhu při přechodu do In-play ruší. Pokud nastavíš parametr sázky AtInPlayKeepBet na True sázka se nezruší a zůstane jako nabídka i dále v průběhu zápasu.
- ChaseOddsTimeout - čas pro aktualizaci neuzavřené sázky; 00:00:10.5 - sázky se aktualizují každých 10,5sec
- MaximumOddsDifference - maximální rozdíl nabízených kurzů BestOddsBack vs. BestOddsLay
- MinimumOddsDifference - minimální rozdíl nabízených kurzů BestOddsBack vs. BestOddsLay
- PlaceBetOnBetterOdds - umístit sázku na lepší kurz; Nastavením na True nabízí robot Back sázky na nejlepší Lay pozici a Lay sázky na nejlepší Back pozici.
- PlaceBetOnOddsBehindOfferedAmount - umístit sázku až za (postupně sečtenou) nabídku na trhu.
- Price Improvement - posunutí sázky o +/- x [ticks]. Variabilní použití ... více v příkladech.
Selection - výběr, příležitost
- ExecuteOnSelection - spustit na selection; 0 - aktuální výběr, 1 - favorit, 2 - druhý favorit, 3 - třetí favorit atd. Řazení je podle nastavení v záložce Market Criteria > Sort Selection By ... Pokud nastavíš Sort Selections by Probability to loss a nastavíš ExecuteOnSelection = 1, robot se spustí na posledním outsiderovi (řazeno od nejpravděpodobnějšího losera a první v tomto řazení).
Stake - sázka
- Stake - sázka; výše sázky v měně účtu.
Stake attribute - vlastnosti sázky
- StakeIsMyLiability - sázka je moje riziko. Nastavením na True riskuješ maximálně do výše sázky Stake; např. Stake = 100, riskuješ tedy maximálně 100euro a pak tedy Lay sázka na kurzu 4,40 bude 29,41euro.
- StakeIsPercentageOfMyBank - sázka je procento z mého banku; Při nastavení na True robot vezme hodnotu Stake jako procento z celého dostupného banku. Např. Stake = 15, sázka bude 15% z banku 300euro tj. 45euro. Pokud bude zároveň Stake is my liability = True, bude z hodnoty 45euro maximální částka, kterou riskuješ.
Time - čas
- PlaceBetOnTime - umístit sázku v čase; možnosti: -00:01:30 = 1minutu a 30sec PŘED oficiálním začátkem, 00:02:20 = 2minuty 20sec PO oficiálním začátku.
- PlaceBetOnTimeEnabled - nastavení False - sázka se umisťuje vzhledem k času okamžitě (ale samozřejmě až po splnění ostatních podmínek). Nastavením True, sázka se umisťuje v nastaveném čase u parametru PlaceBetOnTime.
Příklady:
PlaceBetOnOddsBehindOfferedAmount = 100; sázka se umístí až za postupně sečtenou sumu.

Price Improvement - posunutí sázky.
Best Odds Back je kurz nabízené sázky, na kterém když chci Backovat mohu okamžitě uzavřít. Best Odds Back PlaceBetOnBetterOdds je umístění mojí Backové sázky na lepší kurz a to na úroveň nejlepší Lay sázky. Price Improvement funguje jednoduše tak, že posune sázku z původní pozice na novou a to o +/- počet ticků.
Výchozí kurz Best Odds Back PlaceBetOnBetterOdds = 3,90. Price Improvement = 3 posune mojí Back sázku na 4,10 a Price Improvement = -2 posune sázku na 3,80. (pozn.: záporná hodnota Price Improvement na kurzu Best Odds Back by umístila sázku na 3,55. Nicméně podle pravidel Betfairu dojde k uzavření Backové sázky již na "lepším" kurzu a to na 3,65 pokud tam bude dostatek prostředků)
Stejná pravidla fungují pro LAY stranu. Kladná hodnota parametru Price Improvement posunuje do "hodnotnější" pozice. U Backový sázek na Ladderu nahoru a u Layových sázek dolů.

MinimumOddsDifference / MaximumOddsDifference:
OddsDifference je rozdíl mezi BackOddsBack a LayOddsBack. Na obrázku výše je rozdíl 5 ticků.
Pokud nastavíš limity MinimumOddsDifference = 1 a MaximumOddsDifference = 4, sázka se nepodá, protože 5 není v povoleném rozsahu. Parametry nemusíš zadávat, nebo můžeš zadat pouze jeden. V nastavení MinimumOddsDifference = 0 a MaximumOddsDifference = 1, robot sázku nepodá dokud bude na trhu mezi kurzy mezera (GAP).
What is new in Bfexplorer PRO 2
Posted in Bfexplorer Products by StefanBelo
Bfexplorer PRO 2 (Bfexplorer PRO version 4.0) offers the new Bot Executor with more flexible betfair bots:
Bfexplorer Bots
- Place bet
- Be the first in queue
- Place bet by drip feeding
- Dutch selections
- Place bet and close position
- Be the first in queue and close position
- Place bet and trailing stop loss
- Tick offset
- Scratch trade
- Close Position
- Close position by trailing stop loss
- Close Position on outcome
- Close Position at odds
- Close Position on market
- Chase odds
Bfexplorer Bot Executor Bots
- Execute a bot on selections
- Execute a bot on associated market
- Chain execution on selection
- Chain execution on market
- Concurrent execution on selection
- Wait for profit or loss on selection
- Wait for profit or loss on market
- If profit then else
- Bot selector
- Bots executor
- Set bot parameters
- My bot
- My market bot
Bfexplorer Community Bots
- Odds trader
- Selection notifier
- Event notification
- Notify me
- Place pair bets
- Place bets
- Place bet only on my odds
- Place bet till time
- Place bet or take partially matched
- Place bet for required profit
- Dutch event selections
- Trigger a bot by odds trend
- Trigger a bot when market turns in-play
- Trigger a bot by betfair starting price
- Trigger a bot by betfair starting price favourite
- Close position on what is offered
- Close position at odds and percentage stake
- Stop at a winner
- Football bot executor
- Trigger a bot by market name
- Lay a horse
The ladder - visualization of odds at which a bot should close position in profit or loss.
My Bets - grouping of matched bets by selection.
Market Grid View - stop bot and cancel bets icon, visualization of active bots on a market.
Tools " Trade opportunity lookup " and "Execute my strategy on selection" - support for new betfair bot. Live scores for football matches support for betfair bots. Horse racing form support for betfair bots.
Bot executor offers, combining a new betfair bot without programming.

Bfexplorer plug-ins
- All My Bets
- Betfair Coupons
- Betfair Coupons - Football
- Betfair Coupons - Tennis
- Bfexplorer To Excel
- Close All Positions
- Debug My Bot
- Dutch Market Selections
- Horse Racing Browser
- Horse Racing Database
- Market Betfair Charts
- Market Bot Executor
- Market Charts
- Market Data Visualiser
- Market Statistics
- Market Visualiser
- My Account
- NinjaTrader Betfair Data Feed
- What If Scenario
To install Bfexplorer PRO 2 click here.
NinjaTrader - Best prices
Posted in General Betting by max
Hello
I configured NinjaTrader as described and it works. Interface indicators for NinjaTrader is similar in Bfexplorer so it looks as though these two programs were created for themselves. In this program, there are many options and certainly the analysis will take some time but I like charts and become acquainted with this very willingly.
I have a question regarding the tools NinjaTrader Betfair Data Feed. There is the option Use best prices only which if I understand it uses data in 3 Best Back Price and 3 Best Lay Price? So if I disable this option is for what range will be data feed?
Regards
Tick offset - both profit and loss
Posted in General Betting by max
Hello
What this exactly means that bot has both profit and loss closing feature? I think I understand what it means but I'm not sure how it works in this bot. If for example I have set:
BetType: Back
TickOffset: 1
Does this mean that if I bet on the odds 4.5, position will be closed if:
Loss Odds: 4,6
Profit Odds: 4,4
If this is closing of positions in profit works well but seems to me that position on a 1 loss tick is sometimes closed but not always or not immediately. Maybe it's good because I did not know about this feature before and I was able to run on a 1 loss tick bot Close position on outcome. It would be well-read explanation of what exactly is in this case both loss and how it works.
Regards
Implementing a custom bot. Guidance for a beginner..
Posted in Bot programming by maonj
Hi Stefan
Is there any documentation about the SDK, e.g. tutorials, getting started, API docs, that will help me better understand how to write custom bots for my needs? I've watched the video screencasts but I'm still not clear on what all the different classes do, and what the difference is between MyRunnerBot and MyMarketBot. I've also had a look through the sample scripts but none of them do anything like what I require:
Specifically, I want to write a bot which will place initial bets just before an event begins and then continuously monitor changes to the event (e.g. in-play live scores and live market odds) and make new bets, adjust bets and close bets according to my custom rules throughout the game. So the bot also needs to keep track of when the game begins so I can leave it running long before the game starts.
Any help or advice would be greatly appreciated.
Thanks
how to run standard bot from my bot
Posted in Bot programming by mapper
Hi Stefan and all,
I have starting to learn BFE SDK. I have created a set of conditions in my bot. Current output is runner with price and bet type (back/lay). I want to run standard built bot Place bet & close position (it's suitable for me) but I do not know how to trigger this bot (with parameter of bet type) from my bot. Could somebody help me?
situation:
my current bot check rules. if some rules are matched I want to LAY. If other rules are matched I want to BACK. For both cases I want to use PB&CP with the same parameters (only bet type is depend on previous rules).
Thanks in advance for you ideas and help!


