TradingAgents-astock is a free, open source ai development platforms project written in Python and released under Apache-2.0. It has 3,366 GitHub stars, 870 forks and 14 open issues, and was last pushed 35 hours ago. On this registry it ranks #116 of 139 tracked projects in AI Development Platforms, with 5 head-to-head comparisons available.

What is TradingAgents-astock?

TradingAgents-astock is an Apache-2.0 Python framework that runs a multi-agent LLM debate over China A-share equities, built for quantitative researchers, students, and developers who need an A-share-aware research and teaching harness rather than a trading system.

What it is

TradingAgents-astock is a deeply specialised fork of TauricResearch/TradingAgents, the 65K-star multi-agent investment research framework from the TradingAgents paper, published under the full Apache 2.0 licence. It lives in the Python and LangGraph LLM-agent ecosystem, and it reorganises the upstream architecture around China A-share market structure across three dimensions: the data layer, the analyst roles, and the trading rules applied to decisions.

The concrete thing it replaces is the upstream framework's US-market data and reasoning path — Yahoo Finance and Alpha Vantage feeds, four analysts who do not understand A-share institutions, T+0 assumptions with no price limits, English output, and the SPY benchmark. This fork instead connects directly to mootdx, Eastmoney, Sina, Tencent, Tonghuashun, CLS, and Baidu Stocks, adds three A-share-specific analysts, enforces T+1 settlement, daily price limits, minimum lot sizes, ST status, and trading sessions, produces Chinese reports while keeping internal debate in English for reasoning quality, and benchmarks against the CSI 300. The project is an engineering implementation and research reproduction of the paper framework, aimed at research and teaching, and it explicitly does not constitute investment advice or provide any investment service.

Key capabilities

  • Seven analysts feed the decision chain: the original market, sentiment, news, and fundamentals roles plus a policy analyst for regulatory and industrial policy, a hot-money tracker for 龙虎榜 and large-order flow, and a lockup monitor for share unlocks, major-holder reductions, and equity pledges.
  • A staged LangGraph pipeline runs bull versus bear research debate for up to N rounds, then a Research Manager investment plan, then a Trader plan constrained by A-share rules, then aggressive, conservative, and neutral risk debate, and finally a Portfolio Manager rating with rationale.
  • A dual-LLM split assigns quick_think_llm to analysts, researchers, traders, and risk debaters, while deep_think_llm handles the Research Manager and Portfolio Manager.
  • Analyst tooling is explicit and named: get_stock_data, get_indicators, get_news, get_global_news, get_insider_transactions, get_fundamentals, get_balance_sheet, get_cashflow, and get_income_statement.
  • Every data source is free and requires no API key and no points wall: mootdx over TCP 7709, Tencent via qt.gtimg.cn, Eastmoney datacenter and push2 endpoints, Sina, Tonghuashun 10jqka consensus EPS, CLS cls.cn newsflash, and Baidu Stocks concept-sector classification.
  • Eastmoney request throttling is centralised in _em_get(), using serial rate limiting with a default interval of at least one second plus 0.1 to 0.5 seconds of jitter, a reused Keep-Alive session, and an optional EM_MIN_INTERVAL=1.5~2 environment variable for batch runs.

Who uses it and how

  • Academic and teaching users reproduce the TradingAgents paper's multi-agent debate design on A-share names, where the policy, hot-money, and lockup analysts make the A-share mechanics part of the exercise.
  • Quant and fintech developers prototype A-share sentiment, fund-flow, and event research, running batch analyses across many tickers and raising EM_MIN_INTERVAL to stay under Eastmoney's risk-control thresholds.
  • Individual developers run the full seven-analyst workflow on single stocks, either from the command line or through the bundled Web UI, with no Docker requirement.
  • Users who hold a personal Claude Pro or Max subscription can install the [agentsdk] extra so eligible nodes consume subscription quota instead of API billing.
  • Teams deliberately avoid Tushare points walls, Alpha Vantage overseas APIs, and Yahoo Finance, none of which the project depends on.

Getting started

Install with Python 3.10 or newer by cloning the repository and running pip install -e .; Google Gemini support is added separately with langchain-google-genai, google-genai, and httpx. No Docker is needed, and the package runs from a pip install with zero external service dependencies.

How it compares

The nearest comparison is the upstream TradingAgents project this fork is derived from, and both carry the same full Apache 2.0 licence. They diverge on market coverage: upstream pulls from Yahoo Finance and Alpha Vantage and reasons in US-market terms, while this fork uses free direct A-share sources and adds three market-specific analyst roles. They also diverge on constraints and language, since this fork enforces T+1, price limits, lot sizes, and ST rules, and emits Chinese reports.

When to use it — and when not to

A self-hoster operates little beyond a Python environment, since there is no external database, storage tier, or SMTP service to run, but the workflow still requires LLM credentials for the quick and deep thinking models. Anyone looking for live execution, order routing, or investment advice should not pick it, because the project is scoped to research and teaching only. The honest weaknesses are its dependence on free scraped HTTP endpoints that rate-limit and change without notice, and the maintenance surface that comes with tracking upstream framework changes.

project readme (upstream, from github) — read inline

简体中文 | English

TradingAgents-Astock

基于 TauricResearch/TradingAgents(65K ⭐)的 A 股深度特化 fork
全 Apache 2.0 开源 · pip install 即跑 · 零外部服务依赖

⚠️ 本项目是 TradingAgents 论文框架的工程实现与研究复现,面向研究与教学。
不构成任何投资建议,也不提供任何投资服务。

Stars Forks 论文 License 改动记录

为什么做这个 Fork · 与上游对比 · 架构概览 · Analyst 角色 · 数据源 · 快速开始 · Web UI · 排错


为什么做这个 Fork

原版 TradingAgents 是一个出色的多 Agent 投研框架,但它针对美股设计:数据走 Yahoo Finance / Alpha Vantage,分析师不懂 A 股制度,辩论和决策完全面向美股市场。

本 Fork 的目标:把 TradingAgents 的多 Agent 辩论架构真正落地到 A 股,不是简单翻译,而是从数据层、Agent 角色、交易规则三个维度做深度特化。

核心改造

维度 原版 本 Fork
数据源 Yahoo Finance / Alpha Vantage mootdx + 东财 + 新浪 + 同花顺(全免费直连)
Analyst 角色 4 个(市场/情绪/新闻/基本面) 7 个(+政策分析师/游资追踪/解禁监控)
交易规则 美股(T+0、无涨跌停) A 股(T+1、涨跌停、最小手数、交易时段)
输出语言 英文 中文报告(内部辩论保持英文以保证推理质量)
Alpha 基准 SPY 沪深 300(CSI 300)

与上游对比

特性 原版 TradingAgents 本 Fork
许可证 Apache 2.0 全 Apache 2.0
部署依赖 pip install 开箱即用
A 股数据 mootdx + 东财 + 新浪 + 同花顺(直连 HTTP)
A 股特化角色 政策/游资/解禁 3 个深度角色
A 股交易约束 T+1/涨跌停/手数/ST 全覆盖

架构概览

┌─────────────────────────────────────────────────────────┐
│                    7 Analyst 研报生成                      │
│  Market → Social → News → Fundamentals                   │
│  → Policy → Hot Money → Lockup                           │
│         (每个 Analyst 带工具循环)                          │
├─────────────────────────────────────────────────────────┤
│               Bull vs Bear 投研辩论                       │
│         Bull Researcher ←→ Bear Researcher               │
│               (最多 N 轮辩论)                             │
├─────────────────────────────────────────────────────────┤
│              Research Manager 综合研判                     │
│         (深度思考 LLM,输出投资计划)                       │
├─────────────────────────────────────────────────────────┤
│                  Trader 交易方案                          │
│         (A 股约束:T+1/涨跌停/手数)                       │
├─────────────────────────────────────────────────────────┤
│        Aggressive ←→ Conservative ←→ Neutral             │
│               三方风险辩论                                 │
├─────────────────────────────────────────────────────────┤
│            Portfolio Manager 最终决策                      │
│     (深度思考 LLM,输出评级 + 理由)                       │
└─────────────────────────────────────────────────────────┘

双 LLM 设计

  • quick_think_llm:所有 Analyst、Researcher、Trader、Risk Debater
  • deep_think_llm:Research Manager 和 Portfolio Manager(需要综合全局信息做决策)

7 个 Analyst 角色

原版 4 角色(A 股适配)

角色 职责 数据工具
🏪 市场分析师 K 线形态、技术指标、量价分析 get_stock_data, get_indicators
💬 舆情分析师 社交媒体情绪、散户讨论热度 get_news
📰 新闻分析师 行业新闻、公告、宏观事件 get_news, get_global_news, get_insider_transactions
📊 基本面分析师 财报三表、盈利能力、估值 get_fundamentals, get_balance_sheet, get_cashflow, get_income_statement

A 股特化 3 角色(新增)

角色 职责 数据工具 为什么需要
🏛️ 政策分析师 监管政策、产业政策、窗口指导 get_news, get_global_news A 股是政策市,政策变化直接影响板块轮动
🔥 游资追踪师 龙虎榜、大单流向、主力资金动态 get_stock_data, get_news, get_insider_transactions 游资是 A 股短线定价的核心力量
🔓 解禁监控师 限售股解禁、大股东减持、股权质押 get_insider_transactions, get_news, get_fundamentals 解禁是 A 股特有的重大供给冲击因素

所有 7 个 Analyst 的报告会流入后续的 Bull/Bear 辩论和三方风险辩论,确保 A 股特色因素贯穿整条决策链。


数据源

全部免费,无需 API Key,无积分墙:

来源 协议 提供内容
mootdx TCP 7709 OHLCV K 线、财务快照、F10 文本
腾讯财经 HTTP (qt.gtimg.cn) PE / PB / 市值 / 换手率(实时)
东方财富 HTTP (datacenter / push2) 龙虎榜、限售解禁、板块行情、个股信息
新浪财经 HTTP K 线历史、财报三表
同花顺 HTTP (10jqka) EPS 一致预期
财联社 HTTP (cls.cn) 全球财经快讯
百度股市通 HTTP (finance.pae.baidu) 概念板块分类、资金流向

完全不依赖 Tushare(积分墙)、Alpha Vantage(海外 API)、Yahoo Finance(不支持 A 股)。


数据源优先级 & 东财防封(v0.2.11):行情 / K线 / 市值 / 财务能从 mootdx(通达信 TCP,不封 IP)或腾讯拿到的,一律走它们;东财只用于它独有的数据(龙虎榜 / 解禁 / 资金流 / 板块 / 个股新闻等)。所有东财请求统一走内置节流入口 _em_get():串行限流(默认间隔 ≥1s + 0.1~0.5s 随机抖动)+ 复用 Keep-Alive 会话,多 Agent 跑批量分析不再触发临时封 IP(东财风控实测:每秒 >5 / 并发 ≥10 / 1 分钟 ≥200 触发封禁)。批量场景可设环境变量 EM_MIN_INTERVAL=1.5~2 进一步降速。仅东财限流,mootdx / 腾讯 / 新浪 / 同花顺 / 财联社 / 百度 不受影响。

快速开始

1. 环境准备

# Python >= 3.10
git clone https://github.com/simonlin1212/tradingagents-astock.git
cd tradingagents-astock
pip install -e .

# 如需使用 Google Gemini 模型(无 [google] extra,需显式装,见下方 FAQ):
pip install --no-deps "langchain-google-genai>=4.0.0"
pip install "google-genai>=1.53.0" "httpx>=0.28.1"

# 如需让节点走你个人 Claude Pro/Max 订阅额度而非 API 计费(可选):
pip install -e ".[agentsdk]"

装完即可用,无需 Docker。 安装后直接跑 streamlit run web/app.py(Web UI)或 tradingagents(CLI)即可,详见下方「Web UI」「CLI 方式」两节。Docker 仅是可选的部署方式,本地开发不需要。

2. 配置 LLM

默认走 API Key 计费。每次分析需 30-50 次 LLM 调用。

例外(v0.4.0 新增):装 [agentsdk] 后可让部分或全部节点经 Claude Agent SDK 走你个人 Claude Pro/Max 订阅额度,不产生 API 账单。见下方「用个人 Claude 订阅额度」。

在项目根目录创建 .env 文件,按你选择的供应商配置:

# ── 方案 A:MiniMax(推荐,国内直连,性价比高)──────────
MINIMAX_API_KEY=sk-xxx
# 申请地址:https://platform.minimaxi.com/

# ── 方案 B:DeepSeek ─────────────────────────────────
DEEPSEEK_API_KEY=sk-xxx
# 申请地址:https://platform.deepseek.com/

# ── 方案 C:智谱 GLM ─────────────────────────────────
ZHIPU_API_KEY=xxx
# 申请地址:https://open.bigmodel.cn/

# ── 方案 D:通义千问 Qwen ────────────────────────────
DASHSCOPE_API_KEY=sk-xxx
# 申请地址:https://dashscope.console.aliyun.com/

# ── 方案 E:OpenAI ───────────────────────────────────
OPENAI_API_KEY=sk-xxx

# ── 方案 F:Anthropic ────────────────────────────────
ANTHROPIC_API_KEY=sk-ant-xxx

# ── 方案 G:Kimi(Anthropic 兼容 API)────────────────
ANTHROPIC_API_KEY=your-kimi-token
ANTHROPIC_BASE_URL=https://api.kimi.com/coding/
# ⚠️ 两个都要设。只给 key 不给端点,请求会发到 Anthropic 官方并报
#    「401 invalid x-api-key」。端点也可以写在 config 的 backend_url 里(见下)。
# ⚠️ 别用 ANTHROPIC_AUTH_TOKEN——那是 Claude Code CLI 的写法,本项目走 langchain,
#    只认 ANTHROPIC_API_KEY。

# ── 方案 H:任意 OpenAI 兼容网关(9Router / AI Router / 自建代理)──
OPENAI_COMPATIBLE_API_KEY=sk-xxx     # 也接受 OPENAI_API_KEY
BACKEND_URL=https://your-relay.example/v1   # 你的网关地址(也可在 Web 侧栏「API Base URL」填)

3. 运行分析

新建一个 Python 文件(比如项目根目录下的 run.py),把下面这段粘进去,按你选的供应商改 config 后运行 uv run python run.py。根目录自带的 main.py 就是这个示例的可运行版本,直接 uv run python main.py 也行。

config 不是仓库里的某个配置文件,而是传给 TradingAgentsGraph(config=...) 的一个字典:只写你要覆盖的项,其余项自动取 tradingagents/default_config.py 里的默认值(完整可选项见下文「配置说明」一节)。

from tradingagents.graph.trading_graph import TradingAgentsGraph

# ── MiniMax 示例(推荐)─────────────────────────────
config = {
    "llm_provider": "minimax",
    "deep_think_llm": "MiniMax-M2.7",
    "quick_think_llm": "MiniMax-M2.7-highspeed",
    "output_language": "Chinese",
}

# ── DeepSeek 示例 ───────────────────────────────────
# config = {
#     "llm_provider": "deepseek",
#     "deep_think_llm": "deepseek-chat",
#     "quick_think_llm": "deepseek-chat",
#     "output_language": "Chinese",
# }

# ── Anthropic + Kimi 示例 ───────────────────────────
# config = {
#     "llm_provider": "anthropic",
#     "deep_think_llm": "claude-sonnet-4-6",
#     "quick_think_llm": "claude-sonnet-4-6",
#     "backend_url": "https://api.kimi.com/coding/",
#     "output_language": "Chinese",
# }

ta = TradingAgentsGraph(debug=True, config=config)
final_state, decision = ta.propagate("688017", "2026-05-12")
print(decision)

4. CLI 方式

tradingagents                 # 交互式 CLI
tradingagents analyze         # 同上(默认命令)
tradingagents performance     # 决策绩效统计(见下)
tradingagents --help          # 查看所有选项

5. 决策绩效统计(v0.5.2 新增)

想知道这套流程过往的判断准不准,跑:

tradingagents performance            # 人读的报告
tradingagents performa

readme truncated — read the full docs on github

Frequently asked questions

Is TradingAgents-astock free to use?

TradingAgents-astock is open source under the Apache-2.0 licence. There is no licence fee and no seat count — you can self-host it or, where the project offers one, pay a vendor for a managed version instead.

What does TradingAgents-astock do?

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

What is TradingAgents-astock written in?

TradingAgents-astock is primarily written in Python. Its source is publicly available at https://github.com/simonlin1212/TradingAgents-astock, and it has 3,366 GitHub stars.