Datasets
Equity Fundamental Data
Introduction
This page explains how to request, manipulate, and visualize historical Equity Fundamental data. Corporate fundamental data is available through the US Fundamental Data from Morningstar.
Create Subscriptions
Follow these steps to subscribe to an Equity security:
- Load the assembly files and data types in their own cell.
- Import the data types.
- Create a
QuantBook
. - Call the
AddEquity
method with a ticker and then save a reference to the EquitySymbol
.
#load "../Initialize.csx"
#load "../QuantConnect.csx" #r "../Microsoft.Data.Analysis.dll" using QuantConnect; using QuantConnect.Data; using QuantConnect.Algorithm; using QuantConnect.Research; using QuantConnect.Indicators; using Microsoft.Data.Analysis;
var qb = new QuantBook();
qb = QuantBook()
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 DateTime
datetime
, and an end DateTime
datetime
. 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]; } } }
history[symbols[1]]

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
You need some historical Equity fundamental data to produce plots. You can use many of the supported plotting librariesPlot.NET
package to visualize data in various formats. For example, you can plot line charts.
Follow these steps to plot line charts using built-in methodsPlotly.NET
package:
- Call the
plot
method on the historyDataFrame
. - Create
Line
charts. - Create a
Layout
. - Combine the charts and assign the
Layout
to the chart. - Show the plot.
history.plot(title='PE Ratio Over Time', figsize=(15, 8))
var chart1 = Chart2D.Chart.Line<DateTime, decimal, string>( history.Select(x => (DateTime)x.Time), history.Select(x => (decimal)x[aapl]), Name: "AAPL" ); var chart2 = Chart2D.Chart.Line<DateTime, decimal, string>( history.Select(x => (DateTime)x.Time), history.Select(x => (decimal)x[goog]), Name: "GOOG" );
LinearAxis xAxis = new LinearAxis(); xAxis.SetValue("title", "Time"); LinearAxis yAxis = new LinearAxis(); yAxis.SetValue("title", "PE Ratio"); Title title = Title.init("AAPL & GOOG PE Ratio"); Layout layout = new Layout(); layout.SetValue("xaxis", xAxis); layout.SetValue("yaxis", yAxis); layout.SetValue("title", title);
var chart = Plotly.NET.Chart.Combine(new []{chart1, chart2}); chart.WithLayout(layout);
plt.show()
HTML(GenericChart.toChartHTML(chart))
Line charts display the value of the property you selected in a time series.

