TradingAgents Deployment and Practice: Building Your AI Quantitative Trading Team

March 21, 2026

WARNING

The TradingAgents framework is for research purposes only. Trading performance is influenced by various factors, including the selected LLM, model temperature, trading cycles, data quality, etc. This framework does not constitute financial, investment, or trading advice.

Have you ever wondered what it would feel like to have an AI team making investment decisions for you?

Today we're talking about TradingAgents, an open-source framework that allows you to build an "AI Quantitative Trading Team." It simulates the workflow of a real financial institution: researchers conduct studies, analysts write reports, risk management teams evaluate risk, and finally, traders place orders.

Sounds cool? Let's dive straight in.

Target Audience

This article is intended for technical individuals with 1-5 years of development experience. You will need:

  • Basic Python knowledge and the ability to understand code
  • Curiosity about AI Agents and multi-agent systems
  • An interest in trying AI-assisted investment decision-making (but don't treat it as real financial advice)

Core Dependencies and Environment

First, let's see what is required to get it running:

  • Python: 3.10 or higher
  • Environment Management: Anaconda or venv recommended
  • LLM Provider: OpenAI (GPT), Google (Gemini), Anthropic (Claude), xAI (Grok), OpenRouter, Ollama (local models)
  • Data Source: Alpha Vantage (stock data, news, indicators)
  • Core Framework: LangGraph (multi-agent orchestration)

TIP

If you just want to see the results first, the CLI mode requires no coding and has a very low entry barrier.

Project Structure

TradingAgents/
β”œβ”€β”€ cli/                           # Command line interface
β”‚   └── main.py                    # Startup entry point
β”œβ”€β”€ tradingagents/
β”‚   β”œβ”€β”€ agents/
β”‚   β”‚   β”œβ”€β”€ analysts/              # Analyst team
β”‚   β”‚   β”‚   β”œβ”€β”€ fundamentals_analyst.py   # Fundamental analysis
β”‚   β”‚   β”‚   β”œβ”€β”€ market_analyst.py         # Market analysis
β”‚   β”‚   β”‚   β”œβ”€β”€ news_analyst.py           # News analysis
β”‚   β”‚   β”‚   └── social_media_analyst.py   # Social media sentiment
β”‚   β”‚   β”œβ”€β”€ researchers/            # Researcher team
β”‚   β”‚   β”‚   β”œβ”€β”€ bull_researcher.py        # Bullish researcher
β”‚   β”‚   β”‚   └── bear_researcher.py        # Bearish researcher
β”‚   β”‚   β”œβ”€β”€ trader/                 # Trader
β”‚   β”‚   β”‚   └── trader.py
β”‚   β”‚   β”œβ”€β”€ risk_mgmt/              # Risk management team
β”‚   β”‚   β”‚   β”œβ”€β”€ aggressive_debator.py
β”‚   β”‚   β”‚   β”œβ”€β”€ conservative_debator.py
β”‚   β”‚   β”‚   └── neutral_debator.py
β”‚   β”‚   └── managers/
β”‚   β”‚       β”œβ”€β”€ research_manager.py
β”‚   β”‚       └── risk_manager.py
β”‚   β”œβ”€β”€ dataflows/                  # Data flows
β”‚   β”‚   β”œβ”€β”€ alpha_vantage_*.py     # Alpha Vantage data
β”‚   β”‚   └── y_finance.py           # Yahoo Finance data
β”‚   β”œβ”€β”€ graph/                      # LangGraph structure
β”‚   β”‚   └── trading_graph.py
β”‚   └── llm_clients/                # LLM clients
β”‚       β”œβ”€β”€ anthropic_client.py
β”‚       β”œβ”€β”€ google_client.py
β”‚       └── factory.py
β”œβ”€β”€ main.py                         # Python entry point
└── test.py                         # Test cases

The structure is clear: the agents directory stores various AI roles, dataflows handles data acquisition, and graph connects these roles into a workflow.


Step-by-Step Deployment

1. Clone Project and Create Environment

# Clone the code
git clone https://github.com/TauricResearch/TradingAgents.git
cd TradingAgents

# Create Python environment (conda recommended)
conda create -n tradingagents python=3.13
conda activate tradingagents

# Install dependencies
pip install -r requirements.txt

TIP

Python 3.13 is the officially recommended version, but 3.10+ should also work. If you encounter compatibility issues, try 3.11.

2. Configure API Keys

TradingAgents supports multiple LLM providers; you need to configure at least one:

# Option 1: Environment Variables
export OPENAI_API_KEY=sk-your-openai-key
export ANTHROPIC_API_KEY=sk-ant-your-anthropic-key
export GOOGLE_API_KEY=your-google-key
export ALPHA_VANTAGE_API_KEY=your-alpha-vantage-key

# Option 2: Copy configuration file
cp .env.example .env
# Then edit the .env file and fill in your keys

TIP

Alpha Vantage is a required API for retrieving stock data. The free version has usage limits but is sufficient for testing.

3. Quick Experience with CLI

Don't want to write code? Run the CLI directly:

python -m cli.main

You will see an interactive interface where you can choose:

  • Stock ticker (e.g., NVDA, AAPL)
  • Analysis date
  • LLM to use (supports GPT, Gemini, Claude, etc.)
  • Research depth
  • Number of debate rounds

Once selected, the framework will launch a series of AI agents collaborating. You will see their real-time analysis reports in the terminal.

CLI Interface

As the analysis progresses, you will see the output of different agents appearing step-by-step:

News Analysis

Finally, the trader will provide a trading recommendation:

Trading Decision

4. Calling via Python Code

Want to integrate it into your own project? It only takes a few lines of code:

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

# Initialize (debug=True to see detailed logs)
ta = TradingAgentsGraph(debug=True, config=DEFAULT_CONFIG.copy())

# Input ticker and date, returns decision
# The first return value is the intermediate process, the second is the final decision
_, decision = ta.propagate("NVDA", "2026-01-15")

print(decision)

Running this script will yield output similar to this:

{
  "ticker": "NVDA",
  "date": "2026-01-15",
  "decision": "BUY",
  "confidence": 0.75,
  "reasoning": "The bull researcher believes...",
  "risk_assessment": "Moderate risk"
}

5. Switching LLM Providers

One of the highlights of TradingAgents is its support for multiple LLMs. You can switch at any time:

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

# Copy default config and modify
config = DEFAULT_CONFIG.copy()
config["llm_provider"] = "anthropic"        # Options: openai, google, anthropic, xai, openrouter, ollama
config["deep_think_llm"] = "claude-sonnet-4.5"   # Strong model for complex reasoning
config["quick_think_llm"] = "claude-haiku-4.5"  # Lightweight model for simple tasks
config["max_debate_rounds"] = 2               # Number of bull-bear debate rounds

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

6. Custom Configuration Items

There are many adjustable parameters in DEFAULT_CONFIG:

config = DEFAULT_CONFIG.copy()

# Core parameters
config["llm_provider"] = "openai"
config["deep_think_llm"] = "gpt-5.2"      # Deep thinking model
config["quick_think_llm"] = "gpt-5-mini"  # Quick response model

# Debate settings
config["max_debate_rounds"] = 3           # Number of bull-bear debate rounds
config["enable_researchers"] = True       # Enable researcher team
config["enable_risk_management"] = True  # Enable risk management team

# Data settings
config["data_provider"] = "alpha_vantage"  # Data provider
config["news_provider"] = "yfinance"      # News source

Defapi Integration: A Low-Cost Solution

Speaking of AI Agents, here is a practical tip:

If you want to run TradingAgents with Claude or GPT but are deterred by official API pricing, you can try Defapiβ€”it supports the v1/chat/completions protocol at half the official price.

The configuration is fully compatible with the official API; you just need to change the base_url to the Defapi address. For a multi-agent system like TradingAgents, where every agent calls the LLM, using Defapi can save significant costs.

The specific configuration method is to change the base_url in the LLM client from the official address to https://api.defapi.org, and use the API Key assigned by Defapi. Currently, Defapi supports mainstream models like Claude, GPT, and Gemini, basically covering all TradingAgents requirements.


Common Troubleshooting

1. API Key not working?

Check if your environment variables are set correctly. Use echo $OPENAI_API_KEY on Linux/Mac, or echo %OPENAI_API_KEY on Windows. If using a .env file, ensure you have run cp .env.example .env and filled in the real keys.

2. Model not supported?

Model names vary across providers. For example, OpenAI uses gpt-5.2, while Anthropic uses claude-sonnet-4.5. If you're unsure about the model name, try the ones listed in the official documentation first.

3. Alpha Vantage call failed?

The free API version has per-minute call limits (usually 5 calls/min). Frequent requests in a short time will return a 429 error. Solution: Upgrade to a paid plan or add delays in the code.

4. Network timeout?

TradingAgents calls multiple LLMs and data APIs; poor network connectivity can easily cause timeouts. You can try:

  • Switching to models accessible from your region
  • Increasing timeout configurations
  • Using local models (Ollama)

5. Outputting a "No Trade" decision?

Sometimes all agents suggest "HOLD," which is normal. The framework's decision synthesizes opinions from the bull, bear, and risk management sides. If the consensus is conservative, it will output HOLD. You can adjust max_debate_rounds to increase debate rounds and potentially make decisions more aggressive (or conservative).

6. How to interpret decision results?

The output is usually in JSON format, containing:

  • decision: BUY / SELL / HOLD
  • confidence: Confidence level 0-1
  • reasoning: Summary of analysis from each agent
  • risk_assessment: Risk level

Remember: This is only AI analysis and suggestion; do not treat it directly as a trading command.


Extended Reading and Advanced Directions

1. Trading-R1

This is a follow-up project from the same team, focusing on optimizing trading strategies using reinforcement learning. The paper has been published on arXiv, and the code will be open-sourced soon; it's worth following.

2. Multi-Agent System Optimization

The architecture of TradingAgents is essentially multi-agent collaboration. You can try:

  • Adding new agent roles (e.g., Macroeconomic Analyst)
  • Adjusting the debate logic between agents
  • Connecting to real trading interfaces (during a paper trading phase)

3. Local Model Solutions

If you don't want to rely on external APIs, you can deploy Ollama local models. While the performance might not match GPT/Claude, the cost is zero, making it suitable for learning and testing.

Updated March 21, 2026