Back

Universe Growth

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?

Update Backtest








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);
0

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?

0


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.

0

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.


Update Backtest





0

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.


Loading...

This discussion is closed

 
";