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.
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 the processed longer term (30-day) sentiment score data for sentiment trading
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, cache for comparing last sentiment score to trade, making it immediately tradable signal
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:
# Comparing the last sentiment score and decide to buy if the sentiment increases to ride the popularity
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:
# Update trade direction based on updated data
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 to avoid stale fill
if not (slice.contains_key(self.aapl) and slice[self.aapl] is not None):
return
# Buy if sentiment increase, liquidate otherwise to ride on the popularity of the equity
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:
- 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
Pricing
Cloud Access
Harness Brain Sentiment analysis data in the QuantConnect Cloud for your backtesting and live trading purposes.
Cloud Access Universe
Harness Brain Sentiment Universe analysis data in the QuantConnect Cloud for your backtesting and live trading purposes.
On Premise Download
Brain Sentiment Indicator archived in LEAN format for on premise backtesting and research. One file per ticker per month.
Explore Other Datasets
US ETF Constituents
Dataset by QuantConnect
US Equity Security Master
Dataset by QuantConnect
Crypto Market Cap
Dataset by CoinGecko