-
Bets
Hello, I am still using trial version, I have money on my Betfair account and would like to try to stake. However, in practice mode I am able to stake but not in live mode. Account is connected. In left bottom corner shows my cash balance
5.1.2026 9:05:39
-
Bfexplorer Latest Release
Version 4.10.1227
The cumulative updates for net 10. Install from Bfexplorer Preview version.
Version 4.08.1010
The cumulative updates. Install from Bfexplorer Preview version.
Version 3.34.0704
WeightOfMoneyData provider for ...
27.12.2025 20:36:17
-
8 Essential Data Contexts Available for Betfair Market Analysis
Just documented the comprehensive data contexts available in our Betfair trading system. Here's what we can analyze:
🏇 OLBG Racing Tips - Professional tipster confidence ratings and analysis📈 Custom Performance Metrics - In-play ratings, trends, and win ...
26.7.2025 19:03:01
peteresgate@outlook.com
So do you mean something like this?:
let betSize(bet : Bet) =
bet.Size
let getBetSize() =
if selection.Bets |> Seq.exists (fun bet -> bet.OrderStatus <> BetOrderStatus.Matched && bet.BetType = BetType.Lay)
then
let price = selection.Bets |> Seq.map betSize |> Seq.head
This is the correct way? Is there not a way to do something like selection.Bets.Size or selection.Bets.Price or selection.Bets.BetType etc?
Betfair Bot
Any code, in any programming language is “sentence” expressed by programming language “words” and constructs you can make by programming, adds the language vocabulary.
So the vocabulary you can use to express your intentions in programming language is limited to couple words.
The above line of code:
let Stake = _selection.GetPriceSize(BetType.Lay)
In human sentence expresses:
Selection, get PriceSize object for Lay side to stake!
As English have strict words order in sentence, to be grammatically correct, we command so exclamation mark at the end of sentence.
So you command selection to get PriceSize, and in this context it is Lay PriceSize offered. It is not bet, it is offer on this selection other bettors placed.
You can command bet object to get price or size to you, so odds or stake you placed a bet with.
So you must ask/command _selection.Bets to get all unmatched bets to you (to value), and then ask a bet to get you price, size and so on, like I did in my bot trigger code:
BetStatusBetCancellingBotOrchestrationBotTrigger.fsx
on the line 31.
***
Read further only when you want to learn some advance features of F# programming language.
***
I do not know in what context you use _selection, but please keep in mind that in F# underscore _ is used as intention to declare not used value, because in F# you must declare exact intention, so like in mathematics it does not make sense to express something what is not used.
Yes, in other programming languages, programmers used to declare object variables with _, but in F# it has different meaning, for instance here:
ShowPriceTradedVolume.fsx
On the line 52, where I declared construct for BetStatusBetCancellingBotOrchestrationBotTrigger type, I used _ for not used values, because in F# any input value/s in constructor are declared as well as object values you can access not only in constructor but in entire type.
On the line 106, you can see __ (two underscores), so in type member you must type __ to declare not used self-identifier of object. I use this as self-identifier, but you can use whatever word/character.
Ok, this underscore issue is for advance developers, you code will work whatever you will use.
***
Option value
***
For the option types/values it is similar like in C# for Nullable. So you can use anOptionValue.IsSome and if is some you can get value by: anOptionValue.Value, but better way is to use match expression or functions from Option module, like Option.iter.
In my code you can find maybe, computation expression I created, so for options you can type simplified expressions, for instance here:
ShowHorseData.fsx
Lines from 39 to 43, and then on line 40, let! ... actually evaluates if mySelection.MetaData.IsSome and continues only when it is assigning to metaData the value, otherwise returning None.
Such expression allows me to write less code. Programming is not about writing a lot of code, actually less code is always better approach.
Programming is about understanding of context in which you write the code, and so it is about interpreting of “words”.
peteresgate@outlook.com
Maybe GetPriceSize is not the code I'm looking for? When a bet is matched or partially matched, it has the Stake that is matched and the odds it is matched at. So the code I am looking for that you have questioned is to find the stake amount that is matched. Thanks
Betfair Bot
Peter may I ask you to explain me by your own words, how do you understand this line of code?
let Stake = _selection.GetPriceSize(BetType.Lay)
As you may know, and now I speak not about programming languages, but about languages, my mother’s language is Slovak, and in many Slavic languages there is no such strict rule for word order like in English sentence.
That is the funny part in your question, because well my understanding of any language construct is a little bit different from the way only English people could read the code, the sentence.
Well, yes I understand what you want to try to do in your code, but the “words” you chose to do so are quite unclear for me.
peteresgate@outlook.com
Thanks for the info Stefan. I am trying to use the info for a selection like this:
let UnmatchedLayBets () =
if _selection.Bets |> Seq.exists (fun bet -> bet.OrderStatus <> BetOrderStatus.Matched && bet.BetType = BetType.Lay)
then
let price = _selection.GetPrice(BetType.Lay)
let Stake = _selection.GetPriceSize(BetType.Lay)
if price > 10.0
then
outputMessage (sprintf "Unmatched Price > 10: %.2f " price )
But the error exists because the result is a float option. I have tried to find how to cast the float option to float so that I can use the result in calculations but have not found how to do it yet. How would I return the stake and price as a float so that I can use it? I'm sure this is an easy question for you but I have been pulling my hair out over this.
Betfair Bot
this. is used to access object properties or methods.
You type your code as you would access static method or type. You must type object, so in this case maybe: market.MarketInfo.StartTime
Betfair Bot
You can access market’s bets or selection’s bets directly (line 76 and 31), and for matched bets you can access BetPosition property, the line 79 and 34.
BetPosition type/class allows you to calculate hedge stake and so on, have a look at on the type methods.
To cancel bets you can use TriggerResult.CancelBets, the line 150.
I already mentioned that the better way is to orchestrate existing bots to execute parts of your strategy, for instance you set trading bot and all bet placing/updating or cancelling your bets is then managed by this trading bot.
In my bot trigger I showed what you asked and created such simple bots’ orchestration:
BetStatusBetCancellingBotOrchestrationBotTrigger.fsx
Please watch my video. To show how to cancel bets, I set my action bot: “Back 1 tick better”, so bot offers 2 Euro back bet 1 tick over best offered price. When odds changes and are in allowed odds range Minimum/MaximumOdds, the bot updates its unmatched bet to always offer its back bet 1 tick over the best offered, set by the parameter: PriceImprovemnt.
Now, in my bot trigger I cancelled unmatched bet on my selection, the line 150. But what happened?
As the bet was placed by my action bot, and the bot is managing its bets itself, the bet was again placed.
What does it mean?
If you place your bets by action bots, you do not need to manage bets placed by the action bot, but of course if you do not want your unmatched bets be offered on the market anymore, you need to stop the action bot, and as the action bot managing its bets, the unmatched bets will cancel its bets when you end its execution, the line 160.
It is really better way to orchestrate action bots in your bot trigger than managing bet status in your bot trigger.
Well yes, if you want to place your bets directly then you can do so, you have got:
TriggerResult.PlaceBets
TriggerResult.CancelBets
Let’s say you have got strange trading strategy, where you setup the trading bot:
"Place Bet and Close Selection Bet Position"
To offer bet 3 ticks from best offered price, and close its bet position with profit of 3 ticks, or 5 ticks to lose.
You would setup two versions of this trading bot one offering back and the other one lay bet. In your bot trigger you would execute such pair of trading bots on 3 favourites when some conditions occurred.
Now imagine what you would have to program to manage such complex trading strategy in your bot trigger by directly placing your bets.
Betfair Bot
Here is my bot trigger code:
ShowPriceTradedVolume.fsx
Please watch video, showing how to use IntelliSense to browse available code.
peteresgate@outlook.com
Edit,
When I say at +/- 2 levels, I mean the matched volume at a price (which I will use the price at +/- 2 levels because I know those prices
peteresgate@outlook.com
This is the code I am using to try and find Matched Volume at levels:
https://github.com/PeterEsgate/BfexplorerTestBots/blob/master/MarketDepthMatched
and I use it by:
let test = getMarketDepthMatched(BetType.Lay) (MYSELECTION) 1
outputMessage (sprintf "matched data %.2f" test)
But this causes Bfexplorer to "hang" and I have to cancel the bot
For my bot, the last 2 things I need is to find the matched volumes at +/- 2 levels and the Time from scheduled start, but I am having difficulty with these 2 things.
Betfair Bot
Full market data are available in the active market, so in the only market open in Bet Event View or in Bet Event Trader View.
Why is it so?
Bfexplorer can monitor hundreds of markets so this way it is reasonably lower amount of data loaded from betfair servers.
Yes you can get matched volume only through PriceGridData, of course you must iterate through prices with traded volume, not all of 399 prices are traded.
If you run your bot in Bot Executor, then you can simply use the bot: “Execute at Time” and set the parameter: UseSetMarketInactive to True. So when executed in bot executes your action bot and set MonitoringStatus to Inactive, Bot Executor then removes such market from monitoring and opens it in Bet Event view, so your bot have them full market data available.
Of course there are other betfair api methods you can use to get traded data betfair uses in charts. You can see that in my post:
Lay the Field Strategy – Analyzing Data
Betfair Bot
Here is my bot trigger showing on ladders near BSP and after the race is turned at in-play the actual BSP:
HorseRacingShowStartPrices.fsx
peteresgate@outlook.com
I have tried both the MyF#bot and MyC#Bot for showSelectionSP, and I tried the HorseRacingSPBotTrigger and moved showHorseData to show before inPlay the Near and Far SP, but I have never achieved to show the Near/Far Projected SP or the actual SP when inPlay (the horse metadata works). I was wondering if there has been a change in the method to receive the SP prices?
Betfair Bot
Actually, there are such bot triggers:
HorseRacingSpFavouriteBotTrigger.fsx
HorseRacingSpBotTrigger.fsx
As an example you could create a bot trigger showing for active selections near BSP and actual BSP after race is turned at in-play. You can show prices on ladder, like in this example:
Horse Racing - Oddschecker Favourite Trigger
Betfair Bot
Yes, placing betfair sp bet returns matched bet with matched amount zero, as SP bet is fully matched only after race is turned at in-play and all betfair start price bets are processed. This be cannot be cancelled I believe, well have never try that.
You can place normal bet with Take SP, such bet can be cancelled and unmatched part of bet is turned to SP at the moment race is turned at in-play.
Have a look at UpdateSpPricesMarketBot.fs if you want to update sp prices, but that is bot assembly, not bot trigger code. You have got access to betfair api in bot trigger code, so you need to study betfair documentation and then you can replicated code working with sp prices in bot trigger as well.
Betfair Bot
That is great Peter.
I would really suggest you to set breakpoint in your code and then debug it and browse available data offered by bfexplorer.
You must know what data you have got, visualize them in your head, and then you know what you can do with data.
Your approach for now is browsing existing code, so when you did not find similar one you cannot make progress, but data you have got, so working with data is the way to go.
peteresgate@outlook.com
I got it to work using another of your codes that I found from weight of money :)
peteresgate@outlook.com
Hi Stefan,
Yes thanks it will get the odds at specified levels now thanks.
But with the volume it is different.
https://github.com/PeterEsgate/BfexplorerTestBots/blob/master/Market%20Depth%20Volume
On Line 35 and 27, why I can't I just substitute the "priceData.Price" with "priceData.ToBack" ?
With the PriceGridData.GetOfferedPriceData(), there is no method (that I could find) to go to different levels like with priceGridData.GetPriceData(index)
Betfair Bot
On the line 3 of your code, there are set three values: startIndex, nextIndex, findFun
The findFun is function used to evaluate the place with empty offer. So when you want to place back bet, it must be checked lay offer and wise versa.
You change that code, therefore your findFun function returns true on offer with available offer. Actually in your code I cannot see logical problem because you start iterating through data on the best offer, so price must be set.
If you code does not go to the line 23, as you say price returned is always 0.0
Peter, how/where you execute your bot trigger?
The full market depth is updated only for active market, so for the market that is currently open in Bet Event/Trader.
It means that if you run your bot by Bot Executor tool you will get updates only for 3 best offered prices.
I would suggest you to debug code, only this way you can find your problem in the code.
Hint: There is function selection.PriceGridData.GetOfferedPriceData()
You can use to get all offered prices. I do not know what you want to make in your code, so this function: GetOfferedPriceData returns all offered prices, and you can filter whatever criteria you use.
Here is bot trigger code:
ShowOfferedPrices.fsx
Peter, please use VS debugger when testing your code.
peteresgate@outlook.com
Please see the code here:
https://github.com/PeterEsgate/BfexplorerTestBots/blob/master/Market%20Depth%20Levels
I run it like this:
let mutable odds = defaultArg (botTriggerParameters.GetParameter<float>("Odds")) 1.0
odds <- getMarketDepthPrice(BetType.Back) (myLaySelection) 1
outputMessage (sprintf "Lay Odds at Level 0 %.2f" odds)
odds <- getMarketDepthPrice(BetType.Back) (myLaySelection) 2
outputMessage (sprintf "Lay Odds at Level 1 %.2f" odds)
but the result of odds is always 0.0
I am trying to find the available odds at different market depth levels
Could you please tell me what is wrong with the code?