Skip to main content

TradingAgents: Multi-Agents LLM Financial Trading Framework

Project description

TradingAgents

PyPI version python uv Ruff Pydantic v2 tests code-quality Ask DeepWiki license PRs contributors

🚀 TradingAgents is a multi-agent LLM financial trading framework that leverages large language models to simulate analyst teams, research debates, and portfolio management decisions for stock trading analysis.

Other Languages: English | 繁體中文 | 简体中文

✨ Highlights

  • Built on LangGraph and AG2 (AutoGen) for robust multi-agent orchestration
  • Multi-agent architecture: Analyst Team → Research Team → Trader → Risk Management → Portfolio Management
  • Support for multiple LLM providers: OpenAI, Anthropic, Google Gemini, xAI (Grok), OpenRouter, Ollama
  • Market data powered by yfinance for OHLCV, fundamentals, technical indicators, news, and insider transactions
  • Pydantic-based configuration with strict typing and validation
  • Analysis results automatically saved to results/ with organized subfolders
  • Modern src/ layout with full type-annotated code
  • Fast dependency management via uv
  • Pre-commit suite: ruff, mdformat, codespell, mypy, uv hooks
  • Pytest with coverage; MkDocs Material documentation

🚀 Quick Start

git clone https://github.com/Mai0313/TradingAgents.git
cd TradingAgents
make uv-install               # Install uv (only needed once)
uv sync                       # Install dependencies
cp .env.example .env          # Configure your API keys

Configure API Keys

Edit .env and set your LLM provider keys:

# LLM Providers (set the one you use)
OPENAI_API_KEY=sk-...
ANTHROPIC_API_KEY=sk-ant-...
GOOGLE_API_KEY=AIza...
XAI_API_KEY=...
OPENROUTER_API_KEY=...

Usage

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

config = TradingAgentsConfig(
    llm_provider="openai",
    deep_think_llm="gpt-5.2",
    quick_think_llm="gpt-5-mini",
    max_debate_rounds=1,
)

ta = TradingAgentsGraph(debug=True, config=config)
_, decision = ta.propagate("NVDA", "2024-05-10")
print(decision)

📁 Project Structure

src/
└── tradingagents/
    ├── agents/           # Agent implementations
    │   ├── analysts/     # Market, News, Social, Fundamentals analysts
    │   ├── managers/     # Research & Portfolio managers
    │   ├── researchers/  # Bull & Bear researchers
    │   ├── risk_mgmt/    # Risk management agents
    │   ├── trader/       # Trader agent
    │   └── utils/        # Shared agent utilities
    ├── dataflows/        # Data ingestion via yfinance
    ├── graph/            # LangGraph trading graph setup
    ├── llm_clients/      # LLM provider clients (OpenAI, Anthropic, Google, xAI, OpenRouter, Ollama)
    └── default_config.py # Default configuration

🤖 Agent Workflow

  1. Analyst Team — Each selected analyst independently researches market data, news, sentiment, and fundamentals
  2. Research Team — Bull and Bear researchers debate; Research Manager makes a final investment decision
  3. Trader — Formulates a trade plan based on research
  4. Risk Management — Three risk analysts (aggressive, neutral, conservative) debate risk
  5. Portfolio Manager — Makes the final trade decision based on all inputs

Results are saved to results/<TICKER>/<DATE>/ with per-team sub-folders and a consolidated complete_report.md.

🤝 Contributing

For development instructions including documentation, testing, and Docker services, please see CONTRIBUTING.md.

  • Open issues/PRs
  • Follow the coding style (ruff, type hints)
  • Use Conventional Commit messages and descriptive PR titles

📄 License

MIT — see LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tradingagents-0.0.0.tar.gz (339.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tradingagents-0.0.0-py3-none-any.whl (64.7 kB view details)

Uploaded Python 3

File details

Details for the file tradingagents-0.0.0.tar.gz.

File metadata

  • Download URL: tradingagents-0.0.0.tar.gz
  • Upload date:
  • Size: 339.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for tradingagents-0.0.0.tar.gz
Algorithm Hash digest
SHA256 5a5e8468e077ccf407b881f2840727d9785adbbf82fec774a217f310ef35e55a
MD5 7fdede6ebfc6866663d4e22be37ced11
BLAKE2b-256 d2efb7bcf3205bfdb48ceec5b99ce17a8274330087ebd56de4b09b0f0195bcc2

See more details on using hashes here.

File details

Details for the file tradingagents-0.0.0-py3-none-any.whl.

File metadata

  • Download URL: tradingagents-0.0.0-py3-none-any.whl
  • Upload date:
  • Size: 64.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for tradingagents-0.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3bc3575ac862f4d2fe3c9c384b0afd893fc600d428c51070c925987a9432e80f
MD5 368ba24edc0bca903e0a0bf869b0dba2
BLAKE2b-256 740ec984d25d4e0636e2b57094e0715d9fe5f45e9798598cbcaf1b0c184756be

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page