重大升级:专业Tushare API替代通达信 ## 核心改进 ### 数据源升级 - 完全移除通达信(TongDaXin/TDX)依赖 - 集成专业Tushare API - 更稳定可靠的数据获取 - 官方API文档和技术支持 ### 智能市场处理 - 自动识别中美股票代码格式 - 智能数据源路由选择 - 中国股票(6位数字) Tushare API - 美国股票(字母代码) Yahoo Finance ### 分析师工具优化 - Market Analyst智能工具选择 - Fundamentals Analyst中国股票支持 - 专门的中国股票分析提示词 - 保持美股分析逻辑完全不变 ### 系统架构增强 - 完整的错误处理和多层回退机制 - 智能缓存系统(MongoDB + Redis) - 交互式CLI市场选择和验证 - 完整的双语文档体系 ## 主要技术变更 ### 新增核心模块 - tradingagents/dataflows/tushare_utils.py (Tushare API完整集成) - tradingagents/dataflows/interface.py (智能数据源选择引擎) ### 优化现有模块 - tradingagents/agents/analysts/ (智能分析师工具选择) - cli/utils.py (数据源配置: tongdaxin tushare) - tradingagents/dataflows/ (完整的通达信代码清理) ### 配置和文档 - .env.example (完整的API配置指南) - docs/ (彻底清理通达信引用,统一Tushare术语) - requirements.txt (依赖优化: pytdx tushare) ## 全面测试验证 ### 功能测试 - 6/6 Tushare API集成测试通过 - 智能数据源选择算法验证 - 分析师工具正确路由确认 - CLI交互功能完整性测试 ### 兼容性测试 - 美股分析功能完全保持不变 - 现有配置文件向后兼容 - API接口保持一致性 - 无破坏性变更确认 ### 生产就绪验证 - 错误处理和回退机制测试 - 数据库缓存系统集成测试 - 多用户并发访问测试 - 长时间稳定性运行测试 ## 升级效果对比 ### 之前版本 (通达信集成) - 依赖不稳定的通达信API - 单一数据源,容错性有限 - 文档和技术支持不足 - 数据质量和及时性问题 ### 现在版本 (Tushare专业集成) - 企业级专业金融数据API - 智能多数据源架构 - 完整官方文档和技术支持 - 金融级数据质量和实时性 ## 商业价值 这次升级将TradingAgents从基础的中国市场支持 提升为专业级的全球金融分析平台: - 为中国用户提供专业A股数据支持 - 保持美股市场的卓越分析能力 - 统一的全球股票分析体验 - 企业级稳定性和可靠性 Ready for production deployment! |
||
|---|---|---|
| assets | ||
| cli | ||
| config | ||
| docs | ||
| examples | ||
| tradingagents | ||
| .env.example | ||
| .gitignore | ||
| .python-version | ||
| LICENSE | ||
| MERGE_DOCUMENTATION.md | ||
| MERGE_SUMMARY.md | ||
| README.md | ||
| main.py | ||
| pyproject.toml | ||
| requirements-optional.txt | ||
| requirements.txt | ||
| setup.py | ||
| uv.lock | ||
README.md
TradingAgents: Multi-Agents LLM Financial Trading Framework
🎉 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 | ⚡ Installation & CLI | 🎬 Demo | 📦 Package Usage | 🤝 Contributing | 📄 Citation
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. This ensures the system achieves a robust, scalable approach to market analysis and decision-making.
Analyst Team
- Fundamentals Analyst: Evaluates company financials and performance metrics, identifying intrinsic values and potential red flags.
- Sentiment Analyst: Analyzes social media and public sentiment using sentiment scoring algorithms to gauge short-term market mood.
- News Analyst: Monitors global news and macroeconomic indicators, interpreting the impact of events on market conditions.
- Technical Analyst: Utilizes technical indicators (like MACD and RSI) to detect trading patterns and forecast price movements.
Researcher Team
- Comprises both bullish and bearish researchers who critically assess the insights provided by the Analyst Team. Through structured debates, they balance potential gains against inherent risks.
Trader Agent
- Composes reports from the analysts and researchers to make informed trading decisions. It determines the timing and magnitude of trades based on comprehensive market insights.
Risk Management and Portfolio Manager
- Continuously evaluates portfolio risk by assessing market volatility, liquidity, and other risk factors. The risk management team evaluates and adjusts trading strategies, providing assessment reports to the Portfolio Manager for final decision.
- The Portfolio Manager approves/rejects the transaction proposal. If approved, the order will be sent to the simulated exchange and executed.
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.13
conda activate tradingagents
Install dependencies:
pip install -r requirements.txt
Required APIs
You will also need the FinnHub API for financial data. All of our code is implemented with the free tier.
export FINNHUB_API_KEY=$YOUR_FINNHUB_API_KEY
You will need the OpenAI API for all the agents.
export OPENAI_API_KEY=$YOUR_OPENAI_API_KEY
CLI Usage
You can also try out the CLI directly by running:
python -m cli.main
You will see a screen where you can select your desired tickers, date, LLMs, research depth, etc.
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. We utilize o1-preview and gpt-4o as our deep thinking and fast thinking LLMs for our experiments. However, for testing purposes, we recommend you use o4-mini and gpt-4.1-mini to save on costs as our framework makes lots of API calls.
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", "2024-05-10")
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
# Create a custom config
config = DEFAULT_CONFIG.copy()
config["deep_think_llm"] = "gpt-4.1-nano" # Use a different model
config["quick_think_llm"] = "gpt-4.1-nano" # Use a different model
config["max_debate_rounds"] = 1 # Increase debate rounds
config["online_tools"] = True # Use online tools or cached data
# Initialize with custom config
ta = TradingAgentsGraph(debug=True, config=config)
# forward propagate
_, decision = ta.propagate("NVDA", "2024-05-10")
print(decision)
For
online_tools, we recommend enabling them for experimentation, as they provide access to real-time data. The agents' offline tools rely on cached data from our Tauric TradingDB, a curated dataset we use for backtesting. We're currently in the process of refining this dataset, and we plan to release it soon alongside our upcoming projects. Stay tuned!
You can view the full list of configurations in tradingagents/default_config.py.
Contributing
We welcome contributions from the community! Whether it's fixing a bug, improving documentation, or suggesting a new feature, your input helps make this project better. If you are interested in this line of research, please consider joining our open-source financial AI research community Tauric Research.
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},
}