US Equity
Corporate Fundamentals
Introduction
Corporate fundamental data contains all the information on the underlying company of an Equity asset and the information in their financial statements. Since corporate data contains information not found in price and alternative data, adding corporate data to your trading strategies provides you with more information so you can make more informed trading decisions. Corporate fundamental data is available through the US Fundamental Data from Morningstar.
Direct Access
To get fundamental data for Equities in your algorithm, use the Fundamentals
property of the Equity
objects. The fundamental data represent the company's fundamentals for the current algorithm time.
var fundamentals = Securities[_symbol].Fundamentals;
fundamentals = self.Securities[self.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. The fundamental data represents the corporate fundamentals for the current algorithm time.
// Single asset var ibm = QuantConnect.Symbol.Create("IBM", SecurityType.Equity, Market.USA); var ibmFundamental = Fundamentals(ibm); // Multiple assets var nb = QuantConnect.Symbol.Create("NB", SecurityType.Equity, Market.USA); var fundamentals = Fundamentals(new List<Symbol>{ nb, ibm }).ToList();
# Single asset ibm = QuantConnect.Symbol.Create("IBM", SecurityType.Equity, Market.USA) ibm_fundamental = self.Fundamentals(ibm) # Multiple assets nb = QuantConnect.Symbol.Create("NB", SecurityType.Equity, Market.USA) fundamentals = self.Fundamentals([ nb, ibm ])
Data Availability
Some assets don't have fundamentals (for example, ETFs) and the Morningstar dataset doesn't provide fundamentals for all US Equities. To check if fundamental data is available for an asset, use the HasFundamentalData
property.
var hasFundamentalData = Securities[_symbol].Fundamentals.HasFundamentalData;
has_fundamental_data = self.Securities[self.symbol].Fundamentals.HasFundamentalData
Object References
If you save a reference to the Fundamentals
object or its properties, you can access the fundamental properties as they change over time.
_fundamentals = Securities[_symbol].Fundamentals; var earningRatios = _fundamentals.EarningRatios;
self.fundamentals = self.Securities[self.symbol].Fundamentals earning_ratios = self.fundamentals.EarningRatios
Universe Selection
You can access fundamental data in the selection function of your fundamental universe.
public class MyUniverseAlgorithm : QCAlgorithm { public override void Initialize() { AddUniverse(FundamentalFilterFunction); } private IEnumerable<Symbol> FundamentalFilterFunction(IEnumerable<Fundamental> fundamental) { return (from f in fundamental where f.HasFundamentalData select f.Symbol); } }
class MyUniverseAlgorithm(QCAlgorithm): def Initialize(self) -> None: self.AddUniverse(self.FundamentalFunction) def FundamentalFunction(self, fundamental: List[Fundamental]) -> List[Symbol]: return [c.Symbol for c in fundamental if c.HasFundamentalData]
Historical Data
To get historical fundamental data, call the History
method. The return type depends on how you call the method.
var ibm = QuantConnect.Symbol.Create("IBM", SecurityType.Equity, Market.USA); // Fundamental objects var fundamentalHistory = History<Fundamental>(ibm, TimeSpan.FromDays(30)); // Fundamentals objects for all US Equities (including delisted companies) var fundamentalsHistory = History<Fundamentals>(TimeSpan.FromDays(30));
ibm = Symbol.Create("IBM", SecurityType.Equity, Market.USA) # DataFrame objects df_history = qb.History(Fundamental, ibm, timedelta(30)) # 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))
For more information about historical fundamental data, see Equity Fundamental Data.
Data Updates
The US Fundamental dataset only provides the originally-reported figures. If there was a mistake in reporting a figure, the data value isn't fixed later. In live trading, new fundamental data is available to your algorithms at approximately 6/7 AM Eastern Time (ET) each day. The majority of the corporate data update occurs once per month, but the financial ratios update daily. If there is no new data for a period of time, the previous data is filled forward.
Properties
The US Fundamentals dataset provides Fundamental objects. To filter Fundamental objects, you can use the MorningstarSectorCode, MorningstarIndustryGroupCode, and MorningstarIndustryCode enumeration values.
Fundamentals Attributes
Fundamentals objects have the following attributes:
MorningstarSectorCode Enumeration
Sectors are large super categories of data. To access the sector of an Equity, use the MorningstarSectorCode property.
filtered = fundamental.Where(x => x.AssetClassification.MorningstarSectorCode == MorningstarSectorCode.Technology);
filtered = [x for x in fundamental if x.AssetClassification.MorningstarSectorCode == MorningstarSectorCode.Technology]
The MorningstarSectorCode enumeration has the following members:
MorningstarIndustryGroupCode Enumeration
Industry groups are clusters of related industries which tie together. To access the industry group of an Equity, use the MorningstarIndustryGroupCode property.
filtered = fundamental.Where(x => x.AssetClassification.MorningstarIndustryGroupCode == MorningstarIndustryGroupCode.ApplicationSoftware);
filtered = [x for x in fundamental if x.AssetClassification.MorningstarIndustryGroupCode == MorningstarIndustryGroupCode.ApplicationSoftware]
The MorningstarIndustryGroupCode enumeration has the following members:
MorningstarIndustryCode Enumeration
Industries are the finest level of classification available and are the individual industries according to the Morningstar classification system. To access the industry group of an Equity, use the MorningstarIndustryCode property:
filtered = fundamental.Where(x => x.AssetClassification.MorningstarIndustryCode == MorningstarIndustryCode.SoftwareApplication);
filtered = [x for x in fundamental if x.AssetClassification.MorningstarIndustryCode == MorningstarIndustryCode.SoftwareApplication]
The MorningstarIndustryCode enumeration has the following members:
Exchange Id Values
Exchange Id is mapped to represent the exchange that lists the Equity. To access the exchange Id of an Equity, use the PrimaryExchangeID property.
filtered = fundamental.Where(x => x.CompanyReference.PrimaryExchangeID == "NAS");
filtered = [x for x in fundamental if x.CompanyReference.PrimaryExchangeID == "NAS"]
The exchanges are represented by the following string values:
String Representation | Exchange |
---|---|
NYS | New York Stock Exchange (NYSE) |
NAS | NASDAQ |
ASE | American Stock Exchange (AMEX) |
TSE | Tokyo Stock Exchange |
AMS | Amsterdam Internet Exchange |
SGO | Santiago Stock Exchange |
XMAD | Madrid Stock Exchange |
ASX | Australian Securities Exchange |
BVMF | B3 (stock exchange) |
LON | London Stock Exchange |
TKS | Istanbul Stock Exchange Settlement and Custody Bank |
SHG | Shanghai Exchange |
LIM | Lima Stock Exchange |
FRA | Frankfurt Stock Exchange |
JSE | Johannesburg Stock Exchange |
MIL | Milan Stock Exchange |
TAE | Tel Aviv Stock Exchange |
STO | Stockholm Stock Exchange |
ETR | Deutsche Boerse Xetra Core |
PAR | Paris Stock Exchange |
BUE | Buenos Aires Stock Exchange |
KRX | Korea Exchange |
SWX | SIX Swiss Exchange |
PINX | Pink Sheets (OTC) |
CSE | Canadian Securities Exchange |
PHS | Philippine Stock Exchange |
MEX | Mexican Stock Exchange |
TAI | Taiwan Stock Exchange |
IDX | Indonesia Stock Exchange |
OSL | Oslo Stock Exchange |
BOG | Colombia Stock Exchange |
NSE | National Stock Exchange of India |
HEL | Nasdaq Helsinki |
MISX | Moscow Exchange |
HKG | Hong Kong Stock Exchange |
IST | Istanbul Stock Exchange |
BOM | Bombay Stock Exchange |
TSX | Toronto Stock Exchange |
BRU | Brussels Stock Exchange |
BATS | BATS Global Markets |
ARCX | NYSE Arca |
GREY | Grey Market (OTC) |
DUS | Dusseldorf Stock Exchange |
BER | Berlin Stock Exchange |
ROCO | Taipei Exchange |
CNQ | Canadian Trading and Quotation System Inc. |
BSP | Bangko Sentral ng Pilipinas |
NEOE | NEO Exchange |