finlight Logo

Wednesday, September 23, 2026

Build a News Sentiment Signal for Your Watchlist

Kevin Bartsch

Build a News Sentiment Signal for Your Watchlist

Per-article sentiment is useful, but what you often want is a single number per company: is the news flow leaning positive or negative right now? In this tutorial you'll turn finlight's sentiment and confidence into one confidence-weighted score per ticker, for a whole watchlist, with Python and pandas.

The idea

Each article comes with a sentiment (positive, neutral, negative) and a confidence. We'll:

  1. Pull recent articles for each ticker.
  2. Map sentiment to a number: +1, 0, -1.
  3. Weight each article by its confidence and average per ticker.

The result is a score between -1 and +1 that summarizes the news tone for each company.

The code

import pandas as pd

from finlight_client import FinlightApi, ApiConfig
from finlight_client.models import GetArticlesParams

client = FinlightApi(config=ApiConfig(api_key="YOUR_API_KEY"))

WATCHLIST = ["AAPL", "NVDA", "TSLA"]
SCORE = {"positive": 1, "neutral": 0, "negative": -1}

rows = []
for ticker in WATCHLIST:
    response = client.articles.fetch_articles(
        GetArticlesParams(tickers=[ticker], from_="2026-06-01", pageSize=100)
    )
    for article in response.articles:
        if article.sentiment is None:
            continue
        rows.append({
            "ticker": ticker,
            "score": SCORE.get(article.sentiment, 0),
            "confidence": article.confidence or 0.0,
        })

df = pd.DataFrame(rows)

# Confidence-weighted average sentiment per ticker
df["weighted"] = df["score"] * df["confidence"]
signal = df.groupby("ticker").apply(
    lambda g: g["weighted"].sum() / g["confidence"].sum()
)

print(signal.sort_values(ascending=False))

What you get

signal is one number per ticker:

ticker
NVDA    0.62
AAPL    0.18
TSLA   -0.34

A positive score means the recent news flow leans positive, a negative score means it leans negative, and the magnitude reflects how strong and confident that lean is. Weighting by confidence means a batch of high-confidence stories moves the score more than a pile of uncertain ones.

Make it better

  • Add recency weighting: multiply by a time decay so today's news counts more than last week's.
  • Add volume: track the article count alongside the score, since a strong score on two articles is weaker evidence than the same score on fifty.
  • Go incremental: rerun on a schedule, or switch to the WebSocket to update the signal in real time.

A caution

Sentiment is one input, not a price prediction. Markets can ignore bad news or overreact to good news. Treat this score as a feature to combine with volume, source, and your own models, not a standalone trading rule.

Where to go next

Get your free API key →