How do I create a TradeBarConsolidator which collects all the premarket activity, midnight to 9:30?
QUANTCONNECT COMMUNITY
How do I create a TradeBarConsolidator which collects all the premarket activity, midnight to 9:30?
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.
Robert Christian
I guess I can just write my own consolidation logic.
I want to write a strategy to trade morning volatility on small cap and low-priced stocks. I've seen how to use `QCAlgorithm::AddUniverse`, but can I use it for this purpose? Are stocks ever added/removed intra-day, or does it only happen after market close? Will OnData be called or do I have to call AddEquity for OnData to run? I don't see a matching RemoveEquity method.
Derek Melchin
Hi Robert,
Securities are added/removed from the universe once a day. Refer to this related thread for information on narrowing down the universe based on intraday performance.
To subscribe to premarket data when using a universe selection model, we need to add the following line to Initialize
self.UniverseSettings.ExtendedMarketHours = True
When using the `AddEquity` method instead, we can request extended market data by passing True as the last argument. For example,
self.AddEquity("SPY", Resolution.Daily, Market.USA, True, 1.0, True)
OnData is only every called if we subscribe the algorithm to some data source. To unsubscribe to a security, we can use `RemoveSecurity`. See the attached backtest for reference.
Best,
Derek Melchin
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.
Robert Christian
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!