{"record":{"id":"202ff961e4b5b278","repo":"QuantConnect/Lean","slug":"algorithm-should-have-run-on-regular-hours-for-se","errorCode":null,"errorMessage":"Algorithm should have run on regular hours for {self._es.symbol} future, which enabled extended market hours","messagePattern":"Algorithm should have run on regular hours for (.+?) future, which enabled extended market hours","errorType":"exception","errorClass":"AssertionError","httpStatus":null,"severity":"error","filePath":"Algorithm.Python/FuturesExtendedMarketHoursRegressionAlgorithm.py","lineNumber":63,"sourceCode":"        slice_has_e_s_data = self._es.symbol in slice_symbols\n        self._es_ran_on_regular_hours |= es_is_in_regular_hours and slice_has_e_s_data\n        self._es_ran_on_extended_hours |= es_is_in_extended_hours and slice_has_e_s_data\n\n        gc_is_in_regular_hours = self._gc.exchange.hours.is_open(self.time, False)\n        gc_is_in_extended_hours = not gc_is_in_regular_hours and self._gc.exchange.hours.is_open(self.time, True)\n        slice_has_g_c_data = self._gc.symbol in slice_symbols\n        self._gc_ran_on_regular_hours |= gc_is_in_regular_hours and slice_has_g_c_data\n        self._gc_ran_on_extended_hours |= gc_is_in_extended_hours and slice_has_g_c_data\n\n        time_of_day = self.time.time()\n        current_time_is_regular_hours = (time_of_day >= time(9, 30, 0) and time_of_day < time(16, 15, 0)) or (time_of_day >= time(16, 30, 0) and time_of_day < time(17, 0, 0))\n        current_time_is_extended_hours = not current_time_is_regular_hours and (time_of_day < time(9, 30, 0) or time_of_day >= time(18, 0, 0))\n        if es_is_in_regular_hours != current_time_is_regular_hours or es_is_in_extended_hours != current_time_is_extended_hours:\n            raise AssertionError(\"At {Time}, {_es.symbol} is either in regular hours but current time is in extended hours, or viceversa\")\n\n    def on_end_of_algorithm(self):\n        if not self._es_ran_on_regular_hours:\n            raise AssertionError(f\"Algorithm should have run on regular hours for {self._es.symbol} future, which enabled extended market hours\")\n\n        if not self._es_ran_on_extended_hours:\n            raise AssertionError(f\"Algorithm should have run on extended hours for {self._es.symbol} future, which enabled extended market hours\")\n\n        if not self._gc_ran_on_regular_hours:\n            raise AssertionError(f\"Algorithm should have run on regular hours for {self._gc.symbol} future, which did not enable extended market hours\")\n\n        if self._gc_ran_on_extended_hours:\n            raise AssertionError(f\"Algorithm should have not run on extended hours for {self._gc.symbol} future, which did not enable extended market hours\")\n","sourceCodeStart":45,"sourceCodeEnd":73,"githubUrl":"https://github.com/QuantConnect/Lean/blob/d2c3659f877bfc2b5d9dc0fc89a9c7566f45e892/Algorithm.Python/FuturesExtendedMarketHoursRegressionAlgorithm.py#L45-L73","documentation":"End-of-algorithm assertion that the ES future (extended hours enabled) produced data during a regular-hours bar at least once. _es_ran_on_regular_hours is set True only when ES is in regular hours AND the slice contains ES data. Failing means the algorithm never saw an ES bar during regular hours across the whole backtest.","triggerScenarios":"ES data missing for every regular-hours bar in the window; is_open returning False for all regular times due to a MarketHoursDatabase bug; slice symbol matching failing so slice_has_e_s_data is always False.","commonSituations":"Data drop covering only extended-hours bars; canonical-vs-mapped symbol mismatch in slice_symbols; resolution/fill-forward settings suppressing regular-hours bars; MarketHoursDatabase entry narrowing the regular session.","solutions":["Log self.time and slice_symbols on each bar to see whether ES data arrives in regular hours.","Verify the ES data files cover the regular session for the backtest window.","Confirm slice_symbols includes both the mapped and canonical ES symbol.","Check the MarketHoursDatabase regular-session window for CME ES."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"# Track regular-hours data arrival for ES\nif self._es.exchange.hours.is_open(self.time, False) and self._es.symbol in slice_symbols:\n    self._es_ran_on_regular_hours = True\nelse:\n    self.debug(f\"No ES regular-hours data yet at {self.time}\")","typeGuard":"def slice_has_regular_hours_data(security, slice_symbols, t: datetime) -> bool:\n    return security.exchange.hours.is_open(t, False) and security.symbol in slice_symbols","tryCatchPattern":null,"preventionTips":["Ensure slice_symbols includes both canonical and mapped ES symbols.","Verify ES data files cover the regular session in the window.","Log slice_symbols during regular hours to confirm subscription.","Check MarketHoursDatabase regular-session window for ES."],"tags":["quantconnect","futures","extended-market-hours","regular-hours","data-availability","regression-test"],"backgroundTag":null,"analyzedSha":"d2c3659f877bfc2b5d9dc0fc89a9c7566f45e892","analyzedAt":"2026-08-13T13:52:21.013Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}