@@ -89,36 +89,6 @@ public MarketHourAwareConsolidator(bool dailyStrictEndTimeEnabled, Resolution re
8989 Consolidator . DataConsolidated += ForwardConsolidatedBar ;
9090 }
9191
92- /// <summary>
93- /// Initializes a new instance of the <see cref="MarketHourAwareConsolidator"/> class for an arbitrary period.
94- /// Intraday periods are anchored to the market open without extending past the close.
95- /// </summary>
96- /// <param name="dailyStrictEndTimeEnabled">True if daily strict end times should be enabled</param>
97- /// <param name="period">The consolidation period</param>
98- /// <param name="dataType">The target data type</param>
99- /// <param name="tickType">The target tick type</param>
100- /// <param name="extendedMarketHours">True if extended market hours should be consolidated</param>
101- public MarketHourAwareConsolidator ( bool dailyStrictEndTimeEnabled , TimeSpan period , Type dataType , TickType tickType , bool extendedMarketHours )
102- {
103- _dailyStrictEndTimeEnabled = dailyStrictEndTimeEnabled ;
104- Period = period ;
105- _extendedMarketHours = extendedMarketHours ;
106-
107- // when the period exactly matches a standard resolution, reuse the resolution based consolidation so its
108- // well-tested behavior is preserved; only arbitrary periods need the market-open anchored intraday calendar
109- var resolution = period . ToHigherResolutionEquivalent ( false ) ;
110- if ( resolution . ToTimeSpan ( ) == period )
111- {
112- Consolidator = CreateConsolidator ( resolution , dataType , tickType ) ;
113- }
114- else
115- {
116- Func < DateTime , CalendarInfo > calendar = period < Time . OneDay ? IntradayCalendar : DailyStrictEndTime ;
117- Consolidator = CreateConsolidator ( calendar , dataType , tickType ) ;
118- }
119- Consolidator . DataConsolidated += ForwardConsolidatedBar ;
120- }
121-
12292 /// <summary>
12393 /// Creates the inner consolidator that produces the requested <paramref name="dataType"/> output.
12494 /// </summary>
@@ -151,28 +121,6 @@ protected virtual IDataConsolidator CreateConsolidator(Resolution resolution, Ty
151121 throw new ArgumentNullException ( nameof ( dataType ) , $ "{ dataType . Name } not supported") ;
152122 }
153123
154- /// <summary>
155- /// Creates the underlying calendar based consolidator for the given data type, used for arbitrary periods
156- /// </summary>
157- protected virtual IDataConsolidator CreateConsolidator ( Func < DateTime , CalendarInfo > calendar , Type dataType , TickType tickType )
158- {
159- if ( dataType == typeof ( Tick ) )
160- {
161- return tickType == TickType . Trade
162- ? new TickConsolidator ( calendar )
163- : new TickQuoteBarConsolidator ( calendar ) ;
164- }
165- if ( dataType == typeof ( TradeBar ) )
166- {
167- return new TradeBarConsolidator ( calendar ) ;
168- }
169- if ( dataType == typeof ( QuoteBar ) )
170- {
171- return new QuoteBarConsolidator ( calendar ) ;
172- }
173- throw new ArgumentNullException ( nameof ( dataType ) , $ "{ dataType . Name } not supported") ;
174- }
175-
176124 /// <summary>
177125 /// Event handler that fires when a new piece of data is produced
178126 /// </summary>
@@ -247,27 +195,13 @@ protected void Initialize(IBaseData data)
247195 /// </summary>
248196 protected virtual CalendarInfo DailyStrictEndTime ( DateTime dateTime )
249197 {
250- // strict end times describe a single daily bar, so periods larger than a day fall back to standard period consolidation
251- if ( ! _useStrictEndTime || Period > Time . OneDay )
198+ if ( ! _useStrictEndTime )
252199 {
253200 return new ( Period > Time . OneDay ? dateTime : dateTime . RoundDown ( Period ) , Period ) ;
254201 }
255202 return LeanData . GetDailyCalendar ( dateTime , ExchangeHours , _extendedMarketHours ) ;
256203 }
257204
258- /// <summary>
259- /// Determines a bar start time and period for intraday consolidation, anchored to the market open
260- /// without extending past the market close so a bar never spans across closed market hours
261- /// </summary>
262- protected virtual CalendarInfo IntradayCalendar ( DateTime dateTime )
263- {
264- if ( ExchangeHours == null || ExchangeHours . IsMarketAlwaysOpen )
265- {
266- return new ( dateTime . RoundDown ( Period ) , Period ) ;
267- }
268- return LeanData . GetIntradayCalendar ( dateTime , Period , ExchangeHours , _extendedMarketHours ) ;
269- }
270-
271205 /// <summary>
272206 /// Useful for testing
273207 /// </summary>
0 commit comments