Skip to main content

Quick Start

This guide will get you up and running with TradingAgents in under 5 minutes. We'll walk through a basic example of using the framework to analyze a stock and make a trading decision.

Prerequisites

Before starting, ensure you have:

  • ✅ Completed the Installation
  • ✅ Set up your API keys (FinnHub and OpenAI)
  • ✅ Activated your virtual environment

Basic Usage Example

Here's a simple example to get you started with TradingAgents:

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

# Initialize TradingAgents with default configuration
ta = TradingAgentsGraph(debug=True, config=DEFAULT_CONFIG.copy())

# Analyze NVIDIA stock for a specific date
symbol = "NVDA"
date = "2024-05-10"

# Run the multi-agent analysis
state, decision = ta.propagate(symbol, date)

# Print the trading decision
print(f"Trading Decision for {symbol} on {date}:")
print(decision)

Understanding the Output

The propagate() method returns two values:

  1. State: Contains all intermediate analysis from different agents
  2. Decision: The final trading recommendation

A typical decision output includes:

  • Action: BUY, SELL, or HOLD
  • Confidence: Decision confidence score
  • Reasoning: Summary of analysis
  • Risk Assessment: Identified risks and mitigation strategies

Customizing the Configuration

You can customize the framework behavior by modifying the configuration:

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

# Create custom configuration
custom_config = DEFAULT_CONFIG.copy()

# Use different LLM models (cost-effective for testing)
custom_config["deep_think_llm"] = "gpt-4o-mini"
custom_config["quick_think_llm"] = "gpt-4o-mini"

# Adjust debate rounds (fewer rounds = faster execution)
custom_config["max_debate_rounds"] = 1

# Enable/disable online data tools
custom_config["online_tools"] = True

# Initialize with custom config
ta = TradingAgentsGraph(debug=True, config=custom_config)

# Run analysis
_, decision = ta.propagate("AAPL", "2024-05-10")
print(decision)

Configuration Options

Key configuration parameters you can adjust:

ParameterDescriptionDefaultOptions
deep_think_llmModel for complex analysiso1-previewo1-preview, gpt-4o, gpt-4o-mini
quick_think_llmModel for quick responsesgpt-4ogpt-4o, gpt-4o-mini
max_debate_roundsNumber of researcher debates31-5
online_toolsUse real-time vs cached dataFalseTrue, False

Data Sources

When online_tools = True, agents access:

  • Real-time market data via FinnHub API
  • Current news and sentiment data
  • Live technical indicators

Cached Data (Default)

When online_tools = False, agents use:

  • Curated historical data from Tauric TradingDB
  • Pre-processed technical indicators
  • Historical news and sentiment data

Common Use Cases

1. Single Stock Analysis

# Analyze a specific stock on a specific date
_, decision = ta.propagate("TSLA", "2024-03-15")

2. Multiple Stock Comparison

stocks = ["AAPL", "GOOGL", "MSFT", "NVDA"]
date = "2024-05-10"

results = {}
for stock in stocks:
_, decision = ta.propagate(stock, date)
results[stock] = decision

# Compare decisions
for stock, decision in results.items():
print(f"{stock}: {decision['action']} (Confidence: {decision['confidence']})")

3. Time Series Analysis

import datetime

symbol = "AAPL"
dates = ["2024-05-01", "2024-05-02", "2024-05-03"]

for date in dates:
_, decision = ta.propagate(symbol, date)
print(f"{date}: {decision['action']}")

Performance Tips

For Testing and Development

  • Use gpt-4o-mini models to reduce API costs
  • Set max_debate_rounds = 1 for faster execution
  • Enable debug=True to see detailed logs

For Production Analysis

  • Use o1-preview for deep analysis tasks
  • Increase max_debate_rounds for more thorough debates
  • Enable online_tools for real-time data

Next Steps

Now that you're up and running:

  1. Explore Agent Details: Learn about individual agents
  2. Try the CLI: Use the command-line interface
  3. View Examples: Check out advanced examples
  4. Understand Configuration: Read the API documentation

Troubleshooting

If you encounter issues: