Last active
December 18, 2018 13:07
-
-
Save StefanBelo/32d189503a598e2e74a107f7f8756798 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 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> | |
/// HorseRacingBredBotTrigger | |
/// </summary> | |
type HorseRacingBredBotTrigger(market : Market, selection : Selection, _botName : string, botTriggerParameters : BotTriggerParameters, myBfexplorer : IMyBfexplorer) = | |
let allowedBredCountries = (defaultArg (botTriggerParameters.GetParameter<string>("AllowedBredCountries")) "GB").Split(';') | |
let outputMessage message = | |
myBfexplorer.BfexplorerService.OutputMessage(message, market.Id) | |
let isHorseRacingMarket() = | |
market.MarketInfo.BetEventType.Id = 7 && market.MarketDescription.MarketType = "WIN" | |
let selectionDataToString (mySelection : Selection) = maybe { | |
let! metaData = mySelection.MetaData | |
return sprintf "%s: %.2f | %d | %s" mySelection.Name mySelection.LastPriceTraded metaData.OfficialRating metaData.BredCountry | |
} | |
let canExecuteMyActionBot (mySelection : Selection) = | |
match mySelection.MetaData with | |
| Some metaData -> allowedBredCountries |> Array.contains metaData.BredCountry | |
| None -> false | |
interface IBotTrigger with | |
/// <summary> | |
/// Execute | |
/// </summary> | |
member __.Execute() = | |
if isHorseRacingMarket() | |
then | |
match selectionDataToString selection with | |
| Some data -> data | |
| None -> sprintf "No metadata available for horse: %s!" selection.Name | |
|> outputMessage | |
if canExecuteMyActionBot selection | |
then | |
TriggerResult.ExecuteActionBot | |
else | |
TriggerResult.EndExecution | |
else | |
TriggerResult.EndExecutionWithMessage "You can execute this bot only on a horse racing market!" | |
/// <summary> | |
/// EndExecution | |
/// </summary> | |
member __.EndExecution() = | |
() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment