Created
August 12, 2018 08:40
-
-
Save StefanBelo/5d7d11efdfe487f9a8f1bb8e2e1116d0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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