---
title: "US SEC Filings"
description: "US SEC Filings dataset from Securities and Exchange Commission."
canonical: https://www.quantconnect.com/docs/v2/writing-algorithms/datasets/securities-and-exchange-commission/us-sec-filings
markdown: https://www.quantconnect.com/docs/v2/writing-algorithms/datasets/securities-and-exchange-commission/us-sec-filings.md
language: python
source: https://github.com/QuantConnect/Documentation/tree/master/03%20Writing%20Algorithms/14%20Datasets/25%20Securities%20and%20Exchange%20Commission/02%20US%20SEC%20Filings
modified: 2026-10-30
index: https://www.quantconnect.com/llms.txt
---

# US SEC Filings

[Documentation](https://www.quantconnect.com/docs/v2.md) > [Writing Algorithms](https://www.quantconnect.com/docs/v2/writing-algorithms.md) > Datasets > [Securities and Exchange Commission](https://www.quantconnect.com/docs/v2/writing-algorithms/datasets/securities-and-exchange-commission.md) > US SEC Filings

> Code examples are shown in Python. Append `?lang=csharp` to this URL for the C# version of this page.

## 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](https://www.quantconnect.com/datasets/us-security-exchange-commission-filings).

## 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:

```python
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
```

## Data Summary

The following table describes the dataset properties:

| Property | Value |
| --- | --- |
| Start Date | January 1998 |
| Asset Coverage | 15,000 US Equities |
| Data Density | Sparse |
| Resolution | Daily |
| Timezone | UTC |

## Requesting Data

To add US SEC Filings data to your algorithm, call the `add_data` method. Save a reference to the dataset `Symbol` so you can access the data later in your algorithm.

```python
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
```

## Accessing Data

To get the current US SEC Filings data, index the current [`Slice`](https://www.quantconnect.com/docs/v2/writing-algorithms/key-concepts/time-modeling/timeslices.md) 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.

```python
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.contains_key(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)}")
```

To iterate through all of the dataset objects in the current `Slice`, call the `get` method.

```python
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)}")
```

## Historical Data

To get historical US SEC Filings data, call the `history` method with the dataset `Symbol`. If there is no data in the period you request, the history result is empty.

```python
# 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)
```

For more information about historical data, see [History Requests](https://www.quantconnect.com/docs/v2/writing-algorithms/historical-data/history-requests.md).

## Remove Subscriptions

To remove a subscription, call the `remove_security` method.

```python
self.remove_security(self.report_8k_symbol)
self.remove_security(self.report_10k_symbol)
self.remove_security(self.report_10q_symbol)
```

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](https://www.quantconnect.com/docs/v2/writing-algorithms/algorithm-framework/alpha/key-concepts.md#05-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)

### Classic Algorithm Example

The following example algorithm creates a dynamic universe of the 10 most liquid US Equities. It then buys the securities that have an 8K report with more than 20,000 characters and forms an equal-weighted portfolio. Instead of trading based on how long the report is, you could use sentiment analysis by scoring keywords.

```python
from AlgorithmImports import *

class SECReport8KAlgorithm(QCAlgorithm):

    def initialize(self) -> None:
        self.set_start_date(2024, 9, 1)
        self.set_end_date(2024, 12, 31)
        self.set_cash(100000)
        # Seed the price of each asset with its last known price to avoid trading errors.
        self.settings.seed_initial_prices = True
        self.universe_settings.resolution = Resolution.DAILY
        self.add_universe(self.coarse_selector)
        self.dataset_symbol_by_symbol = {}
        self.long_symbols = []
        self.rebalance = False

        # Request underlying equity data.
        ibm = self.add_equity("IBM", Resolution.DAILY).symbol
        # Add news data for the underlying IBM asset for trade signal generation
        earnings_filing = self.add_data(SECReport10Q, ibm, Resolution.DAILY).symbol
        # Request 120 days of history with the SECReport10Q IBM custom data Symbol
        history = self.history(SECReport10Q, earnings_filing, 120, Resolution.DAILY)
        self.debug(f"We got {len(history)} items from our history request")

    def coarse_selector(self, coarse: List[CoarseFundamental]) -> List[Symbol]:
        # Select the top 10 traded companies with fundamental data, since the market activities can better reflect the fundamental factor efficiently
        coarse = sorted([cf for cf in coarse if cf.has_fundamental_data],
            key=lambda cf: cf.dollar_volume, reverse=True)[:10]
        return [cf.symbol for cf in coarse]

    def on_data(self, slice: Slice) -> None:
        # Trade from SEC data
        for report in slice.get(SECReport8K).values():
            underlying_symbol = report.symbol.underlying
            # Skip the Symbol if it's no longer in the universe (insuffucient popularity to reach market efficiency of fundamental factor)
            if underlying_symbol not in self.dataset_symbol_by_symbol:
                if underlying_symbol in self.long_symbols:
                    self.rebalance = True
                    self.long_symbols.remove(underlying_symbol)
                continue

            # Long the stocks with SEC report over 20000 text length, suggesting excessive insights or future projections are highlighted
            report_text_length = sum([len(i.text) for i in report.report.documents])
            if report_text_length > 20000:
                if underlying_symbol not in self.long_symbols:
                    self.rebalance = True
                    self.long_symbols.append(underlying_symbol)
            elif underlying_symbol in self.long_symbols:
                self.rebalance = True
                self.long_symbols.remove(underlying_symbol)

        if not self.rebalance:
            return
        self.rebalance = False

        # Invest equally to evenly dissipate the capital concentration risk
        portfolio_targets = []
        equal_weighting = 1 / len(self.long_symbols) if len(self.long_symbols) > 0 else 0
        for symbol, security_holding in self.portfolio.items():
            weight = 0
            if symbol in self.long_symbols:
                weight = equal_weighting
            elif not security_holding.invested:
                continue
            portfolio_targets.append(PortfolioTarget(symbol, weight))
        self.set_holdings(portfolio_targets)

    def on_securities_changed(self, changes: SecurityChanges) -> None:
        for security in changes.added_securities:
            # If added to universe, adds SECReport8K for trade signal generation
            self.dataset_symbol_by_symbol[security.symbol] = self.add_data(SECReport8K, security.symbol).symbol

        for security in changes.removed_securities:
            # Remove SEC data subscription to release computation resources
            dataset_symbol = self.dataset_symbol_by_symbol.pop(security.symbol, None)
            if dataset_symbol:
                self.remove_security(dataset_symbol)
```

### Framework Algorithm Example

The following example algorithm creates a dynamic universe of the 10 most liquid US Equities. It then buys the securities that have an 8K report with more than 20,000 characters and forms an equal-weighted portfolio. Instead of trading based on how long the report is, you could use sentiment analysis by scoring keywords.

```python
from AlgorithmImports import *

class SECReport8KAlgorithm(QCAlgorithm):

    def initialize(self) -> None:
        self.set_start_date(2024, 9, 1)
        self.set_end_date(2024, 12, 31)
        self.set_cash(100000)
        # Seed the price of each asset with its last known price to avoid trading errors.
        self.settings.seed_initial_prices = True
        self.universe_settings.resolution = Resolution.DAILY
        # Filter for the most liquid stocks for trading due to high market activities for efficient pricing from fundamental factor
        self.add_universe_selection(MostLiquidFundamentalUniverseSelectionModel())
        # Custom alpha model that generates insights from SEC data
        self.add_alpha(SECReport8KAlphaModel())
        # Invest equally to evenly dissipate the capital concentration risk
        self.set_portfolio_construction(EqualWeightingPortfolioConstructionModel(lambda time: None))

class MostLiquidFundamentalUniverseSelectionModel(FundamentalUniverseSelectionModel):

    def select(self, algorithm: QCAlgorithm, fundamental: List[Fundamental]) -> List[Symbol]:
        # Select the top 10 traded companies with fundamental data, since the market activities can better reflect the fundamental factor efficiently
        sorted_by_dollar_volume = sorted(fundamental, key=lambda f: f.dollar_volume, reverse=True)
        return [f.symbol for f in sorted_by_dollar_volume[:10]]

class SECReport8KAlphaModel(AlphaModel):
    dataset_symbol_by_symbol = {}

    def update(self, algorithm: QCAlgorithm, slice: Slice) -> List[Insight]:
        insights = []

        # Trade only based on SEC data
        for report in slice.get(SECReport8K).values():
            underlying_symbol = report.symbol.underlying
            if underlying_symbol not in self.dataset_symbol_by_symbol:
                continue

            # Long the stocks with SEC report over 20000 text length, suggesting excessive insights or future projections are highlighted
            report_text_length = sum([len(i.text) for i in report.report.documents])

            if report_text_length > 20000:
                direction = InsightDirection.UP
            elif algorithm.portfolio[underlying_symbol].invested:
                direction = InsightDirection.FLAT
            else:
                continue
            insights.append(Insight.price(underlying_symbol, timedelta(days=30), direction))

        return insights

    def on_securities_changed(self, algorithm: QCAlgorithm, changes: SecurityChanges) -> None:
        for security in changes.added_securities:
            # If added to universe, adds SECReport8K for trade signal generation
            self.dataset_symbol_by_symbol[security.symbol] = algorithm.add_data(SECReport8K, security.symbol).symbol

        for security in changes.removed_securities:
            # Remove SEC data subscription to release computation resources
            symbol_data = self.dataset_symbol_by_symbol.pop(security.symbol, None)
            if symbol_data:
                algorithm.remove_security(symbol_data)
```

## Data Point Attributes

The US SEC Filings dataset provides `SECReport8K`, `SECReport10K`, and `SECReport10Q` objects.

### Report 8K Attributes

`SECReport8K` objects have the following attributes:

*Members of `QuantConnect.DataSource.SECReport8K` (JSON): https://www.quantconnect.com/services/inspector?type=T:QuantConnect.DataSource.SECReport8K&language=python*

### Report 10K Attributes

`SECReport10K` objects have the following attributes:

*Members of `QuantConnect.DataSource.SECReport10K` (JSON): https://www.quantconnect.com/services/inspector?type=T:QuantConnect.DataSource.SECReport10K&language=python*

### Report 10Q Attributes

`SECReport10Q` objects have the following attributes:

*Members of `QuantConnect.DataSource.SECReport10Q` (JSON): https://www.quantconnect.com/services/inspector?type=T:QuantConnect.DataSource.SECReport10Q&language=python*
