Brain Sentiment Indicator


The Brain Sentiment Indicator dataset by Brain tracks the public sentiment around US Equities. The data covers 4,500 US Equities, starts in August 2016, and is delivered on a daily frequency. This dataset is created by analyzing financial news using Natural Language Processing techniques while taking into account the similarity and repetition of news on the same topic. The sentiment score assigned to each stock ranges from -1 (most negative) to +1 (most positive). The sentiment score corresponds to the average sentiment for each piece of news. The score is updated daily and is available on two time scales: 7 days and 30 days. For more information, see Brain's summary paper.

This dataset depends on the 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 Sentiment Indicator dataset, including CLI commands and pricing, see the dataset listing.

About the Provider

Brain 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 Sentiment Indicator dataset:

from QuantConnect.DataSource import *

self.symbol = self.AddEquity("AAPL", Resolution.Daily).Symbol
self.dataset_7day_symbol = self.AddData(BrainSentimentIndicator7Day, self.symbol).Symbol
self.dataset_30day_symbol = self.AddData(BrainSentimentIndicator30Day, self.symbol).Symbol

self.AddUniverse(BrainSentimentIndicatorUniverse, "BrainSentimentIndicatorUniverse", Resolution.Daily, self.UniverseSelectionMethod)
using QuantConnect.DataSource;

_symbol = AddEquity("AAPL", Resolution.Daily).Symbol;
_dataset7DaySymbol = AddData<BrainSentimentIndicator7Day>(_symbol).Symbol;
_dataset30DaySymbol = AddData<BrainSentimentIndicator30Day>(_symbol).Symbol;

AddUniverse<BrainSentimentIndicatorUniverse>("BrainSentimentIndicatorUniverse", Resolution.Daily, UniverseSelectionMethod);

Data Summary

The following table describes the dataset properties:

Start DateAugust 2016
Asset Coverage*4,500 US Equities
Data DensitySparse
The coverage includes all assets since the start date. It increases over time.

Data Point Attributes

The Brain Sentiment Indicator dataset provides BrainSentimentIndicatorBase and BrainSentimentIndicatorUniverse objects.

BrainSentimentIndicatorBase Attributes

BrainSentimentIndicatorBase objects have the following attributes:

BrainSentimentIndicatorUniverse Attributes

BrainSentimentIndicatorUniverse objects have the following attributes:

Requesting Data

To add Brain Sentiment Indicator data to your algorithm, call the AddData method. Save a reference to the dataset Symbol so you can access the data later in your algorithm.

class BrainSentimentDataAlgorithm(QCAlgorithm):
    def Initialize(self) -> None:
        self.SetStartDate(2019, 1, 1)
        self.SetEndDate(2021, 7, 8)
        self.symbol = self.AddEquity("AAPL", Resolution.Daily).Symbol
        self.dataset_7day_symbol = self.AddData(BrainSentimentIndicator7Day, self.symbol).Symbol
        self.dataset_30day_symbol = self.AddData(BrainSentimentIndicator30Day, self.symbol).Symbol
namespace QuantConnect
    public class BrainSentimentDataAlgorithm : QCAlgorithm
        private Symbol _symbol, _dataset7DaySymbol, _dataset30DaySymbol;
        public override void Initialize()
            SetStartDate(2019, 1, 1);
            SetEndDate(2021, 7, 8);
            _symbol = AddEquity("AAPL", Resolution.Daily).Symbol;
            _dataset7DaySymbol = AddData<BrainSentimentIndicator7Day>(_symbol).Symbol;
            _dataset30DaySymbol = AddData<BrainSentimentIndicator30Day>(_symbol).Symbol;

Accessing Data

To get the current Brain Sentiment Indicator 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 OnData(self, slice: Slice) -> None:
    if slice.ContainsKey(self.dataset_7day_symbol):
        data_point = slice[self.dataset_7day_symbol]
        self.Log(f"{self.dataset_7day_symbol} sentiment at {slice.Time}: {data_point.Sentiment}")

    if slice.ContainsKey(self.dataset_30day_symbol):
        data_point = slice[self.dataset_30day_symbol]
        self.Log(f"{self.dataset_30day_symbol} sentiment at {slice.Time}: {data_point.Sentiment}")
public override void OnData(Slice slice)
    if (slice.ContainsKey(_dataset7DaySymbol))
        var dataPoint = slice[_dataset7DaySymbol];
        Log($"{_dataset7DaySymbol} sentiment at {slice.Time}: {dataPoint.Sentiment}");

    if (slice.ContainsKey(_dataset30DaySymbol))
        var dataPoint = slice[_dataset30DaySymbol];
        Log($"{_dataset30DaySymbol} sentiment at {slice.Time}: {dataPoint.Sentiment}");

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

def OnData(self, slice: Slice) -> None:
    for dataset_symbol, data_point in slice.Get(BrainSentimentIndicator7Day).items():
        self.Log(f"{dataset_symbol} sentiment at {slice.Time}: {data_point.Sentiment}")

    for dataset_symbol, data_point in slice.Get(BrainSentimentIndicator30Day).items():
        self.Log(f"{dataset_symbol} sentiment at {slice.Time}: {data_point.Sentiment}")
public override void OnData(Slice slice)
    foreach (var kvp in slice.Get<BrainSentimentIndicator7Day>())
        var datasetSymbol = kvp.Key;
        var dataPoint = kvp.Value;
        Log($"{datasetSymbol} sentiment at {slice.Time}: {dataPoint.Sentiment}");

    foreach (var kvp in slice.Get<BrainSentimentIndicator30Day>())
        var datasetSymbol = kvp.Key;
        var dataPoint = kvp.Value;
        Log($"{datasetSymbol} sentiment at {slice.Time}: {dataPoint.Sentiment}");

Historical Data

To get historical Brain Sentiment Indicator data, call the History method with the dataset Symbol. If there is no data in the period you request, the history result is empty.

# DataFrames
week_history_df = self.History(self.dataset_7day_symbol, 100, Resolution.Daily)
month_history_df = self.History(self.dataset_30day_symbol, 100, Resolution.Daily)
history_df = self.History([self.dataset_7day_symbol, self.dataset_30day_symbol], 100, Resolution.Daily)

# Dataset objects
week_history_bars = self.History[BrainSentimentIndicator7Day](self.dataset_7day_symbol, 100, Resolution.Daily)
month_history_bars = self.History[BrainSentimentIndicator30Day](self.dataset_30day_symbol, 100, Resolution.Daily)
// Dataset objects
var weekHistory = History<BrainSentimentIndicator7Day>(_dataset7DaySymbol, 100, Resolution.Daily);
var monthHistory = History<BrainSentimentIndicator30Day>(_dataset30DaySymbol, 100, Resolution.Daily);

// Slice objects
var history = History(new[] {_dataset7DaySymbol, _dataset30DaySymbol}, 100, Resolution.Daily);

For more information about historical data, see History Requests.

Universe Selection

To select a dynamic universe of US Equities based on Brain Sentiment Indicator data, call the AddUniverse method with the BrainSentimentIndicatorUniverse class and a selection function.

def Initialize(self) -> None:
    self.AddUniverse(BrainSentimentIndicatorUniverse, "BrainSentimentIndicatorUniverse", Resolution.Daily, self.UniverseSelection)

def UniverseSelection(self, alt_coarse: List[BrainSentimentIndicatorUniverse]) -> List[Symbol]:
    return [d.Symbol for d in alt_coarse \
                if d.TotalArticleMentions7Days > 0 \
                and d.Sentiment7Days]
AddUniverse<BrainSentimentIndicatorUniverse>("BrainSentimentIndicatorUniverse", Resolution.Daily, altCoarse=>
    return from d in altCoarse 
           where d.TotalArticleMentions7Days > 0m && d.Sentiment7Days > 0m
           select d.Symbol;

The Brain Sentiment Indicator universe runs at 7 AM Eastern Time (ET) in live trading. For more information about dynamic universes, see Universes.

Remove Subscriptions

To remove a subscription, call the RemoveSecurity method.


If you subscribe to Brain Sentiment Indicator 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 Brain Sentiment Indicator dataset enables you to incorporate sentiment from financial news sources into your strategies. Examples include the following strategies:

  • Buying when the public sentiment for a security is increasing
  • Short selling when the public sentiment for a security is decreasing
  • Scaling the position sizing of securities based on how many times they are mentioned in financial news articles
  • Sector rotation based on news sentiment

Disclaimer: The dataset is provided by the data provider for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor do they constitute an offer to provide investment advisory or other services by the data provider.

You can also see our Videos. You can also get in touch with us via Discord.

Did you find this page helpful?

Contribute to the documentation: