Sentiment & News
When to use
Activate when a user wants the news read on a DSE stock or sector: "what's the
sentiment on GP?", "is the news good or bad?", "is this just a rumour?", "score the
headlines". This is the Sentiment Agent (PRD-002 REQ-019). Its score is designed to
feed signal-synthesizer alongside the technical and fundamental legs.
What it does
Reads the shared contract's news array and produces an aggregate sentiment score in
[-1, +1]. Because the DSE is rumour-heavy (PRD-001 REQ-023), it explicitly
separates rumour-driven from fundamentals-driven items:
- Lexicon scoring — each headline is scored from positive vs negative keyword counts (stdlib only; no NLP libraries).
- Rumour detection — an item is a
RUMOURif itssourceis social/forum/ unconfirmed/rumour, its category is rumour-like, or its headline mentions rumour/unconfirmed/speculation. Rumours are down-weighted to x0.3 and, when they are the only material signal, the score is capped to[-0.4, +0.4]so a rumour alone can never drive a strong signal. - Fundamental classification — items in
earnings,regulatory,corporate_action, ormacrocarry full weight.
Output is a Thinking Card (see suite README).
How to run
python3 scripts/sentiment.py --input data.json --pretty
cat data.json | python3 scripts/sentiment.py
Reads news (required) and optional mode/ticker/as_of. Returns score
(-1..+1, fundamental-weighted), confidence, rating (positive/neutral/negative),
key_metrics (item/fundamental/rumour counts, average fundamental sentiment),
per-item reasoning, and flags.
Try it now with the shared fixture:
python3 scripts/sentiment.py --input ../_fixtures/sample_input.json --pretty
Interpreting output
rating:positive(score >=0.2),negative(<=-0.2), elseneutral.flags:rumour_dominated(no fundamental items, score capped) andthin_coverage(<2 items) both lower confidence — never silent drops.- Compare
avg_fundamental_sentimentagainst the headlinescoreto see how much of the read is fundamentals vs noise.
Notes
The lexicon, rumour-vs-news separation rationale, and DSE rumour context are documented in references/SENTIMENT.md. Output is educational analysis only, never financial advice.