Expected Behavior
Consolidators are market-hours aware. In other words, they only account for market hours.
For example, US Equity opens at 9:30, so if we are using 7-min bars, the first bar will be at 9:37 AM. If we use extended hours, the first bar will be 4:07 AM.
Actual Behavior
As it is now, the bar size accounts for the closed market hours, and keeps a continuous period.
class BasicFutureAlgorithm(QCAlgorithm):
_day = 0
def initialize(self):
self.set_start_date(2024, 12, 1)
self.set_end_date(2024, 12, 31)
self._future = self.add_future(
Futures.Indices.SP_500_E_MINI,
extended_market_hours=True
)
consolidator = TradeBarConsolidator(timedelta(minutes=7))
consolidator.data_consolidated += self._log_bar
self.subscription_manager.add_consolidator(self._future.symbol, consolidator)
def _log_bar(self, sender, bar):
if bar.end_time.day == self._day:
return
self._day = bar.end_time.day
self.log(str(bar))
The market opens at 18 on Sunday, so we should see 18:07 instead of 18:03. It's 18:03 because of the 7-min bars started at 20241201 00:00:00:
Potential Solution
N/A
Checklist
Expected Behavior
Consolidators are market-hours aware. In other words, they only account for market hours.
For example, US Equity opens at 9:30, so if we are using 7-min bars, the first bar will be at 9:37 AM. If we use extended hours, the first bar will be 4:07 AM.
Actual Behavior
As it is now, the bar size accounts for the closed market hours, and keeps a continuous period.
The market opens at 18 on Sunday, so we should see 18:07 instead of 18:03. It's 18:03 because of the 7-min bars started at 20241201 00:00:00:
Potential Solution
N/A
Checklist
masterbranch