---
title: "Universes"
description: "Universe selection is the process of selecting a basket of assets to research. Dynamic universe selection decreases selection bias in your analysis."
canonical: https://www.quantconnect.com/docs/v2/research-environment/universes
markdown: https://www.quantconnect.com/docs/v2/research-environment/universes.md
language: python
source: https://github.com/QuantConnect/Documentation/tree/master/04%20Research%20Environment/05%20Universes
modified: 2026-10-30
index: https://www.quantconnect.com/llms.txt
---

# Universes

[Documentation](https://www.quantconnect.com/docs/v2.md) > [Research Environment](https://www.quantconnect.com/docs/v2/research-environment.md) > Universes

> Code examples are shown in Python. Append `?lang=csharp` to this URL for the C# version of this page.

## Introduction

Universe selection is the process of selecting a basket of assets to research. Dynamic universe selection increases diversification and decreases [selection bias](https://en.wikipedia.org/wiki/Selection_bias) in your analysis.

## Get Universe Data

Universes are data types. To get historical data for a universe, pass the universe data type to the `UniverseHistory` method. The object that returns contains a universe data collection for each day. With this object, you can iterate through each day and then iterate through the universe data objects of each day to analyze the universe constituents.

### Fundamental Universes

Follow these steps to get the US Equity Fundamental data for a specific universe:

1. Create a `QuantBook`.
   ```python
   qb = QuantBook()
   ```
2. Define a universe.
   The following example defines a dynamic universe that contains the 10 Equities with the lowest PE ratios in the market. To see all the `Fundamental` attributes you can use to define a filter function for a Fundamental universe, see [Data Point Attributes](https://www.quantconnect.com/docs/v2/writing-algorithms/datasets/morningstar/us-fundamental-data.md#99-Data-Point-Attributes). To create the universe, call the `add_universe` method with the filter function.
   ```python
   def filter_function(fundamentals):
       sorted_by_pe_ratio = sorted(
           [f for f in fundamentals if not np.isnan(f.valuation_ratios.pe_ratio)],
           key=lambda fundamental: fundamental.valuation_ratios.pe_ratio
       )
       return [fundamental.symbol for fundamental in sorted_by_pe_ratio[:10]]

   universe = qb.add_universe(filter_function)
   ```
3. Call the `universe_history` method with the universe, a start date, and an end date.
   ```python
   universe_history = qb.universe_history(universe, datetime(2023, 11, 6), datetime(2023, 11, 13))
   ```
   The end date arguments is optional. If you omit it, the method returns `Fundamental` data between the start date and the current day.
   The `universe_history` method returns a Series where the multi-index is the universe `Symbol` and the time when universe selection would occur in a backtest. Each row in the data column contains a list of `Fundamental` objects. The following image shows the first 5 rows of an example Series:
   ![Historical fundamental universe dataframe](https://cdn.quantconnect.com/i/tu/universe-selection-history-dataframe-python.png)
   To get a flat DataFrame instead of a Series, set the `flatten` argument to `True`.
4. Iterate through the Series to access the universe data.
   ```python
   universe_history = universe_history.droplevel('symbol', axis=0)
   for date, fundamentals in universe_history.items():
       for fundamental in fundamentals:
           symbol = fundamental.symbol
           price = fundamental.price
           if fundamental.has_fundamental_data:
               pe_ratio = fundamental.valuation_ratios.pe_ratio
   ```

### ETF Constituents Universes

Follow these steps to get the data of a specific ETF Constituents universe:

1. Create a `QuantBook`.
   ```python
   qb = QuantBook()
   ```
2. Define a universe.
   The following example defines a dynamic universe that contains the 3 Equities with the largest weight in the SPY ETF. To see all the `ETFConstituentUniverse` attributes you can use to define a filter function for an ETF Constituents universe, see [Data Point Attributes](https://www.quantconnect.com/docs/v2/writing-algorithms/datasets/quantconnect/us-etf-constituents.md#99-Data-Point-Attributes). To create the universe, call the `universe.etf` method with the ETF ticker and the selection function, then pass the result to the `add_universe` method.
   ```python
   def select_assets(constituents: List[ETFConstituentUniverse]) -> List[Symbol]:
       sorted_by_weight = sorted([c for c in constituents if c.weight], key=lambda c: c.weight)
       return [c.symbol for c in sorted_by_weight[-3:]]

   universe = qb.add_universe(qb.universe.etf('SPY', universe_filter_func=select_assets))
   ```
3. Call the `universe_history` method with the universe, a start date, and an end date.
   ```python
   universe_history = qb.universe_history(universe, datetime(2025, 11, 6), datetime(2025, 11, 11))
   ```
   The end date arguments is optional. If you omit it, the method returns `ETFConstituentUniverse` data between the start date and the current day.
   The `universe_history` method returns a Series where the multi-index is the universe `Symbol` and the time when universe selection would occur in a backtest. Each row in the data column contains a list of `ETFConstituentUniverse` objects. Here is an example of a Series:
   ```python
   time
   2025-11-07    [AAPL R735QTJ8XC9X: ¤0.00, MSFT R735QTJ8XC9X: ...
   2025-11-08    [AAPL R735QTJ8XC9X: ¤0.00, MSFT R735QTJ8XC9X: ...
   2025-11-11    [AAPL R735QTJ8XC9X: ¤0.00, MSFT R735QTJ8XC9X: ...
   Name: data, dtype: object
   ```
   To get a flat DataFrame instead of a Series, set the `flatten` argument to `True`.
   ```python
   qb.universe_history(universe, datetime(2025, 11, 6), datetime(2025, 11, 11), flatten=True)
   ```
   | time | symbol | lastupdate | period | sharesheld | weight |
   | --- | --- | --- | --- | --- | --- |
   | 2025-11-07 | AAPL R735QTJ8XC9X | 2025-11-05 | 1 days | 178991437.0 | 0.069116 |
   | 2025-11-07 | MSFT R735QTJ8XC9X | 2025-11-05 | 1 days | 89652295.0 | 0.064993 |
   | 2025-11-07 | NVDA RHM8UTD8DT2D | 2025-11-05 | 1 days | 294289223.0 | 0.082117 |
   | 2025-11-08 | AAPL R735QTJ8XC9X | 2025-11-06 | 1 days | 179242780.0 | 0.069801 |
   | 2025-11-08 | MSFT R735QTJ8XC9X | 2025-11-06 | 1 days | 89778184.0 | 0.064423 |
   | 2025-11-08 | NVDA RHM8UTD8DT2D | 2025-11-06 | 1 days | 294702444.0 | 0.080012 |
   | 2025-11-11 | AAPL R735QTJ8XC9X | 2025-11-07 | 1 days | 178922101.0 | 0.069303 |
   | 2025-11-11 | MSFT R735QTJ8XC9X | 2025-11-07 | 1 days | 89617567.0 | 0.064299 |
   | 2025-11-11 | NVDA RHM8UTD8DT2D | 2025-11-07 | 1 days | 294175231.0 | 0.079933 |
4. Iterate through the Series to access the universe data.
   ```python
   for date, constituents in universe_history.droplevel('symbol', axis=0).items():
       for constituent in constituents:
           symbol = constituent.symbol
           weight = constituent.weight
   ```

## Available Universes

The following table shows the datasets that support universe selection and their respective data type. For more information, about universe selection with these datasets and the data points you can use in the filter function, see the dataset's documentation.

| Dataset Name | Universe Type(s) | Documentation |
| --- | --- | --- |
| Binance Crypto Price Data | `CryptoUniverse` | [Learn more](https://www.quantconnect.com/docs/v2/writing-algorithms/datasets/quantconnect/binance-crypto-price-data.md) |
| Binance US Crypto Price Data | `CryptoUniverse` | [Learn more](https://www.quantconnect.com/docs/v2/writing-algorithms/datasets/quantconnect/binance-us-crypto-price-data.md) |
| Bitfinex Crypto Price Data | `CryptoUniverse` | [Learn more](https://www.quantconnect.com/docs/v2/writing-algorithms/datasets/quantconnect/bitfinex-crypto-price-data.md) |
| Bybit Crypto Price Data | `CryptoUniverse` | [Learn more](https://www.quantconnect.com/docs/v2/writing-algorithms/datasets/quantconnect/bybit-crypto-price-data.md) |
| Coinbase Crypto Price Data | `CryptoUniverse` | [Learn more](https://www.quantconnect.com/docs/v2/writing-algorithms/datasets/quantconnect/coinbase-crypto-price-data.md) |
| Factors | `FactorsUniverse` | [Learn more](https://www.quantconnect.com/docs/v2/writing-algorithms/datasets/quantconnect/factors.md) |
| International Future Universe | `FutureFilterUniverse` `FutureUniverse` | [Learn more](https://www.quantconnect.com/docs/v2/writing-algorithms/datasets/quantconnect/international-future-universe.md) |
| Kraken Crypto Price Data | `CryptoUniverse` | [Learn more](https://www.quantconnect.com/docs/v2/writing-algorithms/datasets/quantconnect/kraken-crypto-price-data.md) |
| Spectral Tick Flow Signal | `SpectralTickFlowSignalUniverse` | [Learn more](https://www.quantconnect.com/docs/v2/writing-algorithms/datasets/quantconnect/spectral-tick-flow-signal.md) |
| US ETF Constituents | `ETFConstituentUniverse` | [Learn more](https://www.quantconnect.com/docs/v2/writing-algorithms/datasets/quantconnect/us-etf-constituents.md) |
| US Equity Option Universe | `OptionFilterUniverse` `OptionUniverse` | [Learn more](https://www.quantconnect.com/docs/v2/writing-algorithms/datasets/quantconnect/us-equity-option-universe.md) |
| US Future Option Universe | `OptionFilterUniverse` `OptionUniverse` | [Learn more](https://www.quantconnect.com/docs/v2/writing-algorithms/datasets/quantconnect/us-future-option-universe.md) |
| US Future Universe | `FutureFilterUniverse` `FutureUniverse` | [Learn more](https://www.quantconnect.com/docs/v2/writing-algorithms/datasets/quantconnect/us-future-universe.md) |
| US Index Option Universe | `OptionFilterUniverse` `OptionUniverse` | [Learn more](https://www.quantconnect.com/docs/v2/writing-algorithms/datasets/quantconnect/us-index-option-universe.md) |
| Brain Language Metrics on Company Filings | `BrainCompanyFilingLanguageMetricsUniverse` | [Learn more](https://www.quantconnect.com/docs/v2/writing-algorithms/datasets/brain/brain-language-metrics-on-company-filings.md) |
| Brain ML Stock Ranking | `BrainStockRankingUniverse` | [Learn more](https://www.quantconnect.com/docs/v2/writing-algorithms/datasets/brain/brain-ml-stock-ranking.md) |
| Brain Sentiment Indicator | `BrainSentimentIndicatorUniverse` | [Learn more](https://www.quantconnect.com/docs/v2/writing-algorithms/datasets/brain/brain-sentiment-indicator.md) |
| Crypto Market Cap | `CoinGeckoUniverse` | [Learn more](https://www.quantconnect.com/docs/v2/writing-algorithms/datasets/coingecko/crypto-market-cap.md) |
| US Bank Financials | `FDICBankFinancialsUniverse` | [Learn more](https://www.quantconnect.com/docs/v2/writing-algorithms/datasets/federal-deposit-insurance-corporation/us-bank-financials.md) |
| OTC Transparency | `FINRAShortInterestUniverse` `FINRAWeeklySummaryUniverse` `FINRAMonthlySummaryUniverse` | [Learn more](https://www.quantconnect.com/docs/v2/writing-algorithms/datasets/financial-industry-regulatory-authority/otc-transparency.md) |
| Regulation SHO | `FINRAShortSaleVolumeUniverse` | [Learn more](https://www.quantconnect.com/docs/v2/writing-algorithms/datasets/financial-industry-regulatory-authority/regulation-sho.md) |
| CNBC Trading | `QuiverCNBCsUniverse` | [Learn more](https://www.quantconnect.com/docs/v2/writing-algorithms/datasets/quiver-quantitative/cnbc-trading.md) |
| Corporate Lobbying | `QuiverLobbyingUniverse` | [Learn more](https://www.quantconnect.com/docs/v2/writing-algorithms/datasets/quiver-quantitative/corporate-lobbying.md) |
| Insider Trading | `QuiverInsiderTradingUniverse` | [Learn more](https://www.quantconnect.com/docs/v2/writing-algorithms/datasets/quiver-quantitative/insider-trading.md) |
| US Congress Trading | `QuiverQuantCongressUniverse` | [Learn more](https://www.quantconnect.com/docs/v2/writing-algorithms/datasets/quiver-quantitative/us-congress-trading.md) |
| US Government Contracts | `QuiverGovernmentContractUniverse` | [Learn more](https://www.quantconnect.com/docs/v2/writing-algorithms/datasets/quiver-quantitative/us-government-contracts.md) |
| Corporate Buybacks | `SmartInsiderIntentionUniverse` `SmartInsiderTransactionUniverse` | [Learn more](https://www.quantconnect.com/docs/v2/writing-algorithms/datasets/smart-insider/corporate-buybacks.md) |
| Patent Maintenance | `USPTOPatentMaintenanceUniverse` | [Learn more](https://www.quantconnect.com/docs/v2/writing-algorithms/datasets/united-states-patent-and-trademark-office/patent-maintenance.md) |

To get universe data for Futures and Options, use the `future_history` and `option_history` methods, respectively.

## Examples

The following examples demonstrate some common practices for universe research.

### Example 1: Top-Minus-Bottom PE Ratio

The below example studies the top-minus-bottom PE Ratio universe, in which the top 10 PE Ratio stocks are brought, and the bottom 10 are sold in equal weighting daily. We carry out a mini-backtest to analyze its performance.

```python
# Instantiate the QuantBook instance for researching.
qb = QuantBook()

# Set start and end dates of the research to avoid look-ahead bias.
start = datetime(2021, 1, 1)
end = datetime(2021, 4, 1)
qb.set_start_date(end)

# Request data for research purposes.
# We are interested in the most liquid primary stocks.
universe = qb.add_universe(
    lambda datum: [x.symbol for x in sorted(
        [f for f in datum],
        key=lambda f: f.dollar_volume
    )[-100:]]
)

# Historical data call for the data to be compared and tested.
universe_history = qb.universe_history(universe, start, end).droplevel([0])
# All symbols' daily prices are for return comparison.
history = qb.history(
    [x.symbol for x in set(
        e for datum in universe_history.values.flatten() for e in datum
    )],
    start,
    end,
    Resolution.DAILY
).close.unstack(0)

# Change the index format for matching.
universe_history.index = universe_history.index.date
history.index = history.index.date
# Process the historical data to generate a signal and return it for research.
bottom_liquid_universe_history = universe_history.apply(
    lambda datum: [x.symbol for x in sorted(
        datum,
        key=lambda d: d.dollar_volume
    )[:10]]
)
top_liquid_universe_history = universe_history.apply(
    lambda datum: [x.symbol for x in sorted(
        datum,
        key=lambda d: d.dollar_volume,
        reverse=True
    )[:10]]
)
ret = history.pct_change().dropna()

# Keep the entries that have common indices for a fair comparison.
common_index = list(set(ret.index).intersection(universe_history.index))
ret = ret.loc[common_index].apply(
    lambda x: x[top_liquid_universe_history.loc[x.name]].sum()*0.1\
        - x[bottom_liquid_universe_history.loc[x.name]].sum()*0.1,
    axis=1
)

# Plot the data for visualization. It is easier to study the pattern.
fig = plt.figure(figsize=(8, 8))
ax = fig.add_subplot()

# Use line plot to present time series.
ax.plot(ret.sort_index())

# Set axis and titles to explain the plot.
ax.set_xlabel("Time")
ax.set_ylabel("Return")
ax.set_title("Top Minus Bottom Liquidity Return")

plt.show()
```
