Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
// Bfexplorer cannot be held responsible for any losses or damages incurred during the use of this betfair bot.
// It is up to you to determine the level of risk you wish to trade under.
// Do not gamble with money you cannot afford to lose.
module TimeoutActionBotTrigger
open System
open System.Collections.Generic
open BeloSoft.Bfexplorer.Domain
open BeloSoft.Bfexplorer.Trading
/// <summary>
/// GetMyBotName
/// </summary>
/// <param name="botTriggerParameters"></param>
let GetMyBotName(botTriggerParameters : BotTriggerParameters) =
let myBotNames = defaultArg (botTriggerParameters.GetParameter<string>("BotsToExecute")) String.Empty
if String.IsNullOrEmpty myBotNames then [||] else myBotNames.Split('|')
/// <summary>
/// TimeoutActionBotTrigger
/// </summary>
type TimeoutActionBotTrigger(market : Market, selection : Selection, botName : string, botTriggerParameters : BotTriggerParameters, myBfexplorer : IMyBfexplorer) =
let botsToExecute = Queue<string>(GetMyBotName(botTriggerParameters))
let timeout = TimeSpan.FromSeconds(defaultArg (botTriggerParameters.GetParameter<float>("Timeout")) 30.0)
let mutable timeToExecute = DateTime.MinValue
interface IBotTrigger with
/// <summary>
/// Execute
/// </summary>
member this.Execute() =
if DateTime.Now >= timeToExecute
let myActionBot = if botsToExecute.Count > 0 then botsToExecute.Dequeue() else String.Empty
let continueToExecute = botsToExecute.Count > 0
if continueToExecute
timeToExecute <- DateTime.Now.Add(timeout)
if String.IsNullOrEmpty myActionBot
EndExecutionWithMessage "Please set the BotsToExecute parameter."
ExecuteMyActionBotOnSelectionWithParametersAndContinueToExecute (myActionBot, selection, list.Empty, continueToExecute)
/// <summary>
/// EndExecution
/// </summary>
member this.EndExecution() =
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment