Skip to content

Instantly share code, notes, and snippets.

@StefanBelo
Created December 12, 2019 12:50
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/f2ba844b31360c8632a31336bfe8a410 to your computer and use it in GitHub Desktop.
Save StefanBelo/f2ba844b31360c8632a31336bfe8a410 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
let isHorseRacingMarket (market : Market) =
market.MarketInfo.BetEventType.Id = 7 && market.MarketDescription.MarketType = "WIN"
let toMySelectionData (selection : Selection) = maybe {
let! metaData = selection.MetaData
return selection, metaData.Form
}
/// <summary>
/// HorseRacingLastRacePositionBotTrigger
/// </summary>
type HorseRacingLastRacePositionBotTrigger(market : Market, _selection : Selection, _botName : string, botTriggerParameters : BotTriggerParameters, myBfexplorer : IMyBfexplorer) =
let lastRacePosition = defaultArg (botTriggerParameters.GetParameter<string>("LastRacePosition")) "8"
let outputMessage message =
myBfexplorer.BfexplorerService.OutputMessage(message, market.Id)
let getMySelectionsData() =
market.Selections
|> Seq.filter isActiveSelection
|> Seq.choose toMySelectionData
|> Seq.toList
let report (mySelectionsData : (Selection * string) list) =
mySelectionsData
|> List.map (fun (mySelection, form) -> sprintf "%s: %s" mySelection.Name form)
|> String.concat "\n"
|> outputMessage
let getMySelections (mySelectionsData : (Selection * string) list) =
mySelectionsData
|> List.choose (fun (mySelection, form) -> if form.EndsWith(lastRacePosition) then Some mySelection else None)
interface IBotTrigger with
/// <summary>
/// Execute
/// </summary>
member __.Execute() =
if isHorseRacingMarket market
then
let mySelectionsData = getMySelectionsData()
if mySelectionsData.IsEmpty
then
TriggerResult.EndExecution
else
report mySelectionsData
let mySelections = getMySelections mySelectionsData
if mySelections.IsEmpty
then
TriggerResult.EndExecution
else
TriggerResult.ExecuteActionBotOnSelectionsAndContinueToExecute (mySelections, false)
else
TriggerResult.EndExecutionWithMessage "You can run this bot on a horse racing market only!"
/// <summary>
/// EndExecution
/// </summary>
member __.EndExecution() =
()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment