Skip to content

Instantly share code, notes, and snippets.

Embed
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 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
open BeloSoft.Data
open BeloSoft.Bfexplorer.Domain
open BeloSoft.Bfexplorer.Trading
/// <summary>
/// CheckPositionBotTrigger
/// </summary>
type CheckPositionBotTrigger(market : Market, selection : Selection, _botName : string, botTriggerParameters : BotTriggerParameters, _myBfexplorer : IMyBfexplorer) =
let allowedPositions =
(defaultArg (botTriggerParameters.GetParameter<string>("AllowedPositions")) "1;2").Split(';')
|> Array.map int
|> Array.toList
let startTimeSpan = TimeSpan.FromSeconds(defaultArg (botTriggerParameters.GetParameter<float>("StartTimeSpan")) -30.0)
let canStartExecution() =
isMarketStartTime startTimeSpan market
let canExecuteMyActionBot() =
let favourites =
market.Selections
|> Seq.filter isActiveSelection
|> Seq.sortBy (fun mySelection -> mySelection.LastPriceTraded)
|> Seq.toList
let mySelectionId = selection.Id
let selectionIndex =
favourites
|> List.findIndex (fun mySelection -> mySelection.Id = mySelectionId)
|> (+) 1
allowedPositions |> List.contains selectionIndex
interface IBotTrigger with
/// <summary>
/// Execute
/// </summary>
member __.Execute() =
if canStartExecution()
then
if canExecuteMyActionBot()
then
TriggerResult.ExecuteActionBot
else
TriggerResult.EndExecution
else
TriggerResult.WaitingForOperation
/// <summary>
/// EndExecution
/// </summary>
member __.EndExecution() =
()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.