Created
January 24, 2022 18:35
-
-
Save StefanBelo/b9510feb9ae358bc417e4a3a8b5f4769 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
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