Equity Fundamental Data


This page explains how to request, manipulate, and visualize historical Equity Fundamental data.


Working knowledge of C#.

Working knowedge of Python and pandas. If you are not familiar with pandas, see the pandas documentation.

Create Subscriptions

Follow these steps to subscribe to an Equity security:

  1. Load the required assembly files and data types.
  2. #load "../Initialize.csx"
    #load "../QuantConnect.csx"
    using QuantConnect;
    using QuantConnect.Data;
    using QuantConnect.Algorithm;
    using QuantConnect.Research;
    using QuantConnect.Indicators;
  3. Create a QuantBook.
  4. var qb = new QuantBook();
    qb = QuantBook()
  5. Call the AddEquity method with a ticker and then save a reference to the Equity Symbol.
  6. var symbols = new [] 
            "AAL",  // American Airlines Group, Inc.
            "ALGT", // Allegiant Travel Company
            "ALK",  // Alaska Air Group, Inc.
            "DAL",  // Delta Air Lines, Inc.
            "LUV",  // Southwest Airlines Company
            "SKYW", // SkyWest, Inc.
            "UAL"   // United Air Lines
        .Select(ticker => qb.AddEquity(ticker).Symbol);
    symbols = [qb.AddEquity(ticker).Symbol
        for ticker in [
            "AAL",   # American Airlines Group, Inc.
            "ALGT",  # Allegiant Travel Company
            "ALK",   # Alaska Air Group, Inc.
            "DAL",   # Delta Air Lines, Inc.
            "LUV",   # Southwest Airlines Company
            "SKYW",  # SkyWest, Inc.
            "UAL"    # United Air Lines

To view the supported assets in the US Equities dataset, see the Data Explorer.

Get Historical Data

You need a subscription before you can request historical fundamental data for a US Equity.

To get historical data, call the GetFundamental method with a list of Symbol objects, a fundamental data field name, a start DateTimedatetime, and an end DateTimedatetime. The start and end times you provide are based in the notebook time zone. To view the possible fundamental data field names, see the FineFundamental attributes in Data Point Attributes. For example, to get data for airline companies over 2014, run:

var startTime = new DateTime(2014, 1, 1);
var endTime = new DateTime(2015, 1, 1);
var history = qb.GetFundamental(symbols, "ValuationRatios.PERatio", startTime, endTime);
start_time = datetime(2014, 1, 1)
end_time = datetime(2015, 1, 1)
history = qb.GetFundamental(symbols, "ValuationRatios.PERatio", start_time, end_time)

The preceding method returns the fundamental data field values that are timestamped within the defined period of time.

Wrangle Data

You need some historical data to perform wrangling operations. To display pandas objects, run a cell in a notebook with the pandas object as the last line. To display other data formats, call the print method.

You need some historical data to perform wrangling operations. Use LINQ to wrangle the data and then call the Console.WriteLine method in a Jupyter Notebook to display the data.

The DataFrame index is the EndTime of the data sample. The columns of the DataFrame are the Equity Symbol objects.

To get the fundamental data points for each Equity, iterate through the history request result.

To select the historical data of a single Equity, index the DataFrame with the Equity Symbol. Each history slice may not have data for all of your Equity subscriptions. To avoid issues, check if it contains data for your Equity before you index it with the Equity Symbol.

foreach (var slice in history)
    foreach (var symbol in symbols)
        if (slice.ContainsKey(symbol))
            var peRatio = slice[symbol];

You can also iterate through each data point in the slice.

foreach (var slice in history)
    foreach (var kvp in slice)
        var symbol = kvp.Key;
        var peRatio = kvp.Value;

You can also use LINQ to select the historical data points.

var symbol = symbols.Last();
var values = history.Select(slice => slice[symbol]);

Plot Data

Jupyter Notebooks don't currently support libraries to plot historical data, but we are working on adding the functionality. Until we add the functionality, use Python to plot historical Equity fundamental data.

You need some historical Equity fundamental data to produce plots. You can use many of the supported plotting libraries to visualize data in various formats. For example, you can plot line charts.

Follow these steps to plot line charts using built-in methods:

  1. Call the plot method on the history DataFrame.
  2. history.plot(title='PE Ratio Over Time', figsize=(15, 8))
  3. Show the plot.

    Line charts display the value of the property you selected in a time series.

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: