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

class BrainSentimentDataAlgorithm(QCAlgorithm):
    
    latest_sentiment_value = None
    target_holdings = 0
    
    def Initialize(self) -> None:
        self.SetStartDate(2019, 1, 1)
        self.SetEndDate(2021, 7, 8)
        self.SetCash(100000) 
        
        # Requesting data
        self.symbol = self.AddEquity("AAPL", Resolution.Daily).Symbol
        self.dataset_symbol = self.AddData(BrainSentimentIndicator30Day, self.symbol).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 OnData(self, slice: Slice) -> None:
        if slice.ContainsKey(self.dataset_symbol):
            sentiment = slice[self.dataset_symbol].Sentiment
            self.update(sentiment)
           
        # Ensure we have security data in the current slice
        if not (slice.ContainsKey(self.symbol) and slice[self.symbol] is not None):
            return
            
        if self.target_holdings != self.Portfolio.Invested:
            self.SetHoldings(self.symbol, 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: