I've been struggle to get premarket hours working correctly. Im using the below ScheduledUniverseSelectionModel with universe_settings.extended_market_hours = True and extended_market_hours=True set in the history call, but im not getting any data. If i switch to regular market hours i get the expected debug messages. Ive also notice if i set limit orders on extended hours they all fill as Market Open Orders and not expect limit orders.
What am I missing here? Thought getting extended_market_hours=True set everywhere and that would work?
self.debug(f"TimeZone: {TimeZones.NEW_YORK}")
self.start_time = time(4, 0) # 9:30 AM
self.end_time = time(9, 0) # 4:00 PM (24-hour format)
self.order_properties = InteractiveBrokersOrderProperties()
self.order_properties.time_in_force = TimeInForce.DAY
self.order_properties.outside_regular_trading_hours = True
self.order_properties.OutsideRegularTradingHours = True
self.set_cash(2500000)
self.universe_settings.extended_market_hours = True
self.universe_settings.minimum_time_in_universe = timedelta(minutes=1)
self.set_brokerage_model(BrokerageName.INTERACTIVE_BROKERS_BROKERAGE, AccountType.MARGIN)
self.universe_settings.resolution = Resolution.SECOND
self.add_universe_selection(ScheduledUniverseSelectionModel(
self.date_rules.every_day(),
self.time_rules.every(timedelta(seconds = 30)),
self.GetTickersFromGoogleSheet# selection function in algorithm.
------
start_time = datetime.datetime(2014,5,29,4,0) # 4:00 AM
end_time = datetime.datetime(2014,5,29,9,30)
self.premarket_bars = self.algo.history[TradeBar](self._symbol, start_time, end_time, Resolution.Minute, extended_market_hours=True)
self.algo.Debug(f"Premarket High: {self.premarket_bars}")
for x in self.premarket_bars:
self.algo.Debug(f"Premarket High: {x.high}")
Mia Alissi
Sources: Extended Market Trading Regression Algorithm, Order Errors - QuantConnect.com, Gaussian Naive Bayes Model, Universe Settings - QuantConnect.com, Futures Fast Trend Following, with Trend Strength
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
Jason
Unfortunately, this didn't answer the question, bad bot.
Jason
Anything here that I am missing, I see the hours are off for the history, but that should still pull historical data. Still an issue with non regular hours.
Jason
Derek Melchin any idea, i have looked through all other forum posts and have set
you can see above ive really double checked the hours are in scope and that is_market_open checked. Just stuck since i feel like ive tried everything.
Louis Szeto
Hi Jason
I can order using your setup during the pre-open period. The problem might probably related to the upper-level conditions.
Best
Louis
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
Jason
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!