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

Principle:24mlight A Share investment Agent Macro News Analysis

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

Overview

Analysis of macroeconomic news and events to assess the broader market environment and its impact on specific stocks, using both market-wide index news (CSI 300) and stock-specific news filtered through LLM evaluation.

Description

Macro news analysis operates at two levels:

  1. Market-Wide Macro Analysis (CSI 300): Fetches news for the CSI 300 index (ticker "000300") and sends it to an LLM with a structured prompt to produce a macro environment assessment. The result includes signal, confidence, score (0-100), summary, key drivers, key risks, and actionable insights. Results are cached in SQLite keyed by date to avoid redundant LLM calls.
  1. Stock-Specific Macro Analysis: Fetches news specific to the target stock, filters to the last 7 days, and sends up to 50 articles to an LLM with prompts that ask for macro environment assessment, impact on the stock, key factors, and reasoning. The result provides context on how broader economic trends affect the individual stock.

Both approaches use prompt templates stored in Markdown files and parse LLM JSON responses with fallback extraction for malformed JSON.

Usage

Use this principle when:

  • Assessing how broader macroeconomic conditions affect individual stock investment decisions
  • Providing market-wide context (CSI 300 index news) alongside stock-specific analysis
  • Caching expensive LLM macro analysis results to avoid redundant API calls

Theoretical Basis

The LLM-based macro analysis pipeline:

# Abstract pipeline (not real implementation)
def analyze_macro_news(news_list, symbol):
    # 1. Format news articles (up to 50)
    news_content = format_articles(news_list[:50])

    # 2. Construct LLM messages with structured prompt
    messages = [
        {"role": "system", "content": macro_system_prompt},
        {"role": "user", "content": format_user_prompt(news_content)},
    ]

    # 3. Call LLM
    result = llm.complete(messages)

    # 4. Parse JSON (with fallback for code fences, bracket extraction)
    analysis = parse_json_with_fallback(result)

    return {
        macro_environment,  # bullish/bearish/neutral
        impact_on_stock,     # positive/negative/neutral
        key_factors,         # list of driving factors
        reasoning           # detailed LLM reasoning text
    }

For market-wide (CSI 300) analysis, additional fields:

  • score: 0-100 macro sentiment score
  • key_drivers: list of positive macro drivers
  • key_risks: list of macro risk factors
  • actionable_insight: actionable investment guidance

Related Pages

Implemented By

Page Connections

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