From 9b9aa1c2e510155980e02869c674a779e3e6cf91 Mon Sep 17 00:00:00 2001 From: Martin Molinero Date: Mon, 8 Jun 2026 18:30:57 -0300 Subject: [PATCH] Minor MarketHourAwareConsolidator tweak --- .../MarketHourAwareConsolidator.cs | 34 ++++++++++--------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/Common/Data/Consolidators/MarketHourAwareConsolidator.cs b/Common/Data/Consolidators/MarketHourAwareConsolidator.cs index 27676b2aeb4a..b674cfd9d1f8 100644 --- a/Common/Data/Consolidators/MarketHourAwareConsolidator.cs +++ b/Common/Data/Consolidators/MarketHourAwareConsolidator.cs @@ -85,38 +85,40 @@ public MarketHourAwareConsolidator(bool dailyStrictEndTimeEnabled, Resolution re Period = resolution.ToTimeSpan(); _extendedMarketHours = extendedMarketHours; + Consolidator = CreateConsolidator(resolution, dataType, tickType); + Consolidator.DataConsolidated += ForwardConsolidatedBar; + } + + /// + /// Creates the inner consolidator that produces the requested output. + /// + protected virtual IDataConsolidator CreateConsolidator(Resolution resolution, Type dataType, TickType tickType) + { if (dataType == typeof(Tick)) { if (tickType == TickType.Trade) { - Consolidator = resolution == Resolution.Daily + return resolution == Resolution.Daily ? new TickConsolidator(DailyStrictEndTime) : new TickConsolidator(Period); } - else - { - Consolidator = resolution == Resolution.Daily - ? new TickQuoteBarConsolidator(DailyStrictEndTime) - : new TickQuoteBarConsolidator(Period); - } + return resolution == Resolution.Daily + ? new TickQuoteBarConsolidator(DailyStrictEndTime) + : new TickQuoteBarConsolidator(Period); } - else if (dataType == typeof(TradeBar)) + if (dataType == typeof(TradeBar)) { - Consolidator = resolution == Resolution.Daily + return resolution == Resolution.Daily ? new TradeBarConsolidator(DailyStrictEndTime) : new TradeBarConsolidator(Period); } - else if (dataType == typeof(QuoteBar)) + if (dataType == typeof(QuoteBar)) { - Consolidator = resolution == Resolution.Daily + return resolution == Resolution.Daily ? new QuoteBarConsolidator(DailyStrictEndTime) : new QuoteBarConsolidator(Period); } - else - { - throw new ArgumentNullException(nameof(dataType), $"{dataType.Name} not supported"); - } - Consolidator.DataConsolidated += ForwardConsolidatedBar; + throw new ArgumentNullException(nameof(dataType), $"{dataType.Name} not supported"); } ///