---
title: "Brain Language Metrics on Company Filings"
description: "Brain Language Metrics on Company Filings dataset from Brain."
canonical: https://www.quantconnect.com/docs/v2/writing-algorithms/datasets/brain/brain-language-metrics-on-company-filings
markdown: https://www.quantconnect.com/docs/v2/writing-algorithms/datasets/brain/brain-language-metrics-on-company-filings.md
language: python
source: https://github.com/QuantConnect/Documentation/tree/master/03%20Writing%20Algorithms/14%20Datasets/08%20Brain/01%20Brain%20Language%20Metrics%20on%20Company%20Filings
modified: 2026-10-30
index: https://www.quantconnect.com/llms.txt
---

# Brain Language Metrics on Company Filings

[Documentation](https://www.quantconnect.com/docs/v2.md) > [Writing Algorithms](https://www.quantconnect.com/docs/v2/writing-algorithms.md) > Datasets > [Brain](https://www.quantconnect.com/docs/v2/writing-algorithms/datasets/brain.md) > Brain Language Metrics on Company Filings

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

## Introduction

The Brain Language Metrics on Company Filings dataset provides the results of an NLP system that monitors several language metrics on 10-K and 10-Q company reports for US Equities. The data covers 5,000 US Equities, starts in January 2010, and is delivered on a daily frequency. The dataset is made of two parts; the first one includes the language metrics of the most recent 10-K or 10-Q report for each firm, namely:

1. Financial sentiment
2. Percentage of words belonging to financial domain classified by language types (e.g. “litigious” or “constraining” language)
3. Readability score
4. Lexical metrics such as lexical density and richness
5. Text statistics such as the report length and the average sentence length

The second part includes the differences between the two most recent 10-Ks or 10-Qs reports of the same period for each company, namely:

1. Difference of the various language metrics (e.g. delta sentiment, delta readability score, delta percentage of a specific language type etc.)
2. Similarity metrics between documents, also with respect to a specific language type (for example similarity with respect to “litigious” language or “uncertainty” language)

The analysis is available for the whole report and for specific sections of the report (e.g. Risk Factors and MD&A).

For more information, refer to Brain's [summary paper](https://braincompany.co/assets/files/BLM_CF_V2_summary.pdf).

This dataset depends on the [US Equity Security Master](https://www.quantconnect.com/datasets/quantconnect-us-equity-security-master) dataset because the US Equity Security Master dataset contains information on splits, dividends, and symbol changes.

For more information about the Brain Language Metrics on Company Filings dataset, including CLI commands and pricing, see the [dataset listing](https://www.quantconnect.com/datasets/brain-language-metrics-company-filings).

## About the Provider

[Brain](https://braincompany.co/bsr.html) is a Research Company that creates proprietary datasets and algorithms for investment strategies, combining experience in financial markets with strong competencies in Statistics, Machine Learning, and Natural Language Processing. The founders share a common academic background of research in Physics as well as extensive experience in Financial markets.

## Getting Started

The following snippet demonstrates how to request data from the Brain Language Metrics on Company Filings dataset:

```python
self.aapl = self.add_equity("AAPL", Resolution.DAILY).symbol
self.dataset_10k_symbol = self.add_data(BrainCompanyFilingLanguageMetrics10K , self.aapl).symbol
self.dataset_all_symbol = self.add_data(BrainCompanyFilingLanguageMetricsAll, self.aapl).symbol

self.universe_10k = self.add_universe(BrainCompanyFilingLanguageMetricsUniverse10K, self.universe_selection)
self.universe_all = self.add_universe(BrainCompanyFilingLanguageMetricsUniverseAll, self.universe_selection)
```

## Data Summary

The following table describes the dataset properties:

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

The coverage includes all assets since the start date. It increases over time.

## Requesting Data

To add Brain Language Metrics on Company 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 BrainCompanyFilingNLPDataAlgorithm(QCAlgorithm):
    def initialize(self) -> None:
        self.set_start_date(2010, 1, 1)
        self.set_end_date(2021, 7, 8)
        self.set_cash(100000)

        self.aapl = self.add_equity("AAPL", Resolution.DAILY).symbol
        self.dataset_10k_symbol = self.add_data(BrainCompanyFilingLanguageMetrics10K, self.aapl).symbol
        self.dataset_all_symbol = self.add_data(BrainCompanyFilingLanguageMetricsAll, self.aapl).symbol
```

## Accessing Data

To get the current Brain Language Metrics on Company 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.dataset_10k_symbol):
        data_point = slice[self.dataset_10k_symbol]
        self.log(f"{self.dataset_10k_symbol} report sentiment at {slice.time}: {data_point.report_sentiment.sentiment}")

    if slice.contains_key(self.dataset_all_symbol):
        data_point = slice[self.dataset_all_symbol]
        self.log(f"{self.dataset_all_symbol} report sentiment at {slice.time}: {data_point.report_sentiment.sentiment}")
```

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(BrainCompanyFilingLanguageMetrics10K).items():
        self.log(f"{dataset_symbol} report sentiment at {slice.time}: {data_point.report_sentiment.sentiment}")

    for dataset_symbol, data_point in slice.get(BrainCompanyFilingLanguageMetricsAll).items():
        self.log(f"{dataset_symbol} report sentiment at {slice.time}: {data_point.report_sentiment.sentiment}")
```

## Historical Data

To get historical Brain Language Metrics on Company 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
ten_k_history_df = self.history(self.dataset_10k_symbol, 100, Resolution.DAILY)
all_history_df = self.history(self.dataset_all_symbol, 100, Resolution.DAILY)
history_df = self.history([self.dataset_10k_symbol, self.dataset_all_symbol], 100, Resolution.DAILY)

# Dataset objects
ten_k_history_bars = self.history[BrainCompanyFilingLanguageMetrics10K](self.dataset_10k_symbol, 100, Resolution.DAILY)
all_history_bars = self.history[BrainCompanyFilingLanguageMetricsAll](self.dataset_all_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).

## Universe Selection

To select a dynamic universe of US Equities based on Brain Language Metrics on Company Filings data, call the `add_universe` method with the `BrainCompanyFilingLanguageMetricsUniverseAll` class or the `BrainCompanyFilingLanguageMetricsUniverse10K` class and a selection function.

```python
def initialize(self) -> None:
    self._universe = self.add_universe(BrainCompanyFilingLanguageMetricsUniverseAll, self.universe_selection)

def universe_selection(self, alt_coarse: List[BrainCompanyFilingLanguageMetricsUniverseAll]) -> List[Symbol]:
    return [d.symbol for d in alt_coarse \
                if d.report_sentiment.sentiment > 0 \
                and d.management_discussion_analyasis_of_financial_condition_and_results_of_operations.sentiment > 0]
```

For more information about dynamic universes, see [Universes](https://www.quantconnect.com/docs/v2/writing-algorithms/universes/key-concepts.md).

## Universe History

You can get historical universe data in an algorithm and in the Research Environment.

### Historical Universe Data in Algorithms

To get historical universe data in an algorithm, call the `history` method with the `Universe` object and the lookback period. If there is no data in the period you request, the history result is empty.

```python
# DataFrame example where the columns are the universe object attributes:
history_df = self.history(self._universe, 30, Resolution.DAILY, flatten=True)

# Series example where the values are lists of the universe objects:
universe_history = self.history(self._universe, 30, Resolution.DAILY)
for (_, time), universeDay in universe_history.items():
    for language_metrics in universeDay:
        self.log(f"{language_metrics.symbol} sentiment at {language_metrics.end_time}: {language_metrics.report_sentiment.sentiment}")
```

### Historical Universe Data in Research

To get historical universe data in research, call the `universe_history` method with the `Universe` object, a start date, and an end date. This method returns the filtered universe. If there is no data in the period you request, the history result is empty.

```python
# DataFrame example where the columns are the universe object attributes:
history_df = qb.universe_history(universe, qb.time-timedelta(30), qb.time, flatten=True)

# Series example where the values are lists of the universe objects:
universe_history = qb.universe_history(universe, qb.time-timedelta(30), qb.time)
for (_, time), universeDay in universe_history.items():
    for language_metrics in universeDay:
        print(f"{language_metrics.symbol} sentiment at {language_metrics.end_time}: {language_metrics.report_sentiment.sentiment}")
```

You can call the `history` method in Research.

## Remove Subscriptions

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

```python
self.remove_security(self.dataset_10k_symbol)
self.remove_security(self.dataset_all_symbol)
```

If you subscribe to Brain Language Metrics on Company 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 Brain Language Metrics on Company Filings dataset enables you to test strategies using language metrics and their differences gathered from 10K and 10Q reports. Examples include the following strategies:

- Using the similarity among reports to determine position sizing of securities. Some examples are discussed in [Lazy Prices, Cohen et al. 2018](https://papers.ssrn.com/sol3/papers.cfm?abstract_id=1658471) and [The Positive Similarity of Company Filings and the Cross-section of Stock Returns, M. Padyšák 2020](https://papers.ssrn.com/sol3/papers.cfm?abstract_id=3690461).
- Using the sentiment of the latest report to determine the portfolio allocation to give to each security in the universe.
- Using levels of uncertainty, readability, or litigious language in the report to determine position sizing of securities.

### Classic Algorithm Example

The following example algorithm buys Apple when the sentiment of their 10K report is positive. Otherwise, it holds cash.

```python
from AlgorithmImports import *

class BrainCompanyFilingNLPDataAlgorithm(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
        # Request company filing data to obtain sentiment scores from company reports.
        # Combine sentiment with fundamental context, past performance, and forward-looking provisions.
        self._equity = self.add_equity("AAPL", Resolution.DAILY)
        self._filing_data = self.add_data(BrainCompanyFilingLanguageMetrics10K, self._equity)
        # Historical data
        history = self.history(self._filing_data, 365, Resolution.DAILY)
        self.debug(f"We got {len(history)} items from our history request for {self._filing_data}")

    def on_data(self, data: Slice) -> None:
        # Trade based on the updated report sentiment.
        if self._filing_data not in data:
            return
        sentiment = data[self._filing_data].report_sentiment.sentiment
        # Buy when sentiment is positive to express the expected positive return projection.
        self.set_holdings(self._equity, int(sentiment > 0))
```

### Framework Algorithm Example

The following example algorithm creates a dynamic universe of US Equities that have positive sentiment in their 10K report and then forms an equal-weighted portfolio:

```python
from AlgorithmImports import *

class BrainCompanyFilingNLPDataAlgorithm(QCAlgorithm):

    def initialize(self) -> None:
        self.set_start_date(2024, 9, 1)
        self.set_end_date(2024, 12, 31)
        self.set_cash(100000)
        self.settings.free_portfolio_value_percentage = 0.1
        # 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 based on company filing data
        self.add_universe(BrainCompanyFilingLanguageMetricsUniverse10K, self.universe_selection)

        self.add_alpha(BrainCompanyFilingNLPAlphaModel())

        self.set_portfolio_construction(EqualWeightingPortfolioConstructionModel())

        self.add_risk_management(NullRiskManagementModel())

        self.set_execution(ImmediateExecutionModel())

    def universe_selection(self, alt_coarse: List[BrainCompanyFilingLanguageMetricsUniverse10K]) -> List[Symbol]:
        # Filter for the stocks with positive sentiment score for the positive return projection
        # Combining both fundamental and sentiment factor, as well as past performance and future provision
        return [d.symbol for d in alt_coarse \
                if d.report_sentiment.sentiment is not None and d.report_sentiment.sentiment > 0]

class BrainCompanyFilingNLPAlphaModel(AlphaModel):

    _securities = []

    def update(self, algorithm: QCAlgorithm, slice: Slice):
        # Signal to invest in the selected universe, which are expected to have a positive return due to positive fundamentals and future prospect
        return [
            Insight.price(security.symbol, timedelta(days=1), InsightDirection.UP)
            for security in self._securities
            if security.price and security.is_tradable
        ]

    def on_securities_changed(self, algorithm: QCAlgorithm, changes: SecurityChanges) -> None:
        for security in changes.added_securities:
            self._securities.append(security)
        for security in changes.removed_securities:
            if security in self._securities:
                self._securities.remove(security)
```

### Research Example

The following example lists US Equities having the highest 2-day rank.

```python
qb = QuantBook()

# Requesting Data
aapl = qb.add_equity("AAPL", Resolution.DAILY).symbol
symbol = qb.add_data(BrainCompanyFilingLanguageMetrics10K, aapl).symbol

# Historical data
history = qb.history(BrainCompanyFilingLanguageMetrics10K, symbol, 180, Resolution.DAILY)
for (symbol, time), row in history.iterrows():
    print(f"{symbol} sentiment at {time}: {row['reportsentimentsentiment']}")

# Add Universe Selection
def universe_selection(alt_coarse: List[BrainCompanyFilingLanguageMetricsUniverse10K]) -> List[Symbol]:
    return [d.symbol for d in sorted([x for x in alt_coarse if x.report_sentiment.sentiment],
        key=lambda x: x.report_sentiment.sentiment, reverse=True)[:10]]

universe = qb.add_universe(BrainCompanyFilingLanguageMetricsUniverse10K, universe_selection)

# Historical Universe data
universe_history = qb.universe_history(universe, qb.time-timedelta(10), qb.time)
for (_, time), universeDay in universe_history.items():
    for language_metrics in universeDay:
        print(f"{language_metrics.symbol} sentiment at {language_metrics.end_time}: {language_metrics.report_sentiment.sentiment}")
```

## Data Point Attributes

The Brain Language Metrics on Company Filings dataset provides `BrainCompanyFilingLanguageMetrics` and `BrainCompanyFilingLanguageMetricsUniverse` objects.

### BrainCompanyFilingLanguageMetrics Attributes

`BrainCompanyFilingLanguageMetrics` objects have the following attributes:

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

### BrainCompanyFilingLanguageMetricsUniverse Attributes

`BrainCompanyFilingLanguageMetricsUniverse` objects have the following attributes:

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