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.Bfexplorer.Domain.dll"
#r "BeloSoft.Bfexplorer.Trading.dll"
#r "BeloSoft.Bfexplorer.Service.Core.dll"
//*)
open BeloSoft.Bfexplorer.Domain
open BeloSoft.Bfexplorer.Trading
let mutable private stakeIndex = 0uy
let toStakeAmounts (value : string) =
value.Split('|') |> Array.map float
/// <summary>
/// MyStakingPlanBotTrigger
/// </summary>
type MyStakingPlanBotTrigger(market : Market, _selection : Selection, botName : string, botTriggerParameters : BotTriggerParameters, myBfexplorer : IMyBfexplorer) =
let stakeAmounts = toStakeAmounts (defaultArg (botTriggerParameters.GetParameter<string>("StakeAmounts")) "1.0|2.0|9.0|36.0")
let losingStreak = (defaultArg (botTriggerParameters.GetParameter<byte>("LosingStreak")) 3uy)
let myStrategyResults = myBfexplorer.BfexplorerService |> MyStrategyOperations.RegisterMyStrategy botName
let getStakeAmount() =
match myStrategyResults.BettingStreak with
| BettingStreak.WinningStreak _ ->
if myStrategyResults.TotalProfit > 0.0
then
stakeIndex <- 0uy
| BettingStreak.LosingStreak loses ->
if byte loses >= losingStreak
then
stakeIndex <- stakeIndex + 1uy
if stakeIndex >= byte stakeAmounts.Length
then
stakeIndex <- 0uy
| BettingStreak.NoBet -> ()
stakeAmounts.[int stakeIndex]
interface IBotTrigger with
/// <summary>
/// Execute
/// </summary>
member __.Execute() =
if myStrategyResults.CanExecuteMyStrategy
then
myStrategyResults.AddMarket(market)
let myBotParameters = [ { MyBotParameter.Name = "Stake"; MyBotParameter.Value = getStakeAmount() } ]
TriggerResult.ExecuteActionBotWithParameters myBotParameters
else
myStrategyResults.CheckMyResults()
TriggerResult.EndExecutionWithMessage "Previous result is not yet known!"
/// <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.