AfterMarketOpen scheduled events for futures seems to use stocks regular trading hours as reference. The scheduled event in the example below triggers at 09:20, instead of the expected 17:50. Why is that and any way to come around it without scheduling an event for 17:50 ?
# Add futures
tickers = [
Futures.Indices.SP500EMini
]
self.selected_symbols = []
for ticker in tickers:
future = self.AddFuture(
ticker=ticker,
resolution=self.resolution,
dataMappingMode=DataMappingMode.OpenInterestAnnual, # Changes when any contracts of next year have a higher volume than the current
dataNormalizationMode=DataNormalizationMode.BackwardsPanamaCanal, # New contract has true price
contractDepthOffset=0, # Choose the front month
)
self.selected_symbols.append(future.Symbol)
# Scheduled event to allow trades when market re-opens
self.Schedule.On(
self.DateRules.EveryDay(self.selected_symbols[0]),
self.TimeRules.AfterMarketOpen(self.selected_symbols[0], -10),
self.StartOfSession
)
'''
Start of session scheduled event
'''
def StartOfSession(self):
self.end_of_session = False
Echoes McCarthur
Hey Haakon,
You should explicitly set the properties (either for the full algo or just the future/security you added) to have extendedMarketHours = true? It looks like that may well be missing. See Here:
https://www.quantconnect.com/docs/v2/writing-algorithms/universes/futures#11-Create-Universes
Or
https://www.quantconnect.com/docs/v2/writing-algorithms/universes/settings#02-Properties
Hope this helps
Louis Szeto
Hi Haakon & Echoes
Thank you for your answer Echoes, indeed you're correct. An additional extendedMarketHours argument should be put in the AfterMarketOpen method besides from the data subscription:
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.
Haakon
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!