Created
October 18, 2019 10:09
-
-
Save StefanBelo/8baacbb7042f34c09f664d67e4992335 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.Bfexplorer.Domain | |
open BeloSoft.Bfexplorer.Trading | |
/// <summary> | |
/// SelectionVolumePercentageBotTrigger | |
/// </summary> | |
type SelectionVolumePercentageBotTrigger(market : Market, selection : Selection, _botName : string, botTriggerParameters : BotTriggerParameters, myBfexplorer : IMyBfexplorer) = | |
let minimalValue = defaultArg (botTriggerParameters.GetParameter<float>("MinimalValue")) 40.0 | |
let maximalValue = defaultArg (botTriggerParameters.GetParameter<float>("MaximalValue")) 60.0 | |
let outputMessage message = | |
myBfexplorer.BfexplorerService.OutputMessage(message, market.Id) | |
let getSelectionVolumePercentage (mySelection : Selection) = | |
(mySelection.TotalMatched / market.TotalMatched) * 100.0 | |
let showSelectionsVolumePercentage() = | |
getFavourites market | |
|> List.map (fun mySelection -> sprintf "%s: %.2f | %.2f%%" mySelection.Name mySelection.LastPriceTraded (getSelectionVolumePercentage mySelection)) | |
|> String.concat "\n" | |
|> outputMessage | |
interface IBotTrigger with | |
/// <summary> | |
/// Execute | |
/// </summary> | |
member __.Execute() = | |
showSelectionsVolumePercentage() | |
let selectionVolumePercentage = getSelectionVolumePercentage selection | |
if selectionVolumePercentage >= minimalValue && selectionVolumePercentage <= maximalValue | |
then | |
TriggerResult.ExecuteActionBot | |
else | |
TriggerResult.EndExecution | |
/// <summary> | |
/// EndExecution | |
/// </summary> | |
member __.EndExecution() = | |
() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment