Back

Universe consisting of all SPY stocks

How can I get a Universe consisting of all stocks which are part of common indices, such as SPY, or Nasdaq100? 

symbols = [ Symbol.Create("SPY", SecurityType.Equity, Market.USA) ]

# set algorithm framework models
self.SetUniverseSelection(ManualUniverseSelectionModel(symbols))

Only selects the SPY etf.

This should be a standard problem, but I could not find anything in the examples.

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.


Great to see you're using the algorithm framework! The algorithm framework breaks down designing a strategy into Universe Selection, Alpha Creation, Portfolio Construction, Execution and Risk Management. Universe Selection, lets you select a universe with self.SetUniverseSelection(_universe_selection_model). In the code above you selected the manual selection model, which provides a fixed amount of assets. That is the reason why SPY is the only selection. Changing the model to the fundamental selection model will allow you to determine the universe off of coarse price and fundemental data. The bottom link shows an implementation of this very similar to what is trying to be achieved. Note that this is one of a few models that will be needed for the algorithm framework to work.

https://www.quantconnect.com/docs/algorithm-framework/universe-selectionhttps://github.com/QuantConnect/Lean/blob/master/Algorithm.Framework/Selection/QC500UniverseSelectionModel.py
0

Thanks for your help, but I don't really get it. Is there no simple way to set all stocks contained in the S&P500 as trading Universe? 

0

Sorry - I just found out that you have massively improved the Algorithm Framework environment. The project wizzard is especially helpful and provides among many others a template for QC500-Universe selection.

Kudos!

0

Hi Filib.

The index composition for the S&P 500 and other common indices are not available yet. However, you can use the custom universe selection model QC500, which closely mirrors the composition of the S&P 500.

For further information, check out this documentation section on Universes and also this QC500 example algorithm.

1

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