TradingAgents README

The project's README from github.com/TauricResearch/TradingAgents. As one markdown file: README.md.

arXiv Discord X Follow Community

TradingAgents #1 Repository of the Day

Deutsch | Español | français | 日本語 | 한국어 | Português | Русский | 中文

TradingAgents: Multi-Agents LLM Financial Trading Framework

News

🚀 TradingAgents | ⚡ Installation & CLI | 🎬 Demo | 📦 Package Usage | 🤝 Contributing | 📄 Citation

🎉 TradingAgents officially released! We have received numerous inquiries about the work, and we would like to express our thanks for the enthusiasm in our community.

So we decided to fully open-source the framework. Looking forward to building impactful projects with you!

TradingAgents Framework

TradingAgents is a multi-agent trading framework that mirrors the dynamics of real-world trading firms. By deploying specialized LLM-powered agents: from fundamental analysts, sentiment experts, and technical analysts, to trader, risk management team, the platform collaboratively evaluates market conditions and informs trading decisions. Moreover, these agents engage in dynamic discussions to pinpoint the optimal strategy.

TradingAgents framework is designed for research purposes. Trading performance may vary based on many factors, including the chosen backbone language models, model temperature, trading periods, the quality of data, and other non-deterministic factors. It is not intended as financial, investment, or trading advice.

Our framework decomposes complex trading tasks into specialized roles.

Analyst Team

Researcher Team

Trader Agent

Risk Management and Portfolio Manager

Installation and CLI

Installation

Clone TradingAgents:

git clone https://github.com/TauricResearch/TradingAgents.git
cd TradingAgents

Create a virtual environment in any of your favorite environment managers:

conda create -n tradingagents python=3.12
conda activate tradingagents

Install the package and its dependencies:

pip install .

Docker

Alternatively, run with Docker:

cp .env.example .env  # add your API keys
docker compose run --rm tradingagents

For local models with Ollama:

docker compose --profile ollama run --rm tradingagents-ollama

Required APIs

TradingAgents supports multiple LLM providers. Set the API key for your chosen provider:

export OPENAI_API_KEY=...          # OpenAI (GPT)
export GOOGLE_API_KEY=...          # Google (Gemini)
export ANTHROPIC_API_KEY=...       # Anthropic (Claude)
export XAI_API_KEY=...             # xAI (Grok)
export DEEPSEEK_API_KEY=...        # DeepSeek
export DASHSCOPE_API_KEY=...       # Qwen — International (dashscope-intl.aliyuncs.com)
export DASHSCOPE_CN_API_KEY=...    # Qwen — China (dashscope.aliyuncs.com)
export ZHIPU_API_KEY=...           # GLM via Z.AI (international)
export ZHIPU_CN_API_KEY=...        # GLM via BigModel (China, open.bigmodel.cn)
export MINIMAX_API_KEY=...         # MiniMax — Global (api.minimax.io)
export MINIMAX_CN_API_KEY=...      # MiniMax — China (api.minimaxi.com)
export OPENROUTER_API_KEY=...      # OpenRouter
export ALPHA_VANTAGE_API_KEY=...   # Alpha Vantage

For Azure OpenAI, copy .env.enterprise.example to .env.enterprise and fill in your credentials.

For AWS Bedrock, install the extra with pip install ".[bedrock]", set llm_provider: "bedrock", configure AWS credentials (environment variables, ~/.aws/credentials, or an IAM role) and AWS_DEFAULT_REGION, and use a Bedrock model ID, e.g. us.anthropic.claude-opus-4-8-v1:0.

For local models, configure Ollama with llm_provider: "ollama". The default endpoint is http://localhost:11434/v1; set OLLAMA_BASE_URL to point at a remote ollama-serve. Pull models with ollama pull <name>, and pick "Custom model ID" in the CLI for any model not listed by default.

For any other OpenAI-compatible server (vLLM, LM Studio, llama.cpp, or a custom relay), use llm_provider: "openai_compatible" and set the endpoint via backend_url (or TRADINGAGENTS_LLM_BACKEND_URL), e.g. http://localhost:8000/v1 for vLLM or http://localhost:1234/v1 for LM Studio. The model is whatever your server serves. No key is needed for local servers; set OPENAI_COMPATIBLE_API_KEY when the endpoint requires one.

Alternatively, copy .env.example to .env and fill in your keys:

cp .env.example .env

CLI Usage

Launch the interactive CLI:

tradingagents          # installed command
python -m cli.main     # alternative: run directly from source

You will see a screen where you can select your desired tickers, analysis date, LLM provider, research depth, and more.

Markets and tickers

TradingAgents works with any market Yahoo Finance covers, using the exchange-suffixed ticker. Company identity and the alpha benchmark resolve automatically per market.

An interface will appear showing results as they load, letting you track the agent's progress as it runs.

TradingAgents Package

Implementation Details

We built TradingAgents with LangGraph to ensure flexibility and modularity. The framework supports multiple LLM providers: OpenAI, Google, Anthropic, xAI, DeepSeek, Qwen (Alibaba DashScope, international and China endpoints), GLM (Zhipu), MiniMax (global + China), OpenRouter, Ollama for local models, and Azure OpenAI for enterprise.

Python Usage

To use TradingAgents inside your code, you can import the tradingagents module and initialize a TradingAgentsGraph() object. The .propagate() function will return a decision. You can run main.py, here's also a quick example:

from tradingagents.graph.trading_graph import TradingAgentsGraph
from tradingagents.default_config import DEFAULT_CONFIG

ta = TradingAgentsGraph(debug=True, config=DEFAULT_CONFIG.copy())

# forward propagate
_, decision = ta.propagate("NVDA", "2026-01-15")
print(decision)

You can also adjust the default configuration to set your own choice of LLMs, debate rounds, etc.

from tradingagents.graph.trading_graph import TradingAgentsGraph
from tradingagents.default_config import DEFAULT_CONFIG

config = DEFAULT_CONFIG.copy()
config["llm_provider"] = "openai"        # e.g. openai, google, anthropic, deepseek, groq, ollama; openai_compatible covers any OpenAI-compatible endpoint (vLLM, LM Studio, llama.cpp, ...)
config["deep_think_llm"] = "gpt-5.6"      # Model for complex reasoning
config["quick_think_llm"] = "gpt-5.6-luna" # Model for quick tasks
config["max_debate_rounds"] = 2

ta = TradingAgentsGraph(debug=True, config=config)
_, decision = ta.propagate("NVDA", "2026-01-15")
print(decision)

See tradingagents/default_config.py for all configuration options.

Persistence and Recovery

TradingAgents persists two kinds of state across runs.

Decision log

The decision log is always on. Each completed run appends its decision to ~/.tradingagents/memory/trading_memory.md. On the next run for the same ticker, TradingAgents fetches the realised return (raw and alpha vs SPY), generates a one-paragraph reflection, and injects the most recent same-ticker decisions plus recent cross-ticker lessons into the Portfolio Manager prompt, so each analysis carries forward what worked and what didn't.

Override the path with TRADINGAGENTS_MEMORY_LOG_PATH.

Checkpoint resume

Checkpoint resume is opt-in via --checkpoint. When enabled, LangGraph saves state after each node so a crashed or interrupted run resumes from the last successful step instead of starting over. On a resume run you will see Resuming from step N for <TICKER> on <date> in the logs; on a new run you will see Starting fresh. Checkpoints are cleared automatically on successful completion.

Per-ticker SQLite databases live at ~/.tradingagents/cache/checkpoints/<TICKER>.db (override the base with TRADINGAGENTS_CACHE_DIR). Use --clear-checkpoints to reset all of them before a run.

tradingagents analyze --checkpoint           # enable for this run
tradingagents analyze --clear-checkpoints    # reset before running
config = DEFAULT_CONFIG.copy()
config["checkpoint_enabled"] = True
ta = TradingAgentsGraph(config=config)
_, decision = ta.propagate("NVDA", "2026-01-15")

Reproducibility

TradingAgents is LLM-driven, so two runs of the same ticker and date can differ. This is expected for a research tool built on language models, not a defect. The variation comes from a few distinct sources, and it helps to separate them.

Language model sampling is non-deterministic. Even at a fixed temperature, providers do not guarantee byte-identical output across calls, and reasoning models (the default GPT-5.x family, and any thinking-mode model) vary the most because their internal reasoning is itself sampled.

Live data moves. News, StockTwits, and Reddit return different content as time passes, so a run today sees different inputs than a run last week even for the same historical trade date. Pin the analysis date to hold the price and indicator window fixed, but the social and news sources still reflect "now".

To reduce variation you can lower the sampling temperature. Set temperature in your config (or TRADINGAGENTS_TEMPERATURE in .env); lower values make models that honor it more repeatable. The current curated models are reasoning-first and largely ignore temperature, so for tighter reproducibility use a non-reasoning model, which you can set explicitly via the Custom model ID option.

config = DEFAULT_CONFIG.copy()
config["llm_provider"] = "openai"
config["temperature"] = 0.0
# Reasoning models ignore temperature. For tighter reproducibility, set a
# non-reasoning deep/quick model explicitly (e.g. via the Custom model ID option).

What does not vary anymore: the analyzed company identity is resolved deterministically from the ticker before any agent runs, and the market analyst grounds exact price and indicator claims in a verified data snapshot. Earlier reports of "different companies" or fabricated price levels across runs are addressed by these two mechanisms.

Backtest results are not guaranteed to match any published figure. Returns depend on the model, the temperature, the date range, data quality, and the sampling above. Treat the framework as a research scaffold for studying multi-agent analysis, not as a strategy with a fixed, replicable return.

Contributing

Contributions are welcome: bug fixes, documentation, and feature ideas; past contributions are credited per release in CHANGELOG.md.

Citation

Please reference our work if you find TradingAgents provides you with some help :)

@misc{xiao2025tradingagentsmultiagentsllmfinancial,
      title={TradingAgents: Multi-Agents LLM Financial Trading Framework}, 
      author={Yijia Xiao and Edward Sun and Di Luo and Wei Wang},
      year={2025},
      eprint={2412.20138},
      archivePrefix={arXiv},
      primaryClass={q-fin.TR},
      url={https://arxiv.org/abs/2412.20138}, 
}

TradingAgents (TauricResearch/TradingAgents)

Searching Database…

这是什么?TradingAgents 是一个多智能体 LLM 框架,用来模拟一家交易公司:不同的专业智能体分别分析基本面、市场情绪、新闻和技术面;看多与看空两方研究员对分析结果进行辩论;再由交易员和风险与投资组合经理团队决定是否执行交易。
这是一个可以接入我自己代码的框架,还是一个现成的交易机器人?两者都是。你可以运行交互式 CLI,端到端地分析股票代码;也可以在自己的 Python 代码中导入 tradingagents 模块,调用 TradingAgentsGraph().propagate() 来获取决策结果。
我怎样才能让它跑起来?克隆仓库,创建虚拟环境,用 pip 安装该包及其依赖,然后启动交互式 CLI;也支持使用 Docker 作为替代方式。
使用哪些 LLM 提供商需要我准备 API 密钥?它支持 OpenAI、Google、Anthropic、xAI、DeepSeek、通义千问(Qwen)、智谱 GLM、MiniMax、OpenRouter、Azure OpenAI 和 AWS Bedrock,还支持任何兼容 OpenAI 接口的服务(如 vLLM、LM Studio、llama.cpp);本地运行的 Ollama 模型则完全不需要密钥。
同一只股票跑两次,结果会一样吗?不会。LLM 的采样本身具有随机性,而且实时新闻和社交数据会随时间变化,所以即使是同一只股票、同一日期,结果也会有差异。降低 temperature,或通过 Custom model ID 选项选用非推理类模型,可以减少这种差异。
这是用来真正交易的吗?不是。它仅用于研究目的,明确不构成任何金融、投资或交易建议;获批的订单会发送到模拟交易所,而不是真实的经纪商。
我能分析哪些股票市场和股票代码?Yahoo Finance 覆盖的任何市场都可以,使用带交易所后缀的代码:美国(AAPL)、香港(0700.HK)、东京(7203.T)、伦敦(AZN.L)、印度、加拿大、澳大利亚、中国 A 股,以及 BTC-USD 这类加密货币交易对。
决策日志在多次运行之间会记住什么?它是一个始终开启的日志,位于 ~/.tradingagents/memory/trading_memory.md,记录每只股票过去的决策和实际收益,然后把这些复盘内容注入到下一次运行的 Portfolio Manager 提示词中,让经验教训得以延续。
检查点续跑是做什么用的?这是一个可选功能(需加 --checkpoint 参数),基于 LangGraph,会在每个节点执行后保存状态。因此运行中断或崩溃后,可以从最后一个成功的步骤继续,而不必从头开始。
为什么回测收益不一定与公开发布的数字一致?收益取决于所选模型、temperature、日期范围以及实时数据质量,因此应将该框架视为用于研究多智能体分析的研究脚手架,而不是固定、可复现的策略。
Size
6.3 MB
Stars
112K
Age
1y
Commits · 90 Days