Principle:24mlight A Share investment Agent News Sentiment Analysis
| Knowledge Sources | |
|---|---|
| Domains | NLP, Finance, Sentiment_Analysis |
| Last Updated | 2026-10-10 14:00 GMT |
Overview
A method of scoring market sentiment from news articles using Large Language Models, producing a numerical score (-1 to 1), directional signal, confidence level, and reasoning text.
Description
News sentiment analysis extracts subjective information from news text to determine market sentiment toward a specific stock or the broader market. Traditional approaches use lexicon-based or supervised ML methods. The LLM-based approach leverages a Large Language Model's contextual understanding to:
- Parse news titles, content, sources, and publication times
- Weight sentiment by source credibility and timeliness
- Produce a structured JSON output with score (-1 to 1), signal (bullish/bearish/neutral), confidence (0 to 1), and human-readable reasoning
The sentiment score is computed by sending a system prompt (defining the analysis criteria) and a user prompt (containing formatted news content) to an LLM, then parsing the JSON response.
Usage
Use this principle when:
- Assessing market sentiment from recent news articles for trading signals
- Complementing technical and fundamental analysis with qualitative news intelligence
- Building a multi-source sentiment pipeline with caching to avoid redundant LLM calls
Theoretical Basis
The LLM-based sentiment scoring pipeline:
# Abstract pipeline (not real implementation)
def analyze_sentiment(news_list, symbol):
# 1. Format news articles into structured text
news_content = format_articles(news_list[:num_of_news])
# 2. Construct LLM messages
messages = [
{"role": "system", "content": sentiment_system_prompt},
{"role": "user", "content": format_user_prompt(news_content)},
]
# 3. Call LLM and parse JSON response
response = llm.complete(messages)
result = parse_json(response)
# 4. Clamp score to [-1, 1]
score = max(-1.0, min(1.0, result["score"]))
# 5. Derive signal from score
signal = "bullish" if score >= 0.3 else "bearish" if score <= -0.3 else "neutral"
return {score, signal, confidence, reasoning}
Signal thresholds:
score >= 0.3→ bullishscore <= -0.3→ bearish- Otherwise → neutral