QuantRocket logo
Disclaimer


Brain Sentiment Data › Part 2: Brain Sentiment Indicator


Brain Sentiment Indicator¶

In this notebook, we use Alphalens to examine the Brain Sentiment Indicator dataset (BSI). This dataset captures sentiment from news sources.

Start by setting the bundle for this notebook:

In [1]:
from zipline.research import use_bundle
use_bundle("usstock-1d-bundle")

Next, we create a Pipeline that contains the BUZZ_VOLUME_SENTIMENT field using a 1-day lookback. This field quantifies news volume relative to the past. We limit the analysis to the top 1000 stocks by dollar volume.

In [2]:
from zipline.pipeline import Pipeline, brain, master
from zipline.pipeline.factors import AverageDollarVolume

# limit analysis to stocks
universe = master.SecuritiesMaster.SecType.latest.eq("STK")

avg_dollar_volume = AverageDollarVolume(window_length=90)

buzz_volume_sentiment =  brain.BSI.slice(1).BUZZ_VOLUME_SENTIMENT.latest

pipeline = Pipeline(
    columns={
        "buzz_volume_sentiment": buzz_volume_sentiment,
    },
    initial_universe=universe,
    screen=(
        avg_dollar_volume.top(1000) 
        & buzz_volume_sentiment.notnull()
    )
)

Next, we run the Pipeline and generate the tear sheet. Stocks with higher than normal news volume (quantile 5) underperform stocks in other quantiles.

In [3]:
import alphalens as al

factor_data = al.from_pipeline(
    pipeline,
    start_date="2016-08-01", # start of dataset
    end_date="2024-03-31",
    factor="buzz_volume_sentiment",
    periods=[1, 21],
    quantiles=5,
    segment="Y"
)
Factor Distribution
 minmaxmeanstdcountavg daily countcount %
Buzz Volume Sentiment Quantile       
1-1.6892.335-0.4880.328208,426108.220.1%
2-0.8894.351-0.1330.416207,218107.620.0%
3-0.6865.6540.1980.560207,228107.620.0%
4-0.5358.7230.6880.779207,197107.620.0%
5-0.373148.8702.4582.703207,959108.020.0%
Returns Analysis
 1D21D
Ann. alpha-0.005-0.009
beta-0.004-0.003
Mean Relative Return Top Quantile (bps)-0.643-0.333
Mean Relative Return Bottom Quantile (bps)0.0460.265
Mean Spread (bps)-0.689-0.605
Information Analysis
 1D21D
IC Mean-0.002-0.005
IC Std.0.0630.060
Risk-Adjusted IC-0.032-0.081
t-stat(IC)-1.395-3.575
p-value(IC)0.1630.000
IC Skew0.130-0.196
IC Kurtosis0.4920.467
Turnover Analysis
 1D21D
Quantile 1 Mean Turnover0.6840.745
Quantile 2 Mean Turnover0.8000.828
Quantile 3 Mean Turnover0.8230.846
Quantile 4 Mean Turnover0.8230.851
Quantile 5 Mean Turnover0.7090.836
1D21D
Mean Factor Rank Autocorrelation0.3310.136

Next Up¶

Part 3: Brain Language Metrics on Company Filings