# trafdingjournal/tradingagents architecture

> Architecture diagram of the GitHub repository trafdingjournal/tradingagents, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/trafdingjournal/tradingagents
- Repository: https://github.com/trafdingjournal/tradingagents
- Video tour (about a minute): https://gitdiagram.com/trafdingjournal/tradingagents/video

## Overview

TradingAgents is a research-oriented, multi-agent financial analysis framework: a user submits a ticker, date and optional portfolio context; specialist analysts gather evidence, researchers debate it, and trading and portfolio agents produce a rated decision and report. The graph also preserves backtesting, point-in-time data handling, configurable data vendors, LLM providers and decision memory. Several subsystems are represented at directory level because their implementations are listed in the tree but were not excerpted; relationships are limited to documented workflow or source-index evidence.

Main entry points: [`tradingagents/graph/trading_graph.py`](https://github.com/trafdingjournal/tradingagents/blob/main/tradingagents/graph/trading_graph.py) (Trading graph), [`tradingagents/backtest.py`](https://github.com/trafdingjournal/tradingagents/blob/main/tradingagents/backtest.py) (Backtesting), [`tradingagents/dataflows/date_window.py`](https://github.com/trafdingjournal/tradingagents/blob/main/tradingagents/dataflows/date_window.py) (Date integrity), [`tradingagents/agents/context.py`](https://github.com/trafdingjournal/tradingagents/blob/main/tradingagents/agents/context.py) (Agent context)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["User entry"]
  node_cli["CLI commands<br/>[main.py]"]
  node_cli_runner["CLI run flow<br/>[run.py]"]
end

subgraph group_workflow["Analysis workflow"]
  node_engine["Trading graph<br/>[trading_graph.py]"]
  node_graph_setup["Graph setup<br/>[setup.py]"]
  node_analysts["Analyst team"]
  node_researchers["Bull and bear"]
  node_risk["Risk debate"]
  node_trader["Trade planning<br/>[trader.py]"]
  node_portfolio_manager["Portfolio decision"]
  node_agent_context["Agent context<br/>[context.py]"]
  node_rating["Rating scale<br/>[rating.py]"]
end

subgraph group_data["Market data"]
  node_data_router["Vendor routing<br/>[router.py]"]
  node_vendors["Data vendors"]
  node_point_time["Date integrity<br/>[date_window.py]"]
end

subgraph group_platform["Run platform"]
  node_llm["LLM clients"]
  node_memory["Decision memory"]
  node_reporting["Report output<br/>[reporting.py]"]
  node_backtest["Backtesting<br/>[backtest.py]"]
  node_portfolio_data["Portfolio input<br/>[portfolio.py]"]
end

node_user(("Research user"))
node_llm_provider["LLM provider"]

node_user -->|"starts analysis"| node_cli
node_cli -->|"runs analysis"| node_cli_runner
node_user -->|"requests backtest"| node_backtest
node_engine -->|"builds workflow"| node_graph_setup
node_analysts -->|"reports inform debate"| node_researchers
node_researchers -->|"debate risks"| node_risk
node_risk -->|"informs trade plan"| node_trader
node_trader -->|"supplies plan"| node_portfolio_manager
node_portfolio_manager -->|"uses rating"| node_rating
node_agent_context -->|"checks historical date"| node_point_time
node_agent_context -.->|"loads company profile"| node_data_router
node_data_router -->|"dispatches data calls"| node_vendors
node_engine -->|"enforces run date"| node_point_time
node_engine -->|"settles and stores decisions"| node_memory
node_engine -->|"creates reports"| node_reporting
node_engine -->|"configures model clients"| node_llm
node_llm -.->|"calls provider"| node_llm_provider
node_backtest -->|"runs dated analyses"| node_engine
node_backtest -->|"uses date windows"| node_point_time
node_cli_runner -.->|"loads holdings"| node_portfolio_data

click node_cli "https://github.com/trafdingjournal/tradingagents/blob/main/cli/main.py"
click node_cli_runner "https://github.com/trafdingjournal/tradingagents/blob/main/cli/run.py"
click node_engine "https://github.com/trafdingjournal/tradingagents/blob/main/tradingagents/graph/trading_graph.py"
click node_graph_setup "https://github.com/trafdingjournal/tradingagents/blob/main/tradingagents/graph/setup.py"
click node_analysts "https://github.com/trafdingjournal/tradingagents/tree/main/tradingagents/agents/analysts"
click node_researchers "https://github.com/trafdingjournal/tradingagents/tree/main/tradingagents/agents/researchers"
click node_risk "https://github.com/trafdingjournal/tradingagents/tree/main/tradingagents/agents/risk_mgmt"
click node_trader "https://github.com/trafdingjournal/tradingagents/blob/main/tradingagents/agents/trader/trader.py"
click node_portfolio_manager "https://github.com/trafdingjournal/tradingagents/blob/main/tradingagents/agents/managers/portfolio_manager.py"
click node_agent_context "https://github.com/trafdingjournal/tradingagents/blob/main/tradingagents/agents/context.py"
click node_rating "https://github.com/trafdingjournal/tradingagents/blob/main/tradingagents/agents/rating.py"
click node_data_router "https://github.com/trafdingjournal/tradingagents/blob/main/tradingagents/dataflows/router.py"
click node_vendors "https://github.com/trafdingjournal/tradingagents/tree/main/tradingagents/dataflows/vendors"
click node_point_time "https://github.com/trafdingjournal/tradingagents/blob/main/tradingagents/dataflows/date_window.py"
click node_llm "https://github.com/trafdingjournal/tradingagents/tree/main/tradingagents/llm_clients"
click node_memory "https://github.com/trafdingjournal/tradingagents/tree/main/tradingagents/memory"
click node_reporting "https://github.com/trafdingjournal/tradingagents/blob/main/tradingagents/reporting.py"
click node_backtest "https://github.com/trafdingjournal/tradingagents/blob/main/tradingagents/backtest.py"
click node_portfolio_data "https://github.com/trafdingjournal/tradingagents/blob/main/tradingagents/portfolio.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_cli,node_cli_runner,node_user toneBlue
class node_engine,node_graph_setup,node_analysts,node_researchers,node_risk,node_trader,node_portfolio_manager,node_agent_context,node_rating toneAmber
class node_data_router,node_vendors,node_point_time toneMint
class node_llm,node_memory,node_reporting,node_backtest,node_portfolio_data toneRose
class node_llm_provider toneIndigo
```

## Components

### User entry

- [CLI commands](https://github.com/trafdingjournal/tradingagents/blob/main/cli/main.py): `cli/main.py`
- [CLI run flow](https://github.com/trafdingjournal/tradingagents/blob/main/cli/run.py): `cli/run.py`

### Analysis workflow

- [Trading graph](https://github.com/trafdingjournal/tradingagents/blob/main/tradingagents/graph/trading_graph.py): `tradingagents/graph/trading_graph.py`
- [Graph setup](https://github.com/trafdingjournal/tradingagents/blob/main/tradingagents/graph/setup.py): `tradingagents/graph/setup.py`
- [Analyst team](https://github.com/trafdingjournal/tradingagents/tree/main/tradingagents/agents/analysts): `tradingagents/agents/analysts`
- [Bull and bear](https://github.com/trafdingjournal/tradingagents/tree/main/tradingagents/agents/researchers): `tradingagents/agents/researchers`
- [Risk debate](https://github.com/trafdingjournal/tradingagents/tree/main/tradingagents/agents/risk_mgmt): `tradingagents/agents/risk_mgmt`
- [Trade planning](https://github.com/trafdingjournal/tradingagents/blob/main/tradingagents/agents/trader/trader.py): `tradingagents/agents/trader/trader.py`
- [Portfolio decision](https://github.com/trafdingjournal/tradingagents/blob/main/tradingagents/agents/managers/portfolio_manager.py): `tradingagents/agents/managers/portfolio_manager.py`
- [Agent context](https://github.com/trafdingjournal/tradingagents/blob/main/tradingagents/agents/context.py): `tradingagents/agents/context.py`
- [Rating scale](https://github.com/trafdingjournal/tradingagents/blob/main/tradingagents/agents/rating.py): `tradingagents/agents/rating.py`

### Market data

- [Vendor routing](https://github.com/trafdingjournal/tradingagents/blob/main/tradingagents/dataflows/router.py): `tradingagents/dataflows/router.py`
- [Data vendors](https://github.com/trafdingjournal/tradingagents/tree/main/tradingagents/dataflows/vendors): `tradingagents/dataflows/vendors`
- [Date integrity](https://github.com/trafdingjournal/tradingagents/blob/main/tradingagents/dataflows/date_window.py): `tradingagents/dataflows/date_window.py`

### Run platform

- [LLM clients](https://github.com/trafdingjournal/tradingagents/tree/main/tradingagents/llm_clients): `tradingagents/llm_clients`
- [Decision memory](https://github.com/trafdingjournal/tradingagents/tree/main/tradingagents/memory): `tradingagents/memory`
- [Report output](https://github.com/trafdingjournal/tradingagents/blob/main/tradingagents/reporting.py): `tradingagents/reporting.py`
- [Backtesting](https://github.com/trafdingjournal/tradingagents/blob/main/tradingagents/backtest.py): `tradingagents/backtest.py`
- [Portfolio input](https://github.com/trafdingjournal/tradingagents/blob/main/tradingagents/portfolio.py): `tradingagents/portfolio.py`

### Other components

- **Research user**
- **LLM provider**

## Connections

- Research user → CLI commands: starts analysis (evidence: `README.md`)
- CLI commands → CLI run flow: runs analysis (evidence: `cli/main.py`)
- Research user → Backtesting: requests backtest (evidence: `README.md`)
- Trading graph → Graph setup: builds workflow (evidence: `tradingagents/graph/trading_graph.py`)
- Analyst team → Bull and bear: reports inform debate (evidence: `README.md`)
- Bull and bear → Risk debate: debate risks (evidence: `README.md`)
- Risk debate → Trade planning: informs trade plan (evidence: `README.md`)
- Trade planning → Portfolio decision: supplies plan (evidence: `tradingagents/agents/managers/portfolio_manager.py`)
- Portfolio decision → Rating scale: uses rating (evidence: `tradingagents/agents/managers/portfolio_manager.py`)
- Agent context → Date integrity: checks historical date (evidence: `tradingagents/agents/context.py`)
- Agent context → Vendor routing: loads company profile
- Vendor routing → Data vendors: dispatches data calls (evidence: `tradingagents/dataflows/router.py`)
- Trading graph → Date integrity: enforces run date (evidence: `tradingagents/graph/trading_graph.py`)
- Trading graph → Decision memory: settles and stores decisions (evidence: `tradingagents/graph/trading_graph.py`)
- Trading graph → Report output: creates reports (evidence: `tradingagents/graph/trading_graph.py`)
- Trading graph → LLM clients: configures model clients (evidence: `tradingagents/graph/trading_graph.py`)
- LLM clients → LLM provider: calls provider
- Backtesting → Trading graph: runs dated analyses (evidence: `tradingagents/backtest.py`)
- Backtesting → Date integrity: uses date windows (evidence: `tradingagents/backtest.py`)
- CLI run flow → Portfolio input: loads holdings
