Created
August 5, 2018 13:40
-
-
Save StefanBelo/7f559dc51600aec48f42acd9aed8a799 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 FavouriteChangedBotTrigger | |
//#I @"D:\Projects\Bfexplorer\Development\Applications\BeloSoft.Bfexplorer.App\bin\Debug\" | |
#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 BeloSoft.Data | |
open BeloSoft.Bfexplorer.Domain | |
open BeloSoft.Bfexplorer.Trading | |
/// <summary> | |
/// TriggerStatus | |
/// </summary> | |
type TriggerStatus = | |
| WaitForMarketTurnedAtInPlay | |
| ReportFavouriteChanged | |
/// <summary> | |
/// FavouriteChangedBotTrigger | |
/// </summary> | |
type FavouriteChangedBotTrigger(market : Market, _selection : Selection, _botName : string, _botTriggerParameters : BotTriggerParameters, myBfexplorer : IMyBfexplorer) = | |
let mutable triggerStatus = TriggerStatus.WaitForMarketTurnedAtInPlay | |
let mutable favourite = nil<Selection> | |
let outputMessage message = | |
myBfexplorer.BfexplorerService.OutputMessage(message, market.Id) | |
let getFavourite() = | |
market.Selections | |
|> Seq.filter isActiveSelection | |
|> Seq.sortBy (fun mySelection -> mySelection.LastPriceTraded) | |
|> Seq.head | |
let reportFavourite (myFavourite : Selection) = | |
outputMessage (sprintf "%s: %.2f" myFavourite.Name myFavourite.LastPriceTraded) | |
interface IBotTrigger with | |
/// <summary> | |
/// Execute | |
/// </summary> | |
member _this.Execute() = | |
match triggerStatus with | |
| TriggerStatus.WaitForMarketTurnedAtInPlay -> | |
if market.IsInPlay | |
then | |
favourite <- getFavourite() | |
reportFavourite favourite | |
triggerStatus <- TriggerStatus.ReportFavouriteChanged | |
TriggerResult.WaitingForOperation | |
| TriggerStatus.ReportFavouriteChanged -> | |
let currentFavourite = getFavourite() | |
if favourite.Id <> currentFavourite.Id | |
then | |
reportFavourite currentFavourite | |
TriggerResult.EndExecution | |
else | |
TriggerResult.WaitingForOperation | |
/// <summary> | |
/// EndExecution | |
/// </summary> | |
member _this.EndExecution() = | |
() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment