I would like to add a consolidator for the symbols I select during Universe selection. The problem is that you have to subscribe to a symbol before you can add a consolidator for that symbol, which means (as far as I know) it can't be done inside the universe seleciton function. I attempted to add the consolidator in the OnSecuritiesChanged function but then the consolidator won't be added if no changes are made in the Universe (I am not only adding a consolidator here so it is important that this runs after every universe selection on all selected symbols even if they are already in the universe). Is there a clean way of doing this? Here is a couple of solutions I have thought off, although I am not a fan of them:
- Manually adding securities to my custom universe using self.AddEquity inside the universe selection function, and return no symbols from the universe selection function (so it is not added twice). Don't like this as I would need to remove the securities each day manually as well.
- Create a scheduled event to add a consolidator to all universe symbols after the Universe selection function has run. Kinda messy in my opinion, and the universe selection function may run at slightly different times each day.
Haakon
The second option also has the issue that the OnData function require the consolidator to exist which it will not until the scheduled function has run.
Haakon
For those interested: I ended up going with the second solution - created a scheduled event after universe selection and added the consolidators then. The universe selection is ran between 7 and 8 AM Eastern Time (ET) when live trading so make sure to set the scheduled event later than that.Â
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!