Skip to content

Instantly share code, notes, and snippets.

@StefanBelo
Last active January 12, 2022 10:09
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/92827cd3ea564946f730a31e6c34a4bf to your computer and use it in GitHub Desktop.
Save StefanBelo/92827cd3ea564946f730a31e6c34a4bf 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 MarketSelectionTradedVolumeAlert
#I @"D:\Projects\Bfexplorer\Development\Applications\BeloSoft.Bfexplorer.App\bin\Debug"
//#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>
/// MarketSelectionTradedVolumeAlert
/// </summary>
type MarketSelectionTradedVolumeAlert(market : Market, _selection : Selection, _botName : string, botTriggerParameters : BotTriggerParameters, myBfexplorer : IMyBfexplorer) =
let minVolume = defaultArg (botTriggerParameters.GetParameter<float>("MinVolume")) 50.0
let alertMe = defaultArg (botTriggerParameters.GetParameter<bool>("AlertMe")) false
let outputMessage message =
myBfexplorer.BfexplorerService.OutputMessage(message, market.Id)
let getSelectionLastSizeTraded (selection : Selection) = maybe {
let lastSizeTraded = selection.PriceTradedHistory.LastSizeTraded
if lastSizeTraded >= minVolume
then
return selection, lastSizeTraded
}
let checkSelectionsTradedVolume() =
getActiveSelections market
|> List.filter (fun selection -> selection.IsUpdated)
|> List.choose getSelectionLastSizeTraded
interface IBotTrigger with
member _this.Execute() =
let selectionsData = checkSelectionsTradedVolume()
if selectionsData.IsEmpty
then
TriggerResult.WaitingForOperation
else
let message =
selectionsData
|> List.map (fun (selection, lastSizeTraded) -> sprintf "\t%s: %.2f | %.2f" selection.Name selection.LastPriceTraded lastSizeTraded)
|> String.concat "\n"
|> sprintf "%s\n%s" market.MarketFullName
outputMessage message
if alertMe
then
TriggerResult.AlertMessage "Big volume traded"
else
TriggerResult.WaitingForOperation
member _this.EndExecution() =
()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment