Skip to content

Instantly share code, notes, and snippets.

@StefanBelo
Created October 14, 2018 18:03
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/1726bff7b89e176dd8fcc2178c391b6a to your computer and use it in GitHub Desktop.
Save StefanBelo/1726bff7b89e176dd8fcc2178c391b6a to your computer and use it in GitHub Desktop.
// 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 BeloSoft.Data
open BeloSoft.Bfexplorer.Domain
open BeloSoft.Bfexplorer.Trading
/// <summary>
/// WeightOfMoneyBotTrigger
/// </summary>
type WeightOfMoneyBotTrigger(market : Market, selection : Selection, _botName : string, botTriggerParameters : BotTriggerParameters, myBfexplorer : IMyBfexplorer) =
let womValue = defaultArg (botTriggerParameters.GetParameter<float>("WomValue")) 0.6
let outputMessage message =
myBfexplorer.BfexplorerService.OutputMessage(message, market.Id)
let getWeightOfMoneyForPriceIndex index =
let offeredToLay = selection.ToLay.Prices.[index].Size
let offeredToBack = selection.ToBack.Prices.[index].Size
let totalOffered = offeredToLay + offeredToBack
if totalOffered = 0.0
then
0.0
else
offeredToLay / totalOffered
let getWeightOfMoneyValues() =
[ 0; 1; 2 ] |> List.map getWeightOfMoneyForPriceIndex
interface IBotTrigger with
/// <summary>
/// Execute
/// </summary>
member __.Execute() =
if selection.IsUpdated
then
let womValues = getWeightOfMoneyValues()
outputMessage (sprintf "%s: %s" selection.Name (womValues |> List.map (sprintf "%.2f") |> String.concat " | "))
if womValues |> List.forall ((<=) womValue)
then
TriggerResult.ExecuteActionBot
else
TriggerResult.WaitingForOperation
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