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

AlgoSeek

US Equities

Introduction

The US Equities dataset by AlgoSeek is survivorship bias-free daily coverage of every stock traded in the US Securities Information Processors (SIP) CTA/UTP feed since 1998. The dataset covers approximately 27,500 securities, starts in January 1998, and is delivered in any resolution from tick to daily. The Data is collected from the full SIP feed via our Equinix co-located servers, including all trades and quotes published to every exchange as well as FINRA. Over-the-Counter (OTC) trades are not included.

This dataset depends on the US Equity Security Master dataset because the US Equity Security Master dataset contains information on splits, dividends, and symbol changes.

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

About the Provider

AlgoSeek is a leading historical intraday US market data provider offering the most comprehensive and detailed market data and analytics products in the financial industry covering Equities, Futures, Options, cash FOREX, and Cryptocurrencies. AlgoSeek data is built for quantitative trading and machine learning. For more information about AlgoSeek, visit algoseek.com.

Getting Started

AlgoSeek is the default US Equities dataset on QuantConnect. The following snippet demonstrates how to request data from the US Equities dataset:

self.aapl = self.add_equity("AAPL", Resolution.DAILY).symbol
_aapl = AddEquity("AAPL", Resolution.Daily).Symbol;

Data Summary

The following table describes the dataset properties:

PropertyValue
Start DateJanuary 1998
Asset Coverage27,500 US Equities
Data DensityDense
ResolutionTick, Second, Minute, Hourly, & Daily
TimezoneNew York
Market HoursRegular and Extended

Requesting Data

To add US Equities data to your algorithm, call the AddEquityadd_equity method. Save a reference to the Equity Symbol so you can access the data later in your algorithm.

class USEquityDataAlgorithm(QCAlgorithm):

    def initialize(self) -> None:
        self.set_start_date(2018, 1, 1)
        self.set_end_date(2021, 6, 1)
        self.set_cash(100000) 
        # Subscribe to AAPL data
        self.aapl = self.add_equity("AAPL", Resolution.MINUTE).symbol
public class USEquityDataAlgorithm : QCAlgorithm
{
    private Symbol _symbol; 
    
    public override void Initialize()
    {
        SetStartDate(2018, 1, 1);
        SetEndDate(2021, 6, 1);
        SetCash(100000);
        // Subscribe to AAPL data
        _aapl = AddEquity("AAPL", Resolution.Minute).Symbol;
    }
}

For more information about creating US Equity subscriptions, see Requesting Data or US Equity Universes.

Accessing Data

To get the current US Equities data, index the Barsbars, QuoteBarsquote_bars, or Ticksticks properties of the current Slice with the Equity Symbol. Slice objects deliver unique events to your algorithm as they happen, but the Slice may not contain data for your security at every time step. To avoid issues, check if the Slice contains the data you want before you index it.

def on_data(self, slice: Slice) -> None:
    # Access data: TradeBar data
    if self.aapl in slice.bars:
        trade_bar = slice.bars[self.aapl]
        self.log(f"{self.aapl} close at {slice.time}: {trade_bar.close}")

    # Access data: QuoteBar data
    if self.aapl in slice.quote_bars:
        quote_bar = slice.quote_bars[self.aapl]
        self.log(f"{self.aapl} bid at {slice.time}: {quote_bar.bid.close}")

    # Access data: Ticks data
    if self.aapl in slice.ticks:
        ticks = slice.ticks[self.aapl]
        for tick in ticks:
            self.log(f"{self.aapl} price at {slice.time}: {tick.price}")
public override void OnData(Slice slice)
{
    // Access data: TradeBar data
    if (slice.Bars.ContainsKey(_symbol))
    {
        var tradeBar = slice.Bars[_symbol];
        Log($"{_symbol} price at {slice.Time}: {tradeBar.Close}");
    }

    // Access data: QuoteBar data
    if (slice.QuoteBars.ContainsKey(_symbol))
    {
        var quoteBar = slice.QuoteBars[_symbol];
        Log($"{_symbol} bid at {slice.Time}: {quoteBar.Bid.Close}");
    }

    // Access data: Ticks data
    if (slice.Ticks.ContainsKey(_symbol))
    {
        var ticks = slice.Ticks[_symbol];
        foreach (var tick in ticks)
        {
            Log($"{_symbol} price at {slice.Time}: {tick.Price}");
        }
    }
}

You can also iterate through all of the data objects in the current Slice.

def on_data(self, slice: Slice) -> None:
    # Iterate all TradeBar received
    for symbol, trade_bar in slice.bars.items():
        self.log(f"{symbol} close at {slice.time}: {trade_bar.close}")

    # Iterate all QuoteBar received
    for symbol, quote_bar in slice.quote_bars.items():
        self.log(f"{symbol} bid at {slice.time}: {quote_bar.bid.close}")

    # Iterate all Ticks received
    for symbol, ticks in slice.ticks.items():
        for tick in ticks:
            self.log(f"{symbol} price at {slice.time}: {tick.price}")
public override void OnData(Slice slice)
{
    // Iterate all TradeBar received
    foreach (var kvp in slice.Bars)
    {
        var symbol = kvp.Key;
        var tradeBar = kvp.Value;
        Log($"{symbol} price at {slice.Time}: {tradeBar.Close}");
    }

    // Iterate all QuoteBar received
    foreach (var kvp in slice.QuoteBars)
    {
        var symbol = kvp.Key;
        var quoteBar = kvp.Value;
        Log($"{symbol} bid at {slice.Time}: {quoteBar.Bid.Close}");
    }

    // Iterate all Ticks received
    foreach (var kvp in slice.Ticks)
    {
        var symbol = kvp.Key;
        var ticks = kvp.Value;
        foreach (var tick in ticks)
        {
            Log($"{symbol} price at {slice.Time}: {tick.Price}");
        }
    }
}

For more information about accessing US Equities data, see Handling Data.

Historical Data

To get historical US Equity data, call the Historyhistory method with the Equity Symbol. If there is no data in the period you request, the history result is empty.

# DataFrame
history_df = self.history(self.aapl, 100, Resolution.DAILY)

# TradeBar objects
history_trade_bars = self.history[TradeBar](self.aapl, 100, Resolution.DAILY)

# QuoteBar objects
history_quote_bars = self.history[QuoteBar](self.aapl, 100, Resolution.MINUTE)

# Tick objects
history_ticks = self.history[Tick](self.aapl, timedelta(seconds=10), Resolution.TICK)
// TradeBar objects 
var historyTradeBars = History(_symbol, 100, Resolution.Daily);

// QuoteBar objects 
var historyQuoteBars = History<QuoteBar>(_symbol, 100, Resolution.Minute);

// Tick objects 
var historyTicks = History<Tick>(_symbol, TimeSpan.FromSeconds(10), Resolution.Tick);

For more information about historical data, see History Requests.

Universe Selection

To select a universe of US Equities, see Equity Universes.

Remove Subscriptions

To unsubscribe from a US Equity that you added with the AddEquityadd_equity method, call the RemoveSecurityremove_security method.

self.remove_security(self.aapl)
RemoveSecurity(_symbol);

The RemoveSecurityremove_security method cancels your open orders for the security and liquidates your holdings.

Supported Assets

To view the supported assets in the US Equities dataset, see the Data Explorer. This dataset doesn't include Over-the-Counter (OTC) stocks.

Example Applications

The US Equities dataset enables you to accurately design Equity trading strategies. Examples include the following strategies:

  • Momentum strategies using historical returns on the premise that the momentum will continue
  • Value strategies using fundamental factors on the premise that the price of undervalued securities will rise
  • Factor investing with periodic rebalancing

Classic Algorithm Example

The following example algorithm buys and holds Apple stock:

from AlgorithmImports import *
from QuantConnect.DataSource import *

class USEquityDataAlgorithm(QCAlgorithm):

    def initialize(self) -> None:
        self.set_start_date(2018, 1, 1)
        self.set_end_date(2021, 6, 1)
        self.set_cash(100000)
        
        # Requesting single equity data, since we only trade AAPL
        self.aapl = self.add_equity("AAPL", Resolution.DAILY).symbol
        
        # Historical data
        history = self.history(self.aapl, 60, Resolution.DAILY)
        self.debug(f"We got {len(history)} items from our history request")

    def on_data(self, slice: Slice) -> None:
        # Check if the current slice containing AAPL and if we hold any position
        # As we make use of the most updated price data to decide the order size
        if slice.contains_key(self.aapl) and slice[self.aapl] is not None and not self.portfolio.invested:
            self.set_holdings(self.aapl, 1)
public class USEquityDataAlgorithm : QCAlgorithm
{
    private Symbol _symbol;
    
    public override void Initialize()
    {
        SetStartDate(2018, 1, 1);
        SetEndDate(2021, 6, 1);
        SetCash(100000);

        // Requesting single equity data, since we only trade AAPL
        _symbol = AddEquity("AAPL", Resolution.Daily).Symbol;
        
        // Historical data
        var history = History(_symbol, 60, Resolution.Daily);
        Debug($"We got {history.Count()} items from our history request");
    }

    public override void OnData(Slice slice)
    {
        // Check if the current slice containing AAPL and if we hold any position
        // As we make use of the most updated price data to decide the order size
        if (slice.ContainsKey(_symbol) && slice[_symbol] != None && !Portfolio.Invested)
        {
            SetHoldings(_symbol, 1);
        }
    }
}

Framework Algorithm Example

The following example algorithm buys and holds Apple stock:

from AlgorithmImports import *
from QuantConnect.DataSource import *

class USEquityDataAlgorithm(QCAlgorithm):

    def initialize(self) -> None:
        self.set_start_date(2018, 1, 1)
        self.set_end_date(2021, 6, 1)
        self.set_cash(100000)
        
        self.universe_settings.resolution = Resolution.DAILY
        # To select only AAPL, use a manual selection universe
        symbols = [Symbol.create("AAPL", SecurityType.EQUITY, Market.USA)]
        self.add_universe_selection(ManualUniverseSelectionModel(symbols))    
        
        # Constant investment signal
        self.add_alpha(ConstantAlphaModel(InsightType.PRICE, InsightDirection.UP, timedelta(days=7), 0.025, None))
        
        # Invest in all members equally
        self.set_portfolio_construction(EqualWeightingPortfolioConstructionModel())
public class USEquityDataAlgorithm : QCAlgorithm
{
    public override void Initialize()
    {
        SetStartDate(2018, 1, 1);
        SetEndDate(2021, 6, 1);
        SetCash(100000);
        
        UniverseSettings.Resolution = Resolution.Daily;
        // To select only AAPL, use a manual selection universe
        var symbols = new[] {QuantConnect.Symbol.Create("AAPL", SecurityType.Equity, Market.USA)};
        AddUniverseSelection(new ManualUniverseSelectionModel(symbols));
        
        // Constant investment signal
        AddAlpha(new ConstantAlphaModel(InsightType.Price, InsightDirection.Up, TimeSpan.FromDays(7), 0.025, None));

        // Invest in all members equally
        SetPortfolioConstruction(new EqualWeightingPortfolioConstructionModel());
    }
}

Data Point Attributes

The US Equities dataset provides TradeBar, QuoteBar, and Tick objects.

TradeBar Attributes

TradeBar objects have the following attributes:

QuoteBar Attributes

QuoteBar objects have the following attributes:

Tick Attributes

Tick objects have the following attributes:

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: