Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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.ComponentModel
open BeloSoft.Bfexplorer.Domain
open BeloSoft.Bfexplorer.Trading
type TriggerStatus =
| WaitForMarketBeingTurnedAtInPlay
| WaitForMarketBeingReopenAtInPlay
| MarketReopenAtInPlay
| WaitForMarketBeingClosed
type MyBotTrigger(market : Market, _selection : Selection, _botName : string, _botTriggerParameters : BotTriggerParameters, myBfexplorer : IMyBfexplorer) =
let mutable triggerStatus = TriggerStatus.WaitForMarketBeingTurnedAtInPlay
let outputMessage message =
myBfexplorer.BfexplorerService.OutputMessage(message, market.Id)
let marketNotifyHandler = PropertyChangedEventHandler(fun _sender args ->
if args.PropertyName = "MarketStatus"
then
outputMessage market.MarketStatusText
if market.MarketStatus = MarketStatus.Open
then
triggerStatus <- TriggerStatus.MarketReopenAtInPlay
)
interface IBotTrigger with
member __.Execute() =
match triggerStatus with
| TriggerStatus.WaitForMarketBeingTurnedAtInPlay ->
if market.IsInPlay
then
(market :> INotifyPropertyChanged).PropertyChanged.AddHandler marketNotifyHandler
triggerStatus <- TriggerStatus.WaitForMarketBeingReopenAtInPlay
| TriggerStatus.MarketReopenAtInPlay ->
outputMessage "Market has been reopened at in-play."
triggerStatus <- TriggerStatus.WaitForMarketBeingClosed
| _ -> ()
TriggerResult.WaitingForOperation
member __.EndExecution() =
(market :> INotifyPropertyChanged).PropertyChanged.RemoveHandler marketNotifyHandler
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment