book
Checkout our new book! Hands on AI Trading with Python, QuantConnect, and AWS Learn More arrow

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
Select Language:
equity = self.add_equity("IBM")
ibm_fundamental = equity.fundamentals
  • Direct Access using the Symbol object
Select Language:
ibm = Symbol.create("IBM", SecurityType.EQUITY, Market.USA)
ibm_fundamental = self.fundamentals
  • Universe Selection
Select Language:
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]]

Data Summary

The following table describes the dataset properties:

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

This dataset doesn't include Over-the-Counter (OTC) stocks.

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_cap to asset_classification 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.

Select Language:
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))

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.

Select Language:
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]

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

Select Language:
fundamentals = self.securities[symbol].fundamentals

To get fundamental data for Equities, regardless of whether or not you have subscribed to them in your algorithm, call the fundamentals 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.

Select Language:
# 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 history method with Fundamental type and the Equity Symbol. If there is no data in the period you request, the history result is empty.

Select Language:
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 universe_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.

Select Language:
# 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: