TradingAgents for A-Shares
A multi-agent investment-research framework tailored to China’s A-share market rules and data.
- Source repo
- simonlin1212/TradingAgents-astock
- Stars
- ★ 3.9k
- Last updated
- 8d ago
- License
- Apache-2.0
- Primary language
- Python
- FA score
- 78/100 · Good
At a glance
- How it runs
- Works with
- Universal · cross-platformOpenAI API · Claude APIClaude Code · Claude.ai (Partial support)
- Cost
- Free software; you pay for model usage
- Setup effort
- Medium · a few setup steps
- You'll need
- Typical use
- A financial-AI researcher studying multi-agent debate behavior while incorporating policy, hot-money, and lockup factors specific to A-shares.
- Not a fit if
- Traders who need executable entry prices, stop-losses, sizing or targets
- Users who want a turnkey service without supplying their own paid LLM API key
- Source review
- 78/100 · Good
What does this agent do, and when should you use it?
TradingAgents-Astock is an A-share-focused fork and engineering implementation of the TradingAgents paper framework, intended for research and teaching rather than investment services. Its LangGraph workflow combines seven analysts, a bull-versus-bear research debate, trade planning, and a three-party risk debate before a Portfolio Manager returns a rating and rationale. The framework retrieves market, financial, news, and A-share-specific information from sources including mootdx, Tencent Finance, Eastmoney, Sina Finance, Tonghuashun, Cailianpress, and Baidu Stock Connect. It can run as a Python library through TradingAgentsGraph, through an interactive CLI, or through a Streamlit web interface with Markdown and PDF exports. Users provide their own LLM credentials and run it locally; the repository does not host an analysis service or retain results.
A call such as TradingAgentsGraph.propagate("688017", "2026-05-12") runs seven LangGraph analyst roles: market, social, news, fundamentals, policy, hot-money tracking, and lockup monitoring. They generate reports using data tools named get_stock_data, get_indicators, get_news, get_global_news, get_fundamentals, get_balance_sheet, get_cashflow, get_income_statement, and get_insider_transactions. Their reports then flow through Bull Researcher and Bear Researcher debate, Research Manager synthesis, Trader planning, and Aggressive, Conservative, and Neutral risk discussion. The Portfolio Manager produces a direction, rating, and rationale; the framework explicitly does not produce entry prices, stop-loss levels, position sizes, or target prices. The web UI exposes 12-stage progress, report viewing, history, and Markdown/PDF downloads, while the CLI and examples/run_cases.py can write complete reports and summary.json files to disk.
- A financial-AI researcher studying multi-agent debate behavior while incorporating policy, hot-money, and lockup factors specific to A-shares.
- A Python-capable individual researcher who wants to run a repeatable, multi-stage analysis for one six-digit A-share ticker.
- An investment-research instructor who needs separate technical, financial, news, and risk-discussion reports for teaching.
- A non-programming user who wants to enter a ticker, date, and lookback period in a local Streamlit interface and inspect the full analysis flow.
- A user who needs to batch-run symbols with examples/run_cases.py and save complete_report.md plus summary.json.
How do you install or deploy this agent?
Requires Python >= 3.10, network access, and credentials for at least one supported LLM provider.
git clone https://github.com/simonlin1212/tradingagents-astock.git
cd tradingagents-astockpip install -e .
Create a .env file in the project root, for example:
MINIMAX_API_KEY=sk-xxxThe documented alternatives include DEEPSEEK_API_KEY, DASHSCOPE_API_KEY, ZHIPU_API_KEY, OPENAI_API_KEY, ANTHROPIC_API_KEY, and other provider-specific variables. The optional Claude Agent SDK mode is installed with:
pip install -e ".[agentsdk]"How do you use this agent?
First Python invocation:
from tradingagents.graph.trading_graph import TradingAgentsGraphconfig = {"llm_provider": "minimax",
"deep_think_llm": "MiniMax-M2.7",
"quick_think_llm": "MiniMax-M2.7-highspeed",
"output_language": "Chinese",
}
ta = TradingAgentsGraph(debug=True, config=config)
final_state, decision = ta.propagate("688017", "2026-05-12")
print(decision)For the interactive CLI, run tradingagents. For the web UI, run tradingagents-web or streamlit run web/app.py, then open http://localhost:8501.
What are this agent's strengths and limitations?
- Its workflow incorporates A-share constraints such as T+1 settlement, price limits, minimum lot sizes, and ST coverage in the trading layer.
- It adds dedicated policy, hot-money, and lockup analysts for A-share-specific factors including Dragon Tiger List activity, fund flows, shareholder reductions, and restricted-share unlocks.
- It separates quick_think_llm from deep_think_llm and documents paths for MiniMax, DeepSeek, Qwen, GLM, OpenAI, Anthropic, Google, xAI, OpenRouter, Ollama, and OpenAI-compatible gateways.
- It offers a Python API, CLI, Streamlit UI, saved history, and Markdown/PDF report export.
- A typical analysis uses roughly 30–50 LLM calls and normally requires the user’s own API key and paid provider account, except when using the optional Claude subscription path.
- Data collection depends on several public network sources; Eastmoney requests require built-in throttling, and batch use is advised to set EM_MIN_INTERVAL=1.5~2.
- Some analyst reports can be empty when the selected model has unreliable tool-calling behavior; the documented remedy is a more capable model or a retry.
- Google Gemini dependencies have a structural httpx installation conflict with mootdx, requiring explicit package installation or a separate virtual environment.
- The project deliberately omits executable entry prices, stop-losses, position sizing, and target prices, so it is not a complete trade-execution system.
How does this agent compare with similar options?
Compared with upstream TradingAgents, this fork replaces the Yahoo Finance / Alpha Vantage-oriented data path with A-share data sources and expands four analyst roles to seven. It changes the benchmark from SPY to CSI 300 and adds A-share trading constraints. The documentation also presents its direct data retrieval approach as avoiding dependencies on Tushare, Alpha Vantage, and Yahoo Finance.
Key facts side by side with the most closely related agents.
| Agent | Source review | Form / cost | Stars | Updated | Language | Full support on |
|---|---|---|---|---|---|---|
| TradingAgents for A-Shares This agent | 78 · Good | Library / SDKFree + model costs | ★ 3.9k | 8d ago | Python | OpenAI API · Claude API |
| TradingAgents Financial Research Framework | 74 · Some gaps | CLIFree + model costs | ★ 121k | 4d ago | Python | OpenAI API · Claude API |
| OpenLens Research Agent | 46 · Major gaps | CLIFree + model costs | ★ 282 | 2mo ago | Python | OpenAI API |
| ALTA Research Trading Workbench | 76 · Good | Web app | ★ 1.1k | 1mo ago | Python | — |
How does FollowAgents rate this agent?
Why each dimension lost points
The README says users configure and run the system themselves, with no hosted service or access to their results. It names data sources, LLM providers, environment variables, proxy endpoints, and local memory, making data flows unusually clear. Credentials are configured through environment variables, and the subscription SDK subprocess is documented as clearing ANTHROPIC_API_KEY; however, general secret storage and rotation guidance and a complete pre-analysis confirmation or data-access permission model are not shown, so full marks are not justified.
The README documents timeouts, retries, throttling, and failure messages, while supplied tests cover SDK timeout and fallback paths. CLAUDE.md records concrete past misses such as non-A-share ticker checks and Responses API truncation warnings, showing corrective maintenance but also that coverage claims can lag behavior. Dependencies mostly have lower bounds; the Gemini/httpx conflict and optional SDK path are explained, but reliability of every dependency path is not demonstrated.
The audience and use case are clearly A-share research and education. The product supports CLI, Web, batch scripts, multiple LLM providers, role-specific models, and analysis dates. The README explicitly excludes investment services, precomputed security conclusions, position sizing, and target prices. Configuration and invalid role-name behavior are described; actual behavior remains dependent on data vendors and model tool-calling ability.
The README covers architecture, data sources, roles, configuration, quick start, CLI/Web, FAQ, product positioning, and limitations. pyproject specifies Python requirements, entry points, dependencies, and an optional extra. LICENSE contains Apache-2.0 terms, with README attribution to NOTICE and upstream. CLAUDE.md records version and maintenance practices, but is partly contributor guidance, and the evidence does not establish a clear ongoing maintenance commitment, so maintenance responsibility is not full marks.
Reports combine analyst work, debate, risk assessment, and a rating with reasons, with Markdown/PDF export and history. The performance section explains direction-accuracy semantics, sample-size caveats, and why the metric is not a backtest. A-share-specific roles and rules add value over a generic framework, but outputs still depend on external LLMs and data sources; the README estimates 30–50 LLM calls per analysis, so cost-benefit varies by provider and use.
The README supports major product claims with configuration details, named sources, interface roles, and feature descriptions; pyproject and test source corroborate entry points, dependencies, and some timeout behavior. It distinguishes research positioning, AI-generated risk, and performance-statistic limitations, and documents warnings for some data without historical point-in-time values. Many source coverage, effectiveness, and historical-fix claims remain documentation assertions, and this review did not run or independently verify them.
- This is a research and education framework. Model-generated output may be wrong and is not investment advice or validated investment performance.
- Analysis depends on external LLMs and third-party market/news sources; operators must manage keys, billing, endpoint privacy, and source availability.
- The README estimates 30–50 LLM calls per analysis. Its performance statistics are not a backtest and have overlapping holding windows, omit costs, and may have sample bias.
Recent releases
Latest entries from the project's GitHub Releases. Notes are quoted from upstream as written, not rewritten or tested by FollowAgents.
-
Release notes excerpt
v0.5.22 - fix: 历史日期调用时跳过实时请求及快照写入,明确说明实时数据已略去,不输出由其生成的金额或方向信号。可选缓存先按分析日截断,再取最近 20 条;无可用记录时说明缺失,保留当天调用行为。 (#121) 详见 CHANGELOG.md。View on GitHub ↗ -
v0.5.21 v0.5.21 — 财报三表恢复 + 防未来函数 / 自定义模型 ID
Release notes excerpt
基本面分析师近 5 个月拿不到的三张财报恢复了,并且回看历史日期时只给分析日之前已经公布的财报;Web 侧栏的「Custom model ID」可以正常使用。建议所有用户升级。 修复 - 资产负债表 / 利润表 / 现金流量表恢复(#116,#117 by @ontheway06):新浪财报接口的数据在 report_list 里,v0.2.5(2026-05-17)起的解析只认另一种结构,三张表一直静默返回「No … data found」,分析师会把「该股没有财报」当成事实。现在两种结构都认;同名科目(如两个「利息收入」)不再互相覆盖。 - 回看历史时不再提前看到未公布的财报:原来按「报告期 ≤ 分析日」筛,分析日 07-15 会拿到 8 月才发的半年报。现在按新浪给的公告日、入库时间判断是否已公布;两个日期都被后来的报表改写时才按法定披露截止日判断;新浪 2020-03-13 给全市场的批量入库单独识别。逾期披露的公司也不会提前露出(例:300630 的 2023 年报 2024-07-05 才发,分析日 2024-05-15 看不到)。 - 三张财报表工具的分析日期改为必填(传空日期会要求重传),提示词写明要传;回看越早取的期数越多,2016 年等较早日期也能取到;升级前记下的缺数据重试会自动补上分析日期。 …View on GitHub ↗ -
v0.5.20 v0.5.20 — 超时保护补全
Release notes excerpt
修复 - 补齐 Claude Agent SDK 订阅主路径的超时保护。llm_timeout 现在同样覆盖订阅调用;单轮按配置值计时,内部工具循环按允许轮数换算总预算。 - 超时后显式收尾 SDK 异步生成器;即使 SDK 阻塞自身事件循环或不响应取消,调用方也会通过 daemon 工作线程的有界等待返回,不再永久卡住。 - 保持付费护栏:超时可走已配置的 fallback,认证失效仍不会静默降级到按 token 计费的 provider。 - 为 Alpha Vantage 请求增加 30 秒网络超时,避免上游无响应时整轮分析永久等待。 验证 - 默认环境:512 passed / 13 skipped / 0 failed,另有 51 个 subtests 通过。 - 安装 agentsdk 可选依赖的隔离环境:34 passed。 - 新增 35 条超时与配置回归用例,并完成 9 项变异验证。 - Claude Opus 5 实现与复核;Cline CLI 的 Kimi K3 独立只读审查无 P0/P1/P2。 完整变更见 [CHANGELOG.md](https://github.com/simonlin1212/TradingAgents-astock/blob/v0.5.20/CHANGELOG.md)。View on GitHub ↗
FAQ
Does it provide entry prices, stop-losses, or position sizes?
Does it cost money to run?
Why might an analyst report be missing?
Can it use a self-hosted or third-party OpenAI-compatible gateway?
Thanks — we use this to improve the page.