Skip to content

Instantly share code, notes, and snippets.

@StefanBelo
Created September 6, 2018 15:02
Show Gist options
  • Save StefanBelo/bd6652d99af6c3d2c446ab99a9b586c7 to your computer and use it in GitHub Desktop.
Save StefanBelo/bd6652d99af6c3d2c446ab99a9b586c7 to your computer and use it in GitHub Desktop.
module BfexplorerBot
#I @"C:\Program Files (x86)\BeloSoft\Bfexplorer\"
#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
open BeloSoft.Bfexplorer.Domain
open BeloSoft.Bfexplorer.Trading
type HorseMetaDataBotTrigger(market : Market, _selection : Selection, _botName : string, botTriggerParameters : BotTriggerParameters, myBfexplorer : IMyBfexplorer) =
let outputMessage message =
myBfexplorer.BfexplorerService.OutputMessage(message, market.Id)
let showHorsesMetaData() =
let selectionMetaDataToString (selection : Selection) =
match selection.MetaData with
| Some metaData -> sprintf "%s, %s" metaData.ClothNumber metaData.JockeyName
| None -> "no meta data!"
|> sprintf "%s: %s" selection.Name
market.Selections
|> Seq.filter isNotRemovedSelection
|> Seq.map selectionMetaDataToString
|> String.concat "\n"
|> outputMessage
let getMySelection (clothNumber : string) =
let isMySelection (selection : Selection) =
match selection.MetaData with
| Some metaData -> metaData.ClothNumber = clothNumber
| None -> false
market.Selections
|> Seq.filter isNotRemovedSelection
|> Seq.tryFind isMySelection
interface IBotTrigger with
member __.Execute() =
showHorsesMetaData()
let executeOnClothNumber = defaultArg (botTriggerParameters.GetParameter<string>("ClothNumber")) String.Empty
if not (String.IsNullOrEmpty executeOnClothNumber)
then
match getMySelection executeOnClothNumber with
| Some mySelection -> TriggerResult.ExecuteActionBotOnSelection mySelection
| None -> TriggerResult.EndExecution
else
TriggerResult.EndExecution
member __.EndExecution() =
()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment