News sentiment analysis uses artificial intelligence to quantify the mood of financial news. Instead of reading hundreds of articles, traders can use sentiment scores to quickly gauge whether coverage is bullish, bearish, or neutral.
What is News Sentiment Analysis?
News sentiment analysis is the process of using natural language processing (NLP) and machine learning to extract the emotional tone from financial news articles, press releases, and other text sources.
The output is typically a sentiment score—a numerical value representing how positive or negative the coverage is for a particular stock or asset.
Typical sentiment scale:
- +1.0 = Extremely bullish
- +0.5 = Moderately positive
- 0.0 = Neutral
- -0.5 = Moderately negative
- -1.0 = Extremely bearish
How Sentiment Analysis Works
Modern sentiment analysis uses several techniques:
| Technique | Description |
|---|---|
| Lexicon-based | Counts positive/negative words using financial dictionaries |
| Machine Learning | Models trained on labeled financial text |
| Deep Learning | Transformer models (BERT, GPT) that understand context |
| Hybrid | Combines multiple approaches for accuracy |
Why Context Matters
Financial sentiment is nuanced. Consider these examples:
- “Revenue fell 5%” → Negative
- “Revenue fell only 5%, beating expectations” → Positive
- “The company killed it this quarter” → Positive (idiom)
Advanced models understand these contextual differences that simple keyword counting would miss.
Why Sentiment Matters for Trading
News sentiment can be a leading indicator:
| Use Case | Description |
|---|---|
| Early signal | Sentiment shifts before price moves |
| Confirmation | Validates technical or fundamental analysis |
| Risk management | Detect negative sentiment before position sizing |
| Contrarian plays | Extreme sentiment can signal reversals |
Sentiment as a Contrarian Indicator
Extreme readings often precede reversals:
| Sentiment Level | Potential Interpretation |
|---|---|
| Above +0.7 | Excessive optimism—potential top |
| Below -0.7 | Excessive pessimism—potential bottom |
| -0.3 to +0.3 | Neutral—no strong directional bias |
This works because markets tend to overshoot in both directions based on news cycles.
Accessing Sentiment Data
You can access historical sentiment scores through the FinBrain API:
from finbrain import FinBrainClient
fb = FinBrainClient(api_key="YOUR_API_KEY")
# Get sentiment data as DataFramedf = fb.sentiments.ticker("S&P 500", "AAPL", as_dataframe=True)
print(df.tail())# sentiment# date# 2024-11-04 0.186# 2024-11-01 0.339# 2024-10-31 0.565
# Calculate sentiment statisticsprint(f"\nMean sentiment: {df['sentiment'].mean():.3f}")print(f"Current sentiment: {df['sentiment'].iloc[-1]:.3f}")
# Add moving averages for trend analysisdf["ma5"] = df["sentiment"].rolling(5).mean()df["ma20"] = df["sentiment"].rolling(20).mean()
# Detect sentiment momentumdf["momentum"] = df["sentiment"] - df["ma5"]
# Find extreme readingsextreme_bullish = df[df["sentiment"] > 0.7]extreme_bearish = df[df["sentiment"] < -0.7]
print(f"\nDays with extreme bullish sentiment: {len(extreme_bullish)}")print(f"Days with extreme bearish sentiment: {len(extreme_bearish)}")Building Sentiment Signals
Momentum Strategy
Trade in the direction of sentiment momentum:
def sentiment_momentum_signal(df): """Generate signal based on sentiment momentum""" current = df["sentiment"].iloc[-1] ma5 = df["sentiment"].tail(5).mean() ma20 = df["sentiment"].tail(20).mean()
# Momentum crossover if ma5 > ma20 and current > 0.2: return "bullish" elif ma5 < ma20 and current < -0.2: return "bearish" else: return "neutral"Contrarian Strategy
Trade against extreme sentiment:
def contrarian_signal(df, lookback=20): """Generate contrarian signal from extreme sentiment""" recent = df.tail(lookback) current = recent["sentiment"].iloc[-1] mean = recent["sentiment"].mean() std = recent["sentiment"].std()
z_score = (current - mean) / std if std > 0 else 0
if z_score > 2: return "contrarian_sell" # Too optimistic elif z_score < -2: return "contrarian_buy" # Too pessimistic else: return "neutral"Combining Sentiment with Other Data
Sentiment works best when combined with other signals:
- Sentiment + Price Action – Confirm breakouts with positive sentiment
- Sentiment + Insider Buying – High conviction when both align
- Sentiment + AI Predictions – Multiple models agreeing increases confidence
- Sentiment + Technical Levels – Use sentiment to validate support/resistance
Key Takeaways
- News sentiment analysis quantifies the mood of financial news
- Scores typically range from -1 (bearish) to +1 (bullish)
- Extreme readings can serve as contrarian indicators
- Sentiment momentum can signal directional trades
- Best used in combination with other data sources
Ready to add sentiment analysis to your trading strategy? Explore the News Sentiment Dataset and API Reference.