Skip to content

Instantly share code, notes, and snippets.

@StefanBelo
Created August 12, 2018 08:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save StefanBelo/5d7d11efdfe487f9a8f1bb8e2e1116d0 to your computer and use it in GitHub Desktop.
Save StefanBelo/5d7d11efdfe487f9a8f1bb8e2e1116d0 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.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