About 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.


About Brain

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.

Add Brain Sentiment Indicator

Add Dataset Create Free QuantConnect Account

About QuantConnect

QuantConnect was founded in 2012 to serve quants everywhere with the best possible algorithmic trading technology. Seeking to disrupt a notoriously closed-source industry, QuantConnect takes a radically open-source approach to algorithmic trading. Through the QuantConnect web platform, more than 50,000 quants are served every month.


Algorithm Example

from AlgorithmImports import *
from QuantConnect.DataSource import *

class BrainSentimentDataAlgorithm(QCAlgorithm):
    
    latest_sentiment_value = None
    target_holdings = 0
    
    def initialize(self) -> None:
        self.set_start_date(2019, 1, 1)
        self.set_end_date(2021, 7, 8)
        self.set_cash(100000) 
        
        # Requesting data
        self.aapl = self.add_equity("AAPL", Resolution.DAILY).symbol
        self.dataset_symbol = self.add_data(BrainSentimentIndicator30Day, self.aapl).symbol
        
        # Historical data
        history = self.history(self.dataset_symbol, 100, Resolution.DAILY)
        self.debug(f"We got {len(history)} items from our history request for {self.dataset_symbol}")
        if history.empty:
            return
        
        # Warm up historical sentiment values
        previous_sentiment_values = history.loc[self.dataset_symbol].sentiment.values
        for sentiment in previous_sentiment_values:
            self.update(sentiment)
            
    def update(self, sentiment: float) -> None:
        if self.latest_sentiment_value is not None:
            self.target_holdings = int(sentiment > self.latest_sentiment_value)
        self.latest_sentiment_value = sentiment
        
    def on_data(self, slice: Slice) -> None:
        if slice.contains_key(self.dataset_symbol):
            sentiment = slice[self.dataset_symbol].sentiment
            self.update(sentiment)
           
        # Ensure we have security data in the current slice
        if not (slice.contains_key(self.aapl) and slice[self.aapl] is not None):
            return
            
        if self.target_holdings != self.portfolio.invested:
            self.set_holdings(self.aapl, self.target_holdings)

Example Applications

The Brain Sentiment Indicator dataset enables you to incorporate sentiment from financial news sources into your strategies. Examples include the following strategies: