Skip to content

Instantly share code, notes, and snippets.

@StefanBelo
Created May 26, 2018 15:32
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/2b2f6a9c4497eaf394854f3f55d5e231 to your computer and use it in GitHub Desktop.
Save StefanBelo/2b2f6a9c4497eaf394854f3f55d5e231 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 HorseRacingWinToBePlacedData
#I @"C:\Program Files (x86)\BeloSoft\Bfexplorer\"
//#I @"D:\Projects\Bfexplorer\Development\Applications\BeloSoft.Bfexplorer.App\bin\Debug\"
#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.Text
open BeloSoft.Bfexplorer.Domain
open BeloSoft.Bfexplorer.Trading
/// <summary>
/// TriggerStatus
/// </summary>
type TriggerStatus =
| Initialize
| ShowMarketData of Market
| ReportError of string
/// <summary>
/// HorseRacingWinToBePlacedData
/// </summary>
type HorseRacingWinToBePlacedData(market : Market, selection : Selection, botName : string, botTriggerParameters : BotTriggerParameters, myBfexplorer : IMyBfexplorer) =
let mutable status = TriggerStatus.Initialize
let reportSelectionsData (winSelection : Selection) (toBePlacedSelection : Selection) =
sprintf "%s: %.2f | %.2f" winSelection.Name winSelection.LastPriceTraded (toPriceProbability toBePlacedSelection.LastPriceTraded)
let reportData (toBePlacedMarket : Market) =
let sb = StringBuilder()
market.Selections
|> Seq.filter isActiveSelection
|> Seq.iter (fun mySelection ->
let toBePlacedSelection = (toBePlacedMarket.Selections |> getSelectionByName mySelection.Name).Value
sb.AppendLine(reportSelectionsData mySelection toBePlacedSelection) |> ignore
)
sb.ToString()
interface IBotTrigger with
/// <summary>
/// Execute
/// </summary>
member this.Execute() =
match status with
| Initialize ->
if market.MarketInfo.BetEventType.Id = 7 && market.MarketDescription.MarketType = "WIN"
then
TriggerResult.OpenAssociatedMarkets ([| "PLACE" |], fun result ->
status <-
if result.IsSuccessResult
then
TriggerStatus.ShowMarketData result.SuccessResult.[0]
else
TriggerStatus.ReportError "Failed to open the to be placed market!"
)
else
TriggerResult.EndExecutionWithMessage "You can execute this bot only on a horse racing win market."
| ShowMarketData toBePlacedMarket -> TriggerResult.EndExecutionWithMessage (reportData toBePlacedMarket)
| ReportError message -> TriggerResult.EndExecutionWithMessage message
/// <summary>
/// EndExecution
/// </summary>
member this.EndExecution() =
()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment