This is probably a misunderstanding on how data and universes work together in QuantConnect. The documentation states "When no universes are asking for data, the asset is removed from your algorithm"
However, in a simple test, I create a course universe filter which returns exactly 20 securities. I then simply log the number of securities currently in the 'Securities' object. The number of securities in that object continues to grow beyond 20.
I would have expected the 'Securities' object to always contain exactly the securities returned by the universe filter?
Am I missing something? See the attached backtest and inspect the logs to view this behavior.
Dan Whitnable
Instead of inspecting the length of the 'Securities' object I decided to look at the length of the 'slice' of data in the 'OnData' method. This seems to better reflect the results from the universe filter and doesn't continue to grow. Securities do seem to be getting removed, however, the securities in the 'slice' are sometimes off by one or two from those returned in the universe.
Again, am I missing something. Do the securities in the 'slice' object reflect the results from the universe filter. What is the timing for getting removed?
The attached backtest shows this. See the logs.
Jared Broad
The subscription is removed but not the object itself as we save it to record trades/fees etc.
If you have holdings the subscription also isnt removed.
We could probably make this clearer by adding "HasData" property to the security object.
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.
Dan Whitnable
Jared,
Thanks for the explanation. I stumbled upon that fact in another post here in the forums shortly after posting.
Would it be reasonable to say, typically, one never needs to access the 'Securities' object when using universes? The "Members" property of the universe holds the set of current securities? In a similar fashion, the slice object would be referenced to get technical data but not for determining which securities are in the universe at a given time. Again, it seems best to look at the universe "Members". Am I on the right track?
Bgrm1
Very helpful share for people from Quantopian like me! Thanks for this Dan.
Colin fritz
I still don't quite understand this issue. Why does the Slice object not inlcude data on all of the securities in the ActiveSecurities list (which I understand to hold the most recent universe selection of securities)?
Dan Whitnable
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!