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 HorseRacingWinToBePlacedData
#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>
/// TriggerStatus
/// </summary>
type TriggerStatus =
| Initialize
| ShowMarketData of Market
| ReportError of string
/// <summary>
/// HorseRacingWinToBePlacedData
/// </summary>
type HorseRacingWinToBePlacedData(market : Market, selection : Selection, botName : string, botTriggerParameters : BotTriggerParameters, myBfexplorer : IMyBfexplorer) =
let mutable status = TriggerStatus.Initialize
let reportSelectionsData (winSelection : Selection) (toBePlacedSelection : Selection) =
sprintf "%s: %.2f | %.2f" winSelection.Name winSelection.LastPriceTraded (toPriceProbability toBePlacedSelection.LastPriceTraded)
let reportData (toBePlacedMarket : Market) =
let sb = StringBuilder()
|> Seq.filter isActiveSelection
|> Seq.iter (fun mySelection ->
let toBePlacedSelection = (toBePlacedMarket.Selections |> getSelectionByName mySelection.Name).Value
sb.AppendLine(reportSelectionsData mySelection toBePlacedSelection) |> ignore
interface IBotTrigger with
/// <summary>
/// Execute
/// </summary>
member this.Execute() =
match status with
| Initialize ->
if market.MarketInfo.BetEventType.Id = 7 && market.MarketDescription.MarketType = "WIN"
TriggerResult.OpenAssociatedMarkets ([| "PLACE" |], fun result ->
status <-
if result.IsSuccessResult
TriggerStatus.ShowMarketData result.SuccessResult.[0]
TriggerStatus.ReportError "Failed to open the to be placed market!"
TriggerResult.EndExecutionWithMessage "You can execute this bot only on a horse racing win market."
| ShowMarketData toBePlacedMarket -> TriggerResult.EndExecutionWithMessage (reportData toBePlacedMarket)
| ReportError message -> TriggerResult.EndExecutionWithMessage message
/// <summary>
/// EndExecution
/// </summary>
member this.EndExecution() =
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment