---
# 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](#tradingagents-framework) | 🌐 [Web Interface](#web-interface) | ⚡ [Installation](#installation) | 🚀 [Deployment](#deployment) | 📦 [Package Usage](#tradingagents-package) | 🤝 [Contributing](#contributing) | 📄 [Citation](#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.](https://tauric.ai/disclaimer/)
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.
## Web Interface
TradingAgents now includes a modern web interface that provides an intuitive way to interact with the multi-agent trading system. The web interface features:
### ✨ Key Features
- **🎨 Modern UI**: Clean, dark-themed interface inspired by Gemini CLI
- **🤖 Multiple AI Providers**: Support for OpenAI, Gemini, DeepSeek, and OpenRouter
- **🔄 Automatic Fallback**: Seamless switching between providers when one fails
- **📱 Responsive Design**: Works perfectly on desktop and mobile devices
- **⚡ Real-time Analysis**: Get instant stock analysis and trading insights
- **🔐 Secure**: Environment-based API key management
### 🖥️ Interface Preview
The web interface provides:
- **Provider Selection**: Choose your preferred AI provider or let the system auto-select
- **Chat Interface**: Natural language interaction with the trading agents
- **Fallback Notifications**: Get notified when the system switches providers
- **Provider Status**: Monitor the health and availability of all AI providers
- **Responsive Design**: Seamless experience across all devices
### 🌐 Quick Start (Web Interface)
1. **Set up your environment**:
```bash
cp env.example .env
# Edit .env with your API keys
```
2. **Install dependencies**:
```bash
pip install -r requirements.txt
```
3. **Run the web server**:
```bash
python -m uvicorn backend.main:app --host 0.0.0.0 --port 8000
```
4. **Open your browser** and navigate to `http://localhost:8000`
## Installation
Clone TradingAgents:
```bash
git clone https://github.com/TauricResearch/TradingAgents.git
cd TradingAgents
```
Create a virtual environment in any of your favorite environment managers:
```bash
conda create -n tradingagents python=3.13
conda activate tradingagents
```
Install dependencies:
```bash
pip install -r requirements.txt
```
### Required APIs
#### AI Provider APIs (at least one required)
**OpenAI** (Recommended):
```bash
export OPENAI_API_KEY=$YOUR_OPENAI_API_KEY
```
Get your key at: https://platform.openai.com/api-keys
**Google Gemini**:
```bash
export GEMINI_API_KEY=$YOUR_GEMINI_API_KEY
```
Get your key at: https://aistudio.google.com/app/apikey
**DeepSeek**:
```bash
export DEEPSEEK_API_KEY=$YOUR_DEEPSEEK_API_KEY
```
Get your key at: https://platform.deepseek.com/api_keys
**OpenRouter**:
```bash
export OPENROUTER_API_KEY=$YOUR_OPENROUTER_API_KEY
```
Get your key at: https://openrouter.ai/keys
#### Financial Data API
**FinnHub** (Required for financial data):
```bash
export FINNHUB_API_KEY=$YOUR_FINNHUB_API_KEY
```
Get your key at: https://finnhub.io/register (Free tier available)
#### Provider Configuration
Set your preferred provider priority:
```bash
export PROVIDER_PRIORITY=openai,gemini,deepseek,openrouter
```
### CLI Usage
You can also try out the CLI directly by running:
```bash
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.
## Deployment
TradingAgents can be easily deployed to production environments using Docker or manual installation.
### 🐳 Docker Deployment (Recommended)
The fastest way to deploy TradingAgents is using Docker Compose:
```bash
# Clone the repository
git clone https://github.com/TauricResearch/TradingAgents.git
cd TradingAgents
# Configure environment
cp env.example .env
# Edit .env with your API keys
# Deploy with Docker
docker-compose up -d
# Check status
docker-compose ps
```
Your application will be available at `http://localhost` with automatic SSL support.
### 🌐 VPS Deployment (Ubuntu/ClawCloud)
For detailed deployment instructions on Ubuntu VPS (including ClawCloud), see our comprehensive [Deployment Guide](DEPLOYMENT.md).
**Quick Ubuntu deployment:**
```bash
# Update system and install dependencies
sudo apt update && sudo apt upgrade -y
sudo apt install -y git python3.11 python3.11-venv nginx redis-server
# Clone and setup
git clone https://github.com/TauricResearch/TradingAgents.git
cd TradingAgents
python3.11 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
# Configure environment
cp env.example .env
# Edit .env with your API keys
# Run the application
python -m uvicorn backend.main:app --host 0.0.0.0 --port 8000
```
### 🔧 Configuration
The application uses environment variables for configuration. Key settings include:
- **AI Provider Keys**: `OPENAI_API_KEY`, `GEMINI_API_KEY`, etc.
- **Provider Priority**: `PROVIDER_PRIORITY=openai,gemini,deepseek`
- **Financial Data**: `FINNHUB_API_KEY`
- **Server**: `PORT=8000`, `ENVIRONMENT=production`
See `env.example` for a complete list of configuration options.
### 🔒 Security Features
- **Automatic Fallback**: Seamless switching between AI providers
- **Rate Limiting**: Built-in request throttling
- **SSL Support**: Automatic HTTPS with Let's Encrypt
- **Environment Variables**: Secure API key management
- **CORS Protection**: Configurable cross-origin policies
### 📊 Monitoring
The application includes built-in monitoring endpoints:
- **Health Check**: `GET /health` - Application status
- **Provider Status**: `GET /providers` - AI provider availability
- **Metrics**: Built-in logging and error tracking
For production deployments, we recommend:
- Using a reverse proxy (Nginx included in Docker setup)
- Setting up monitoring with Prometheus/Grafana
- Implementing log aggregation
- Regular backups of configuration and data
## TradingAgents Package
### Implementation Details
We built TradingAgents with LangGraph to ensure flexibility and modularity. The framework now supports multiple AI providers with automatic fallback capabilities, making it more robust and cost-effective.
### Usage Options
#### 1. Web Interface (Recommended)
The easiest way to use TradingAgents is through the web interface:
```bash
# Start the web server
python -m uvicorn backend.main:app --host 0.0.0.0 --port 8000
# Open http://localhost:8000 in your browser
```
The web interface provides:
- **Multi-provider support** with automatic fallback
- **Real-time analysis** with natural language queries
- **Provider status monitoring**
- **Responsive design** for all devices
#### 2. Python API
You can also use TradingAgents programmatically:
```python
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.
```python
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`.
#### 3. Provider System (New)
TradingAgents now includes a sophisticated provider management system:
```python
from providers import ProviderRouter
# Initialize with automatic provider detection
router = ProviderRouter()
# Generate response with automatic fallback
response, metadata = router.generate_response(
"Analyze TSLA stock performance",
preferred_provider="openai"
)
print(f"Response from {metadata['provider_used']}: {response}")
if metadata['fallback_occurred']:
print("Note: Fallback to backup provider occurred")
```
**Provider Features:**
- **Automatic Fallback**: Seamlessly switches providers on failure
- **Priority Management**: Configurable provider order
- **Health Monitoring**: Real-time provider status tracking
- **Error Handling**: Graceful degradation with detailed error reporting
**Supported Providers:**
- **OpenAI**: GPT-4o, GPT-4o-mini, and other models
- **Google Gemini**: Gemini-2.0-flash-exp and variants
- **DeepSeek**: DeepSeek-chat and other models
- **OpenRouter**: Access to multiple models through one API
## 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](https://tauric.ai/).
## 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},
}
```