Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Implementation:24mlight A Share investment Agent sentiment agent

From Leeroopedia
Knowledge Sources
Domains NLP, Finance, Sentiment_Analysis
Last Updated 2026-10-10 14:00 GMT

Overview

Concrete tool for LLM-based news sentiment analysis that fetches stock news, filters to recent articles, and scores sentiment from -1 to 1 provided by the A_Share_investment_Agent repository.

Description

The sentiment_agent function fetches news via get_stock_news(), filters to the last 7 days, and calls get_news_sentiment() which sends formatted news content to an LLM with sentiment analysis prompts. It parses the LLM JSON response for score, signal, confidence, and reasoning, with fallback handling for errors.

Usage

Import when you need to:

  • Analyze market sentiment from recent news for a stock
  • Run as a parallel node in the LangGraph workflow (after market_data_agent)

Decorated with @agent_endpoint("sentiment", "情绪分析师...").

Code Reference

Source Location

Signature

@agent_endpoint("sentiment", "情绪分析师,分析市场情绪和媒体信号")
def sentiment_agent(state: AgentState) -> dict:
    """Responsible for sentiment analysis."""

Import

from src.agents.sentiment import sentiment_agent

I/O Contract

Inputs

Name Type Required Description
state AgentState Yes Reads data["ticker"], data["end_date"]

Outputs

Name Type Description
messages list HumanMessage with {signal, confidence, reasoning}
data["sentiment_analysis"] str Sentiment score or "error"

Usage Examples =

from src.agents.sentiment import sentiment_agent

# Runs as parallel node after market_data_agent
# 1. Fetches news via get_stock_news(symbol, max_news, date, agent_name="sentiment_agent")
# 2. Filters news to last 7 days
# 3. Calls get_news_sentiment(recent_news, symbol, cache_date, trace_state)
# 4. Returns signal (bullish/bearish/neutral/error), confidence, reasoning

Related Pages

Implements Principle

Requires Environment

Uses Heuristics

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment