Hey guys,
I can't quite figure out why there are all these substantial gaps in my strategy. I realize that they always seem to happen during a rollover, and understand if there were to be a gap for around a day, but they shouldn't be lasting as long as they are. Any insight will help.
Thank you,
Mia Alissi
Below are the identified bugs and logic oversights in your code that are likely to cause the substantial data gaps around rollovers, as described in your issue:
The algorithm does not handle symbol rollover events (such as when a futures contract expires and maps to a new underlying contract). After a rollover, self.symbol no longer reflects the active contract, so consolidators continue to reference and aggregate data from an inactive symbol.
The OnData method only checks self.symbol within data.Ticks. If a rollover occurs and a new symbol becomes active, the code will ignore incoming tick data for the new/rolled symbol. This results in missing tick data and incomplete or empty bars.
The minute_bars, hour_bars, and daily_bars dictionaries key bar data by the original symbol. If a rollover changes the Symbol object, then new symbol bar data will never be stored or retrieved, breaking access to consolidated bars after a rollover.
All TickConsolidator attachments are made only for self.symbol at initialization. When a rollover occurs, no new consolidators are attached to the updated symbol, so minute/hour/daily bars will not be generated for the new contract.
There is no transition logic to switch from the old symbol to the new active one, such as responding to a SymbolChangedEvent. Consequently, dictionaries, consolidators, and internal tracking are never updated or re-initialized. This leads to both missed data and disabled logic after the original symbol stops updating.
These are the core oversights that explain persistent data aggregation gaps during and after rollovers. Addressing them should meaningfully improve the reliability of your tick-to-bar processing and feature extraction across contract changes.
Sources: Handling Data - QuantConnect.com, Time Period Consolidators - QuantConnect.com, Consolidate Regression Algorithm, Short Term Reversal With Futures, Multiple Symbol Consolidation Algorithm
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.
Joshua Hughes
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!