Implementation:24mlight A Share investment Agent macro analyst agent
| Knowledge Sources | |
|---|---|
| Domains | Finance, Macro_Economics, NLP |
| Last Updated | 2026-10-10 14:00 GMT |
Overview
Concrete tool for stock-specific macro news analysis via LLM, fetching and filtering recent news then evaluating macro environment impact on the target stock, provided by the A_Share_investment_Agent repository.
Description
The macro_analyst_agent function fetches stock-specific news via get_stock_news(), filters to the last 7 days, and calls get_macro_news_analysis() which sends up to 50 news articles to an LLM with macro analyst prompts. The LLM returns a JSON assessment of macro environment, impact on stock, key factors, and reasoning.
The companion function get_macro_news_analysis handles LLM call, JSON parsing with code fence and bracket extraction fallbacks.
Usage
Import when you need to:
- Analyze how macroeconomic news affects a specific stock
- Run after risk_management_agent in the LangGraph workflow
Decorated with @agent_endpoint("macro_analyst", "宏观分析师...").
Code Reference
Source Location
- Repository: A_Share_investment_Agent
- File: src/agents/macro_analyst.py
- Lines: L17-113 (agent), L116-222 (get_macro_news_analysis)
Signature
@agent_endpoint("macro_analyst", "宏观分析师,分析宏观经济环境对目标股票的影响")
def macro_analyst_agent(state: AgentState) -> dict:
"""Responsible for macro analysis"""
def get_macro_news_analysis(
news_list: list,
*,
symbol: str | None = None,
cache_date: str | None = None,
trace_state: dict | None = None,
) -> dict:
"""Analyze macro news impact on a stock via LLM."""
Import
from src.agents.macro_analyst import macro_analyst_agent, get_macro_news_analysis
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 {macro_environment, impact_on_stock, key_factors, reasoning} |
| data["macro_analysis"] | dict | Full macro analysis for downstream agents |
Usage Examples
from src.agents.macro_analyst import macro_analyst_agent
# Runs after risk_management_agent
# 1. Fetches news via get_stock_news(symbol, agent_name="macro_analyst_agent")
# 2. Filters to last 7 days
# 3. Calls get_macro_news_analysis() with up to 50 news items
# 4. LLM returns: macro_environment, impact_on_stock, key_factors, reasoning