Last active
November 26, 2024 09:49
-
-
Save StefanBelo/a85ee8b9959b841ea423eade056cc762 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 @"E:\Projects\Bfexplorer\Development\Applications\BeloSoft.Bfexplorer.App\bin\Debug\net9.0-windows" | |
#I @"C:\Program Files\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> | |
/// ShowHorseData | |
/// </summary> | |
type ShowHorseData (market : Market, _selection : Selection, _botName : string, _botTriggerParameters : BotTriggerParameters, myBfexplorer : IMyBfexplorer) = | |
let outputMessage message = | |
myBfexplorer.BfexplorerService.OutputMessage (message, market.Id) | |
let isHorseRacingMarket () = | |
market.MarketInfo.BetEventType.Id = 7 && market.MarketDescription.MarketType = "WIN" | |
let getOddsDifference (selection1 : Selection, selection2 : Selection) = | |
selection1.OddsContext.GetOddsDifference (selection1.LastPriceTraded, selection2.LastPriceTraded) | |
let getBookValue (selections : Selection list) = | |
selections | |
|> List.map (fun mySelection -> toPriceProbability mySelection.LastPriceTraded) | |
|> List.sum | |
let reportHorsesData () = | |
let selectionDataToString (mySelection : Selection) = maybe { | |
let! metaData = mySelection.MetaData | |
return sprintf "%s: %.2f | %d | %s" mySelection.Name mySelection.LastPriceTraded metaData.OfficialRating metaData.Form | |
} | |
let selections = | |
market.Selections | |
|> Seq.filter isNotRemovedSelection | |
|> Seq.sortBy (fun mySelection -> mySelection.LastPriceTraded) | |
|> Seq.toList | |
selections | |
|> List.choose selectionDataToString | |
|> String.concat "\n" | |
|> outputMessage | |
let firstFavourite, secondFavourite = selections.[0], selections.[1] | |
outputMessage <| | |
sprintf "Number of runners: %d\nFavourite: %s\nSecond favourite: %s\nOdds difference: %d\nFavourite and second favourite book value: %.2f" | |
selections.Length | |
firstFavourite.Name secondFavourite.Name | |
(getOddsDifference (firstFavourite, secondFavourite)) | |
(getBookValue [ firstFavourite; secondFavourite ]) | |
interface IBotTrigger with | |
/// <summary> | |
/// Execute | |
/// </summary> | |
member __.Execute () = | |
if isHorseRacingMarket () | |
then | |
reportHorsesData () | |
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