Skip to content

Instantly share code, notes, and snippets.

@StefanBelo
Created January 24, 2022 18:35
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/b9510feb9ae358bc417e4a3a8b5f4769 to your computer and use it in GitHub Desktop.
Save StefanBelo/b9510feb9ae358bc417e4a3a8b5f4769 to your computer and use it in GitHub Desktop.
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 System
open BeloSoft.Bfexplorer.Domain
open BeloSoft.Bfexplorer.Trading
/// <summary>
/// ShowTurnoverPerMinute
/// </summary>
type ShowTurnoverPerMinute(market : Market, _selection : Selection, _botName : string, _botTriggerParameters : BotTriggerParameters, myBfexplorer : IMyBfexplorer) =
let mutable timeToCheck = DateTime.MinValue
let canReport time =
let status = time >= timeToCheck
if status
then
timeToCheck <- time.AddMinutes(1.0)
status
let outputMessage message =
myBfexplorer.BfexplorerService.OutputMessage(message, market.Id)
let reportTurnover (time : DateTime) =
let fromTime = time.AddMinutes(-1.0)
market.Selections
|> Seq.filter isActiveSelection
|> Seq.map (fun selection ->
let totalTradedVolumePerMinute =
selection.PriceTradedHistory.TradedPrices
|> Seq.filter (fun timePriceTraded -> timePriceTraded.Time >= fromTime)
|> Seq.sumBy (fun timePriceTraded -> timePriceTraded.Volume)
sprintf "%s: %.2f" selection.Name totalTradedVolumePerMinute
)
|> String.concat "\n"
|> outputMessage
interface IBotTrigger with
/// <summary>
/// Execute
/// </summary>
member _this.Execute() =
let time = DateTime.Now
if canReport time
then
reportTurnover time
TriggerResult.WaitingForOperation
/// <summary>
/// EndExecution
/// </summary>
member _this.EndExecution() =
()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment