simonlin1212/TradingAgents-astock

A股多Agent投研框架 — 适配A股数据源(龙虎榜/游资/解禁等),7位分析师基于A股规则的辩论决策,基于TradingAgents深度改造,适配大A。A-share multi-agent investment research framework — 7 AI analysts, bull/bear debate, risk assessment。

TradingAgents‑Astock – A China‑stock‑focused multi‑LLM research framework

What it is

  • A fork of the open‑source TradingAgents project (the paper TradingAgents: Multi‑Agents LLM Financial Trading Framework). It implements the same multi‑agent pipeline but rewrites the data layer, agent roles and trading rules for China’s A‑share market.
  • Licensed under Apache 2.0, installable with a single pip install -e . and runs locally (no Docker required, though a Docker image is provided).

Key ideas

Dimension Original TradingAgents (US‑stock) TradingAgents‑Astock (China)
Data sources Yahoo Finance, Alpha Vantage Free Chinese data via mootdx (TCP), East‑money, Sina, Tonghuashun, Tencent Finance, etc. – no API keys needed
Analyst roles 4 analysts (market, sentiment, news, fundamentals) 7 analysts – the original 4 plus Policy, Hot‑Money (track “龙虎榜”), and Lockup (share‑unlock monitoring)
Trading constraints US rules (T+0, no price limits) A‑share rules (T+1 settlement, daily涨跌停 limits, minimum lot size, trading windows)
Output language English Chinese reports (internal debate stays English for better reasoning)
Benchmark SPY CSI‑300 (沪深300)

Architecture (high‑level)

  1. 7 Analyst agents generate individual research notes using tool‑calls to the data layer.
  2. Bull vs. Bear researchers debate the notes (configurable number of rounds).
  3. Research Manager (deep‑think LLM) synthesises a trading plan.
  4. Trader converts the plan into an A‑share‑compliant order (T+1, price‑limit checks, lot‑size rounding).
  5. Risk debaters (Aggressive / Neutral / Conservative) discuss risk.
  6. Portfolio Manager (deep‑think LLM) issues a final rating and rationale.

Two LLM tiers are used:

  • quick_think_llm for the fast‑turnover agents (analysts, researchers, trader, risk debaters).
  • deep_think_llm for the two managers that need the whole context.

How to get started

git clone https://github.com/simonlin1212/tradingagents-astock.git
cd tradingagents-astock
pip install -e .
# optional: install a specific LLM provider, e.g.
# pip install --no-deps "langchain-google-genai>=4.0.0"

Create a .env file with the API key of the LLM you want (MiniMax, DeepSeek, ZhiPu, Qwen, OpenAI, Anthropic, etc.).

MINIMAX_API_KEY=sk-…   # or DEEPSEEK_API_KEY, OPENAI_API_KEY, …

Run either the CLI or the Streamlit UI:

tradingagents               # interactive CLI
tradingagents-web           # starts the Streamlit UI
# or
streamlit run web/app.py

Supply a 6‑digit A‑share ticker and a target date; the system will fetch data, run the full 12‑step pipeline, and output a markdown (or PDF) report containing:

  • individual analyst notes
  • the bull/bear debate
  • risk‑debate outcomes
  • a final Buy / Hold / Sell rating with a short justification.

Performance‑tracking feature

  • After each run the decision and the subsequent market outcome (relative to CSI‑300) are logged.
  • tradingagents performance aggregates these logs and reports direction‑accuracy (how often the rating’s direction beat the benchmark), up_rate, outperform_rate, and a monotonicity test of the rating tiers.
  • No extra LLM calls are needed for this statistics; it simply reads the stored logs.

Configuration highlights

  • llm_provider, quick_think_llm, deep_think_llm choose models.
  • max_debate_rounds and max_risk_discuss_rounds control how many back‑and‑forth exchanges occur.
  • role_llms lets you assign different providers/models to specific roles (e.g., give the Bull and Bear debaters different LLMs to avoid echo‑chamber effects).
  • backend_url enables any OpenAI‑compatible gateway (useful for domestic proxies or self‑hosted inference).
  • output_language is currently limited to Chinese (reports) while internal reasoning stays English.

Typical use‑cases

  • Research/teaching – explore how multi‑agent LLM debates behave on Chinese market data.
  • Prototype development – swap in your own data vendor or custom analyst logic while keeping the graph infrastructure.
  • Metric collection – run the framework on historical dates, gather direction‑accuracy statistics, and experiment with prompt or model changes.

What it is not

  • Not an investment advisory service; it emits no actionable price targets, position sizing, or execution instructions.
  • Not a back‑testing engine – the performance view only records the outcome of each single‑day decision without transaction‑cost modeling.
  • Not a turnkey “stock‑picker” app – you must provide your own LLM API keys and run the code on your own hardware.

Bottom line: TradingAgents‑Astock is a fully‑open, pip‑installable research framework that adapts the multi‑LLM TradingAgents architecture to the specifics of China’s A‑share market, offering free data connectors, seven specialized analyst agents, and a complete debate‑to‑rating pipeline suitable for academic study or experimental trading‑research projects.

Related

  • Project
  • Project
  • Project
  • Project
  • Project