About US ETF Constituents

The US ETF Constituents dataset by QuantConnect tracks the constituents and weighting of US Equities in 2,650 ETF listings. The data starts in January 2009 and is delivered on a daily basis. This dataset is created by tracking the host ETF websites and can be delayed by up to 1 week.


About QuantConnect

QuantConnect was founded in 2012 to serve quants everywhere with the best possible algorithmic trading technology. Seeking to disrupt a notoriously closed-source industry, QuantConnect takes a radically open-source approach to algorithmic trading. Through the QuantConnect web platform, more than 160,000 quants are served every month.


About QuantConnect

QuantConnect was founded in 2012 to serve quants everywhere with the best possible algorithmic trading technology. Seeking to disrupt a notoriously closed-source industry, QuantConnect takes a radically open-source approach to algorithmic trading. Through the QuantConnect web platform, more than 50,000 quants are served every month.


Algorithm Example

class ETFConstituentsDataAlgorithm(QCAlgorithm):

    def Initialize(self) -> None:
        self.SetStartDate(2016, 1, 1)
        self.SetEndDate(2021, 1, 1)
        self.SetCash(100000)
        
        self.UniverseSettings.Resolution = Resolution.Minute
        
        # Requesting data
        self.spy = self.AddEquity("SPY").Symbol
        self.AddUniverse(self.Universe.ETF(self.spy, self.UniverseSettings, self.ETFConstituentsFilter))
        
        self.weightBySymbol = {}
        
        self.Schedule.On(
            self.DateRules.EveryDay(self.spy),
            self.TimeRules.AfterMarketOpen(self.spy, 1),
            self.Rebalance)

    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]
        self.weightBySymbol = {c.Symbol: c.Weight for c in selected}
        
        return list(self.weightBySymbol.keys())

    def Rebalance(self) -> None:
        spyWeight = sum(self.weightBySymbol.values())

        if spyWeight > 0:
            for symbol in self.Portfolio.Keys:
                if symbol not in self.weightBySymbol:
                    self.Liquidate(symbol)
    
            for symbol, weight in self.weightBySymbol.items():
                self.SetHoldings(symbol, 0.5 * weight / spyWeight)
                
            self.SetHoldings(self.spy, -0.5)

    def OnSecurityChanged(self, changes: SecurityChanges) -> None:
        for security in changes.RemovedSecurities:
            if security.Invested:
                algorithm.Liquidate(security.Symbol, 'Removed From Universe')

        for security in changes.AddedSecurities:
            # Historical data
            history = self.History(security.Symbol, 7, Resolution.Daily)
            self.Debug(f'We got {len(history)} from our history request for {security.Symbol}')

Example Applications

The ETF Constituents dataset provides an excellent source of tradable universes for strategies without selection bias. When you use an ETF universe, the original ETF can serve as an excellent benchmark for your strategy performance. Other use cases include the following: