Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
// Bfexplorer cannot be held responsible for any losses or damages incurred during the use of this betfair bot.
// It is up to you to determine the level of risk you wish to trade under.
// Do not gamble with money you cannot afford to lose.
module FindingGapsBetweenBackPrices
#I @"C:\Program Files (x86)\BeloSoft\Bfexplorer\"
//#I @"D:\Projects\Bfexplorer\Development\Applications\BeloSoft.Bfexplorer.App\bin\Debug\"
#r "BeloSoft.Data.dll"
#r "BeloSoft.Betfair.API.dll"
#r "BeloSoft.Bfexplorer.Domain.dll"
#r "BeloSoft.Bfexplorer.Trading.dll"
#r "BeloSoft.Bfexplorer.Service.Core.dll"
open System.Text
open BeloSoft.Bfexplorer.Domain
open BeloSoft.Bfexplorer.Trading
/// <summary>
/// FindingGapsBetweenBackPrices
/// </summary>
type FindingGapsBetweenBackPrices(market : Market, selection : Selection, botName : string, botTriggerParameters : BotTriggerParameters, myBfexplorer : IMyBfexplorer) =
let isGapBetweenBackPrices (mySelection : Selection) =
let bestOfferedPrices = mySelection.ToBack
let bestPrice = bestOfferedPrices.BestPrice
let secondBestPrice = bestOfferedPrices.SecondBestPrice
if secondBestPrice.IsValid
mySelection.OddsContext.GetOddsDifference(secondBestPrice.Price, bestPrice.Price) > 1
let getSelectionsWithGapBetweenBackPrices() =
|> Seq.filter (fun mySelection -> isActiveSelection mySelection && isGapBetweenBackPrices mySelection)
|> Seq.toList
let reportMySelection (mySelection : Selection) =
let bestOfferedPrices = mySelection.ToBack
let bestPrice = bestOfferedPrices.BestPrice.Price
let secondBestPrice = bestOfferedPrices.SecondBestPrice.Price
sprintf "%s: %.2f - %.2f | %d" mySelection.Name bestPrice secondBestPrice (mySelection.OddsContext.GetOddsDifference(secondBestPrice, bestPrice))
interface IBotTrigger with
/// <summary>
/// Execute
/// </summary>
member this.Execute() =
let mySelections = getSelectionsWithGapBetweenBackPrices()
if not mySelections.IsEmpty
let sb = StringBuilder()
|> List.iter (fun mySelection -> sb.AppendLine(reportMySelection mySelection) |> ignore)
/// <summary>
/// EndExecution
/// </summary>
member this.EndExecution() =
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.