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 – AI‑driven research agents for China’s A‑share market
What it is – A fork of the open‑source TradingAgents framework that tailors the multi‑agent investment‑research pipeline to the Chinese A‑share market. It bundles all code, data connectors and a Streamlit UI into a pip‑installable package (Apache‑2.0). The system is a research‑oriented prototype, not a trading service, and comes with a disclaimer that it gives no investment advice.
Why it exists – The original TradingAgents was built for U.S. equities (Yahoo Finance, Alpha Vantage, T+0, no price‑limits). Those assumptions don’t hold for A‑shares, which have:
- T+1 settlement, daily price‑limit bands, minimum lot sizes, and trading windows.
- Strong policy‑driven market dynamics.
- Distinct data sources (mootdx, East‑money, Sina, Tonghuashun, etc.)
The fork rewrites the data layer, adds three China‑specific analyst roles, and adapts the trading rules.
Core components
| Component | Role |
|---|---|
| 7 Analyst agents | Market, Social, News, Fundamentals (original) + Policy, Hot‑Money Tracker, Lock‑up Monitor (A‑share specific). Each pulls data from the built‑in vendors and produces a short report. |
| Bull / Bear researchers | Debate the merits of a long vs. short thesis (default 1 round). |
| Research Manager | Deep‑thinking LLM that synthesises the analyst reports and debate into an investment plan. |
| Trader | Generates an executable order respecting A‑share constraints (T+1, price limits, lot size, trading session). |
| Risk debaters | Aggressive / Neutral / Conservative agents argue risk exposure. |
| Portfolio Manager | Final deep‑thinking LLM that outputs a rating (Buy/Hold/Sell) and justification. |
| Data layer | Free, no‑API‑key connectors: mootdx (TCP), Tencent finance, East‑money, Sina, Tonghuashun, Caixin, Baidu Stock. |
| Web UI | Streamlit front‑end showing the 12‑step pipeline, progress, and downloadable Markdown/PDF reports. |
| CLI | tradingagents command for interactive use, batch analysis, and performance statistics. |
How it works (high‑level flow)
- Data fetch – Each analyst calls its vendor functions (e.g.,
get_stock_data,get_news). - Analyst reports – Short Chinese‑language write‑ups (internal debate stays in English for LLM consistency).
- Bull vs. Bear debate – The two researchers exchange arguments for up to
max_debate_rounds(default 1). - Research Manager – A “deep‑think” LLM consumes all reports and debate output, producing an investment plan.
- Trader – Generates a concrete order respecting A‑share rules.
- Risk debate – Aggressive / Neutral / Conservative agents discuss risk.
- Portfolio Manager – Final deep‑think LLM outputs a rating and rationale.
- Result – The system returns a structured decision object and a full multi‑section report.
Getting started (quick steps)
# 1. Clone & install (Python ≥3.10)
git clone https://github.com/simonlin1212/tradingagents-astock.git
cd tradingagents-astock
pip install -e .
# 2. Set LLM credentials (choose one provider)
cat > .env <<EOF
MINIMAX_API_KEY=sk-xxxx # or DEEPSEEK_API_KEY, OPENAI_API_KEY, etc.
EOF
# 3. Run the UI (or CLI)
tradingagents-web # opens http://localhost:8501
# or
tradingagents analyze # interactive prompt
The README also provides a minimal Python example using TradingAgentsGraph to analyze a single ticker.
What you can do with it
- Research & teaching – Run the full multi‑agent pipeline on any A‑share ticker to see how LLM‑driven analysts reason about price, policy, hot‑money flow, and lock‑up events.
- Experiment with LLM providers – Switch between MiniMax, DeepSeek, Qwen, GLM, OpenAI, Anthropic, Google Gemini, Ollama, or any OpenAI‑compatible gateway via the
llm_providerandbackend_urlsettings. - Batch performance analysis – After several runs,
tradingagents performancecomputes direction‑accuracy, out‑performance vs. CSI‑300, and rating discrimination without extra LLM calls. - Customize roles – Use the
role_llmsconfig to give different models to the Bull/Bear debaters or any other agent, useful for research on model‑specific bias.
Limitations & caveats
- Research‑only – No execution engine, no portfolio‑level risk management, and no transaction‑cost modeling. The disclaimer explicitly states it is not an investment service.
- LLM cost – Each analysis triggers 30‑50 LLM calls; you need a paid API key unless you use a local Ollama model or the Claude‑SDK subscription trick.
- Data reliability – All data sources are free but may be rate‑limited (East‑money throttling is built‑in). Occasionally a specific analyst may return an empty report if the model fails to invoke its tool.
- Model output length – Some providers truncate reports; you may need to raise
max_tokensin the config. - Performance metrics – The
performancecommand reports direction accuracy based on a fixed holding window; it is not a back‑test and can be noisy with few samples.
Who might find it useful?
- Academic or corporate researchers exploring LLM‑driven financial reasoning on Chinese equities.
- Quant developers who want a ready‑made multi‑agent research scaffold to plug into their own execution systems.
- Students learning about AI agents, tool‑calling, and the peculiarities of the A‑share market.
TL;DR – TradingAgents‑Astock is a fully open‑source, pip‑installable framework that runs a chain of seven AI analysts, debate modules, and risk managers to produce Chinese‑language investment reports for China’s A‑share market, with a web UI and CLI for quick experimentation. It is a genuine AI research project, not a curated list or tutorial.
Related
- Project
- Project
- Project
- Project
- Project