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.1.tar.gz (338.8 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.1-py3-none-any.whl (64.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: tradingagents-0.0.1.tar.gz
  • Upload date:
  • Size: 338.8 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.1.tar.gz
Algorithm Hash digest
SHA256 e9815879872fef868678448675d17577d1098545f46754c86036bb01e552505b
MD5 7a1f8fc957f2b5bd4a2a953f031aa407
BLAKE2b-256 827bea85f8305aa3f9452e165c7df9ef47c61b0c28187b0dc2986451c5d0a41f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: tradingagents-0.0.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7e63f338fd81e96420ac2d44350c9c82b24aae1fa56fe273ee664b98de8e3bfe
MD5 c5d7a4a6d8697ca8e967825ebaa8dbe6
BLAKE2b-256 d8656b8f811ebb6c74ba38c6a05bab066b7a9bc2442793add056c3383fd081ee

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