QuantConnect

US Equity Coarse Universe

Introduction

The US Equity Coarse Universe dataset by QuantConnect is a daily universe of all trading stocks in the US for a given day with the end of day price and volume. The data covers 30,000 US Equities in total, with approximately 8,000 Equities per day. The data starts in January 1998 and is delivered each trading day. This dataset is created by taking the closing auction price tick from the daily L1 trade and quote exchange dumps.

This dataset depends on the US Equities by AlgoSeek dataset because universe selection adds and removes market data subscriptions and on the US Equity Security Master dataset because the US Equity Security Master dataset contains information on splits, dividends, and symbol changes.

QuantConnect/LEAN combines the data of this dataset with MorningStar Fundamental data in runtime. You can use this dataset in local development without the Morningstar counterpart.

For more information about the US Equity Coarse Universe dataset, including CLI commands and pricing, see the dataset listing.

About the Provider

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.

Getting Started

The following snippet demonstrates how to request data from the US Equity Coarse Universe dataset:

  • Direct Access using the Security object
equity = self.add_equity("IBM")
ibm_fundamental = equity.fundamentals
var equity = AddEquity("IBM");
var ibmFundamental = equity.Fundamentals;
  • Direct Access using the Symbol object
ibm = Symbol.create("IBM", SecurityType.EQUITY, Market.USA)
ibm_fundamental = self.fundamentals
var ibm = QuantConnect.Symbol.Create("IBM", SecurityType.Equity, Market.USA);
var ibmFundamental = Fundamentals(ibm);
  • Universe Selection
def initialize(self) -> None:
    # Universe selection
    self._universe = self.add_universe(self.fundamental_filter_function)

def fundamental_filter_function(self, fundamental: List[Fundamental]):
    # Sort all equities with price above $10 by dollar volume
    sorted_by_dollar_volume = sorted([f for f in fundamental if f.price > 10],
                                key=lambda f: f.dollar_volume, reverse=True)
    # Take the top 10
    return [f.symbol for f in sorted_by_dollar_volume[:10]]
public override void Initialize()
{
    // Universe selection
    _universe = AddUniverseSelection(new FundamentalUniverseSelectionModel(FundamentalFilterFunction));
}

public override List<Symbol> FundamentalFilterFunction(List<Fundamental> fundamental)
{
    // Sort all equities with price above $10 by dollar volume, take the top 10
    return (from f in fundamental
            where f.Price > 10
            orderby f.DollarVolume descending
            select f.Symbol).Take(10);
}

Data Summary

The following table describes the dataset properties:

PropertyValue
Start DateJanuary 1998
Asset Coverage30,000 US Equities
Data DensityDense
ResolutionDaily
TimezoneNew York

Example Applications

The US Equity Coarse Universe dataset enables you to accurately design a universe of US Equities. Examples include the following strategies:

  • Selecting securities with the largest dollar volume
  • Selecting securities within a specific price range
  • Selecting securities that have fundamental data available (together with MorningStar Fundamental data in Fundamental objects)

For more example algorithms, see Examples.

Data Point Attributes

The US Equity Coarse Universe dataset provides its data within Fundamental objects, which have the following . The attributes from market_capMarketCap to asset_classificationAssetClassification listed in the following widget are NaN until this dataset is combined with the MorningStar Fundamental dataset.

Requesting Data

You don't need any special code to request US Coarse Fundamental Data. You can access the current and historical fundamental data for any of the US Equities that this dataset includes.

class CoarseFundamentalDataAlgorithm(QCAlgorithm):

    def initialize(self) -> None:
        self.set_start_date(2021, 1, 1)
        self.set_end_date(2021, 7, 1)
        self.set_cash(100000) 
        self.universe_settings.asynchronous = True

        # Option 1: Subscribe to individual US Equity assets
         self.add_equity("IBM")  

        # Option 2A: Create a fundamental universe (classic version)
         self._universe = self.add_universe(self.fundamental_function)

        # Option 2B: Create a fundamental universe (framework version)
        self.add_universe_selection(FundamentalUniverseSelectionModel(self.fundamental_function))
namespace QuantConnect
{
    public class CoarseFundamentalDataAlgorithm : QCAlgorithm
    {
    	private Universe _universe:
        public override void Initialize()
        {
            SetStartDate(2021, 1, 1);
            SetEndDate(2021, 7, 1);
            SetCash(100000);
            UniverseSettings.Asynchronous = True;
            
            // Option 1: Subscribe to individual US Equity assets
            AddEquity("IBM");

            // Option 2A: Create a fundamental universe (classic version)
            _universe = AddUniverse(FundamentalFilterFunction);

            // Option 2B: Create a fundamental universe (framework version)
            AddUniverseSelection(new FundamentalUniverseSelectionModel(FundamentalFilterFunction));
        }
    }
}

For more information about universe settings, see Settings.

Accessing Data

If you add a fundamental universe to your algorithm, you can access fundamental data in the universe selection function.

def fundamental_function(self, fundamental: List[Fundamental]) -> List[Symbol]:
    sorted_by_dollar_volume = sorted(fundamental, key=lambda x: x.dollar_volume, reverse=True)[:3]
    for cf in sorted_by_dollar_volume:
        self.debug(f"{cf.end_time} :: {cf.symbol} : {cf.adjusted_price} :: {cf.dollar_volume}")

    return [ x.symbol for x in sortedByDollarVolume]
public IEnumerable<Symbol> FundamentalFunction(IEnumerable<Fundamental> fundamental)
{
    var sortedByDollarVolume = fundamental
        .OrderByDescending(x => x.DollarVolume)
        .Take(3).ToList();

    foreach (var cf in sortedByDollarVolume)
    {
        Debug($"{cf.EndTime} :: {cf.Symbol} : {cf.AdjustedPrice} :: {cf.DollarVolume}");
    }

    return sortedByDollarVolume.Select(x => x.Symbol);
}

To get fundamental data for Equities in your algorithm, use the Fundamentalsfundamentals property of the Equity objects. The fundamental data represent the corporate fundamentals for the current algorithm time.

fundamentals = self.securities[symbol].fundamentals
var fundamentals = Securities[symbol].Fundamentals;

To get fundamental data for Equities, regardless of whether or not you have subscribed to them in your algorithm, call the Fundamentalsfundamentals method. If you pass one Symbol, the method returns a Fundamental object. If you pass a list of Symbol objects, the method returns a list of Fundamental objects.

// Single asset 
var ibm = QuantConnect.Symbol.Create("IBM", SecurityType.Equity, Market.USA);
var ibmFundamental = Fundamentals(ibm);

// Multiple assets
var nb = QuantConnect.Symbol.Create("NB", SecurityType.Equity, Market.USA);
var fundamentals = Fundamentals(new List<Symbol>{ nb, ibm }).ToList();
# Single asset
ibm = Symbol.create("IBM", SecurityType.EQUITY, Market.USA)
ibm_fundamental = self.fundamentals(ibm)

# Multiple assets
nb = Symbol.create("NB", SecurityType.EQUITY, Market.USA)
fundamentals = self.fundamentals([ nb, ibm ])

Historical Data

You can get historical fundamental data in an algorithm and in the Research Environment.

Historical Data in Algorithms

To get historical fundamental data in an algorithm, call the Historyhistory method with Fundamental type and the Equity Symbol. If there is no data in the period you request, the history result is empty.

var ibm = QuantConnect.Symbol.Create("IBM", SecurityType.Equity, Market.USA);

// Fundamental objects
var fundamentalHistory = History<Fundamental>(ibm, TimeSpan.FromDays(30));

// Fundamentals objects for all US Equities (including delisted companies)
var fundamentalsHistory = History<Fundamentals>(TimeSpan.FromDays(30));

// Collection of Fundamental objects for all US Equities (including delisted companies)
var collectionHistory = History(_universe, 30, Resolution.Daily);
foreach (var fundamental in collectionHistory)
{
    // Cast to Fundamental is required
    var mostLiquid = fundamental.OfType<Fundamental>().OrderByDescending(x => x.DollarVolume).Take(5);
}
ibm = Symbol.create("IBM", SecurityType.EQUITY, Market.USA)

# DataFrame of fundamental data for a given asset
df_history = self.history(Fundamental, ibm, timedelta(30), flatten=True)

# Fundamental objects
fundamental_history = self.history[Fundamental](ibm, timedelta(30))

# Fundamentals objects for all US Equities (including delisted companies)
fundamentals_history = self.history[Fundamentals](timedelta(30))

# DataFrame of fundamental data for universe constituents
df_history = self.history(self._universe, 30, Resolution.DAILY, flatten=True)

# Series of fundamental data for universe constituents
series_history = self.history(self._universe, 30, Resolution.DAILY)
for (universe_symbol, time), fundamental in series_history.items():
    most_liquid = sorted(fundamental, key=lambda x: x.dollar_volume)[-5:]

Historical Universe Data in Research

To get historical universe data in the Research Environment, call the UniverseHistoryuniverse_history method with the Universe object and the lookback period. This method returns the filtered universe. If there is no data in the period you request, the history result is empty.

var universeHistory = qb.UniverseHistory(universe, qb.Time.AddDays(-30), qb.Time);
foreach (var fundamentals in universeHistory)
{
    foreach (Fundamental fundamental in fundamentals)
    {
        Console.WriteLine($"{fundamental.Symbol} dollar volume at {fundamental.EndTime}: {fundamental.DollarVolume}");
    }
}
# DataFrame of fundamental data for universe constituents
df_history = qb.universe_history(universe, qb.time-timedelta(30), qb.time, flatten=True)

# Series of fundamental data for universe constituents
series_history = qb.universe_history(universe, qb.time-timedelta(30), qb.time)
for (universe_symbol, time), fundamentals in series_history.items():
    for fundamental in fundamentals:
        print(f"{fundamental.symbol} dollar volume at {fundamental.end_time}: {fundamental.dollar_volume}")

For more information about historical US Equity fundamental data, see Equity Fundamental Data.

Example Applications

The US Equity Coarse Universe dataset enables you to accurately design a universe of US Equities. Examples include the following strategies:

  • Selecting securities with the largest dollar volume
  • Selecting securities within a specific price range
  • Selecting securities that have fundamental data available (together with MorningStar Fundamental data in Fundamental objects)

For more example algorithms, see Examples.

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: