Equity

ETF Constituents Universes

Introduction

An ETF constituents universe lets you select a universe of securities in an exchange traded fund. The US ETF Constituents dataset includes 2,650 US ETFs you can use to create your universe.

Create Universes

To add an ETF Constituents universe, call the Universe.ETF method.

public class ETFConstituentsAlgorithm : QCAlgorithm
{
    public override void Initialize() 
    {
        AddUniverse(Universe.ETF("SPY", Market.USA, UniverseSettings));
    }
}
class ETFConstituentsAlgorithm(QCAlgorithm):
    def Initialize(self) -> None:        
        self.AddUniverse(self.Universe.ETF("SPY", Market.USA, self.UniverseSettings))

The following table describes the ETF method arguments:

Argument: etfTicker

The ETF ticker. To view the supported ETFs in the US ETF Constituents dataset, see Supported ETFs.

Data Type: stringstr | Default Value: None

Argument: market

The market of the ETF. If you don't provide an argument, it uses the default Equity market of the brokerage model.

Data Type: stringstr | Default Value: None

Argument: universeSettings

The universe settings. If you don't provide an argument, it uses the algorithm UniverseSettings.

Data Type: UniverseSettings | Default Value: None

Argument: universeFilterFunc

A function to select some of the ETF constituents for the universe. If you don't provide an argument, it selects all of the constituents.

Data Type: Func<IEnumerable<ETFConstituentData>, IEnumerable<Symbol>>Callable[[List[ETFConstituentData]], List[Symbol]] | Default Value: nullNone

To select a subset of the ETF constituents, provide a universeFilterFunc argument. The filter function receives ETFConstituentData objects, which represent one of the ETF constituents. ETFConstituentsData objects have the following attributes:

public class ETFConstituentsAlgorithm : QCAlgorithm 
{
    public override void Initialize() 
    {
        var universe = Universe.ETF("SPY", Market.USA, UniverseSettings, ETFConstituentsFilter);
        AddUniverse(universe);
    }

    private IEnumerable<Symbol> ETFConstituentsFilter(IEnumerable<ETFConstituentData> constituents)
    {
        // Get the 10 securities with the largest weight in the index
        return constituents.OrderByDescending(c => c.Weight).Take(10).Select(c => c.Symbol);
    }
}
class ETFConstituentsAlgorithm(QCAlgorithm):
    def Initialize(self) -> None:
        universe = self.Universe.ETF("SPY", Market.USA, self.UniverseSettings, self.ETFConstituentsFilter)
        self.AddUniverse(universe)

    def ETFConstituentsFilter(self, constituents: List[ETFConstituentData]) -> List[Symbol]:
        # Get the 10 securities with the largest weight in the index
        selected = sorted([c for c in constituents if c.Weight],
            key=lambda c: c.Weight, reverse=True)[:10]
        return [c.Symbol for c in selected]

Selection Frequency

Equity universes run on a daily basis.

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: