| Overall Statistics |
|
Total Trades 0 Average Win 0% Average Loss 0% Compounding Annual Return 0% Drawdown 0% Expectancy 0 Net Profit 0% Sharpe Ratio 0 Probabilistic Sharpe Ratio 0% Loss Rate 0% Win Rate 0% Profit-Loss Ratio 0 Alpha 0 Beta 0 Annual Standard Deviation 0 Annual Variance 0 Information Ratio 1.104 Tracking Error 0.676 Treynor Ratio 0 Total Fees $0.00 Estimated Strategy Capacity $0 Lowest Capacity Asset |
# region imports
from AlgorithmImports import *
# endregion
class VolumeAggregationError(QCAlgorithm):
def Initialize(self):
self.SetStartDate(2022, 5, 1) # Set Start Date
self.SetCash(100000) # Set Strategy Cash
# Symbol.
self.Ticker = "BTCUSDT"
self.H1VolumeRollingWindowLength = 5
# Binance brokerage model set-up.
self.SetBrokerageModel(BrokerageName.Binance, AccountType.Margin)
# Initialise Binance symbol.
self.MinuteSymbol = self.AddCrypto(self.Ticker, Resolution.Minute, Market.Binance).Symbol
# Initialise RollingWindow.
self.H1VolumeRollingWindow = RollingWindow[float](self.H1VolumeRollingWindowLength)
# Create a 1-hour TradeBarConsolidator.
H1Consolidator = TradeBarConsolidator(timedelta(minutes=60))
# Subscribe the method OnNewH1Bar to the consolidation event.
H1Consolidator.DataConsolidated += self.OnNewH1Bar
# Add the consolidator to the SubscriptionManager to update it automatically with self.MinuteSymbol data.
self.SubscriptionManager.AddConsolidator(self.MinuteSymbol, H1Consolidator)
self.CurrentH1Volume = 0
def OnNewH1Bar(self, sender, consolidated):
# Add volume data of the bar that was just fully consolidated to the H1VolumeRollingWindow.
self.H1VolumeRollingWindow.Add(consolidated.Volume)
# TODO: check diff.
self.Debug("{0} Consolidated: {1}. Sum: {2}. Abs. difference {3}.".format(self.UtcTime,
consolidated.Volume,
self.CurrentH1Volume,
self.CurrentH1Volume - consolidated.Volume))
self.CurrentH1Volume = 0
def OnData(self, data: Slice):
self.CurrentH1Volume = self.CurrentH1Volume + data.Bars[self.MinuteSymbol].Volume