Securities and Exchange Commission
US SEC Filings
Introduction
The US SEC Filings dataset provides the quarterly financial earning reports that the United States Securities and Exchange Commission (SEC) requires from publicly traded companies in the US. The data covers 15,000 US Equities, starts in January 1998, and is delivered on a daily frequency. The data is sourced from the SEC's Electronic Data Gathering, Analysis, and Retrieval (EDGAR) system. QuantConnect downloads and formats the Quarterly Financial Reports (10-Q) and Annual Financial Report (8-K) filings of companies into a format for easy consumption by LEAN.
For more information about the US SEC Filings dataset, including CLI commands and pricing, see the dataset listing.
About the Provider
The mission of the U.S. Securities and Exchange Commission is to protect investors, maintain fair, orderly, and efficient markets, and facilitate capital formation. The SEC oversees the key participants in the securities world, including securities exchanges, securities brokers and dealers, investment advisors, and mutual funds. The SEC is concerned primarily with promoting the disclosure of important market-related information, maintaining fair dealing, and protecting against fraud.
Getting Started
The following snippet demonstrates how to request data from the US SEC Filings dataset:
from QuantConnect.DataSource import * self.aapl = self.add_equity("AAPL", Resolution.MINUTE).symbol self.report_8k_symbol = self.add_data(SECReport8K, self.aapl).symbol self.report_10k_symbol = self.add_data(SECReport10K, self.aapl).symbol self.report_10q_symbol = self.add_data(SECReport10Q, self.aapl).symbol
using QuantConnect.DataSource; _symbol = AddEquity("AAPL", Resolution.Daily).Symbol; _report8KSymbol = AddData<SECReport8K>(_symbol, Resolution.Daily).Symbol; _report10KSymbol = AddData<SECReport10K>(_symbol, Resolution.Daily).Symbol; _report10QSymbol = AddData<SECReport10Q>(_symbol, Resolution.Daily).Symbol;
Example Applications
The US SEC Filings dataset enables you to create strategies using information from SEC reports. Examples include the following strategies:
- Extracting information about corporate earnings from the documents for further analysis
- Applying sentiment analysis to the text content of the documents (for example, keyword scoring and ranking)
For more example algorithms, see Examples.
Data Point Attributes
The US SEC Filings dataset provides SECReport8K, SECReport10K, and SECReport10Q objects.
Report 8K Attributes
SECReport8K objects have the following attributes:
Report 10K Attributes
SECReport10K objects have the following attributes:
Report 10Q Attributes
SECReport10Q objects have the following attributes:
Requesting Data
To add US SEC Filings data to your algorithm, call the AddDataadd_data method. Save a reference to the dataset Symbol so you can access the data later in your algorithm.
class SECReportAlgorithm(QCAlgorithm): def initialize(self) -> None: self.set_start_date(2019, 1, 1) self.set_end_date(2019, 8, 21) self.set_cash(100000) self.aapl = self.add_equity("AAPL", Resolution.MINUTE).symbol self.report_8k_symbol = self.add_data(SECReport8K, self.aapl).symbol self.report_10k_symbol = self.add_data(SECReport10K, self.aapl).symbol self.report_10q_symbol = self.add_data(SECReport10Q, self.aapl).symbol
namespace QuantConnect { public class SECReportAlgorithm : QCAlgorithm { private Symbol _symbol, _report8KSymbol, _report10KSymbol, _report10QSymbol; public override void Initialize() { SetStartDate(2019, 1, 1); SetEndDate(2019, 8, 21); SetCash(100000); _symbol = AddEquity("AAPL", Resolution.Daily).Symbol; _report8KSymbol = AddData<SECReport8K>(_symbol, Resolution.Daily).Symbol; _report10KSymbol = AddData<SECReport10K>(_symbol, Resolution.Daily).Symbol; _report10QSymbol = AddData<SECReport10Q>(_symbol, Resolution.Daily).Symbol; } } }
Accessing Data
To get the current US SEC Filings data, index the current Slice with the dataset Symbol. Slice objects deliver unique events to your algorithm as they happen, but the Slice may not contain data for your dataset 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: if slice.contains_key(self.report_8k_symbol): data_point = slice[self.report_8k_symbol] self.log(f"{self.report_8k_symbol} report count at {slice.time}: {len(data_point.report.documents)}") if slice.contains_key(self.report_10k_symbol): data_point = slice[self.report_10k_symbol] self.log(f"{self.report_10k_symbol} report count at {slice.time}: {len(data_point.report.documents)}") if slice.ContainsKey(self.report_10q_symbol): data_point = slice[self.report_10q_symbol] self.log(f"{self.report_10q_symbol} report count at {slice.Time}: {len(data_point.report.documents)}")
public override void OnData(Slice slice) { if (slice.ContainsKey(_report8KSymbol)) { var dataPoint = slice[_report8KSymbol]; Log($"{_report8KSymbol} report count at {slice.Time}: {data_point.Report.Documents.Count}"); } if (slice.ContainsKey(_report10KSymbol)) { var dataPoint = slice[_report10KSymbol]; Log($"{_report10KSymbol} report count at {slice.Time}: {data_point.Report.Documents.Count}"); } if (slice.ContainsKey(_report10QSymbol)) { var dataPoint = slice[_report10QSymbol]; Log($"{_report10QSymbol} report count at {slice.Time}: {data_point.Report.Documents.Count}"); } }
To iterate through all of the dataset objects in the current Slice, call the Getget method.
def on_data(self, slice: Slice) -> None: for dataset_symbol, data_point in slice.get(SECReport8K).items(): self.log(f"{dataset_symbol} report count at {slice.time}: {len(data_point.report.documents)}") for dataset_symbol, data_point in slice.get(SECReport10K).items(): self.log(f"{dataset_symbol} report count at {slice.time}: {len(data_point.report.documents)}") for dataset_symbol, data_point in slice.get(SECReport10Q).items(): self.log(f"{dataset_symbol} report count at {slice.time}: {len(data_point.report.documents)}")
public override void OnData(Slice slice) { foreach (var kvp in slice.Get<SECReport8K>()) { var datasetSymbol = kvp.Key; var dataPoint = kvp.Value; Log($"{datasetSymbol} report count at {slice.Time}: {dataPoint.Report.Documents.Count}"); } foreach (var kvp in slice.Get<SECReport10K>()) { var datasetSymbol = kvp.Key; var dataPoint = kvp.Value; Log($"{datasetSymbol} report count at {slice.Time}: {dataPoint.Report.Documents.Count}"); } foreach (var kvp in slice.Get<SECReport10Q>()) { var datasetSymbol = kvp.Key; var dataPoint = kvp.Value; Log($"{datasetSymbol} report count at {slice.Time}: {dataPoint.Report.Documents.Count}"); } }
Historical Data
To get historical US SEC Filings data, call the Historyhistory method with the dataset Symbol. If there is no data in the period you request, the history result is empty.
# DataFrames report_8k_history_df = self.history(self.report_8k_symbol, 100, Resolution.DAILY) report_10k_history_df = self.history(self.report_10k_symbol, 100, Resolution.DAILY) report_10q_history_df = self.history(self.report_10q_symbol, 100, Resolution.DAILY) history_df = self.history([self.report_8k_symbol, self.report_10k_symbol, self.report_10q_symbol], 100, Resolution.DAILY) # Dataset objects report_8k_history_bars = self.history[SECReport8K](self.report_8k_symbol, 100, Resolution.DAILY) report_10k_history_bars = self.history[SECReport10K](self.report_10k_symbol, 100, Resolution.DAILY) report_10q_history_bars = self.history[SECReport10Q](self.report_10q_symbol, 100, Resolution.DAILY)
// Dataset objects var report8KHistory = History<SECReport8K>(_report8KSymbol, 100, Resolution.Daily); var report10KHistory = History<SECReport10K>(_report10KSymbol, 100, Resolution.Daily); var report10QHistory = History<SECReport10Q>(_report10QSymbol, 100, Resolution.Daily); // Slice objects var history = History(new[] {_report8KSymbol, _report10KSymbol, _report10QSymbol}, 100, Resolution.Daily);
For more information about historical data, see History Requests.
Remove Subscriptions
To remove a subscription, call the RemoveSecurityremove_security method.
self.remove_security(self.report_8k_symbol) self.remove_security(self.report_10k_symbol) self.remove_security(self.report_10q_symbol)
RemoveSecurity(_report8KSymbol); RemoveSecurity(_report10KSymbol); RemoveSecurity(_report10QSymbol);
If you subscribe to US SEC Filings data for assets in a dynamic universe, remove the dataset subscription when the asset leaves your universe. To view a common design pattern, see Track Security Changes.
Example Applications
The US SEC Filings dataset enables you to create strategies using information from SEC reports. Examples include the following strategies:
- Extracting information about corporate earnings from the documents for further analysis
- Applying sentiment analysis to the text content of the documents (for example, keyword scoring and ranking)
For more example algorithms, see Examples.