Created
October 14, 2019 08:21
-
-
Save StefanBelo/80ddefffef01caf04cd95b9a458546d9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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\" | |
#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