Universe Selection

Manual Universes

Introduction

The ManualUniverseSelectionModel selects a static, fixed set of assets. It is similar to adding securities with the traditional AddSecurity API methods. If your algorithm has a static universe, you can use automatic indicators instead of manual indicators in your algorithm.

Manual universes can be prone to look-ahead bias. For example, if you select a set of securities that have performed well during the backtest period, you are incorporating information from the future into the backtest and the algorithm may underperform in live mode.

Add Manual Universe Selection

To add a ManualUniverseSelectionModel to your algorithm, in the Initialize method, call the AddUniverseSelection method. The ManualUniverseSelectionModel constructor expects a list of Symbol objects that represent the universe constituents. To create the Symbol objects, call the Symbol.Create method.

var tickers = new[] {"SPY", "QQQ", "TLT"};
var symbols = tickers.Select(ticker => QuantConnect.Symbol.Create(ticker, SecurityType.Equity, Market.USA));
AddUniverseSelection(new ManualUniverseSelectionModel(symbols));
tickers = ["SPY", "QQQ", "TLT"]
symbols = [ Symbol.Create(ticker, SecurityType.Equity, Market.USA) for ticker in tickers]
self.AddUniverseSelection(ManualUniverseSelectionModel(symbols))

To view the implementation of this model, see the LEAN GitHub repositoryLEAN GitHub repository.

You can also see our Videos. You can also get in touch with us via Discord.

Did you find this page helpful?

Contribute to the documentation: