I'm trying tom understand why I see the universe count growing each day. Looking at the variable Securities.Count and see it incease every day even though the selection is for the top 5. Is there a way to tell wich securities are active?
I'm trying tom understand why I see the universe count growing each day. Looking at the variable Securities.Count and see it incease every day even though the selection is for the top 5. Is there a way to tell wich securities are active?
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.
You can remove the symbol in "Securities" with
foreach (var security in _changes.RemovedSecurities)
{
Securities.Remove(security.Symbol);
}
When using the scheduled event method, please specify an equity symbol for the method to track the market hours
AddEquity("SPY", Resolution.Minute);
Schedule.On(DateRules.EveryDay("SPY"), TimeRules.At(09, 45), CountUniv);
Jing Wu
I added the reference to SPY and now my algo trades SPY, not what I want. It appeard to work wthout the refering to SPY, what it the issue with not refering to a securty?
Thanks for the input.
I modified my code and added my own list to store the universe, then on universe change I add and remove securities. Seems to be stable at five securities as exected now.
It seems odd that the universe continues to grow when the the call is to take the top 5 each time. Is there some reason why that occurs?
Hi Gordon,
The snippet that Jing sent you was just an example of how you would schedule an event for SPY. Given your Current schedule rules, you can omit any reference to security names and simply call Schedule.On(DateRules.EveryDay(), TimeRules.At(09, 0), CountUniv) which will apply CountUniv to the entire universe every day at 9am.
Rather than needing to create a custom function, examining and counting the active securities in your universe can be done using the ActiveSecurities data dictionary. ActiveSecurities provides information about assets currently in your universe, which is useful for iterating over those securities from your universe selection. The securities in this dictionary have the same properties as the Securities collection.
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!