# jaspalkahlon/tradingagents architecture

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

- Interactive diagram: https://gitdiagram.com/jaspalkahlon/tradingagents
- Repository: https://github.com/jaspalkahlon/tradingagents

## Overview

TradingAgents is a multi-agent financial research and decision framework. A user starts an analysis from the CLI; the run builds and executes a trading graph, which coordinates parallel analysts, research and risk debate, and a portfolio decision. Dataflows route market, company, news, and optional macro or prediction-market requests to vendors; provider clients supply LLMs. The framework also supports backtests, checkpoint resume, decision memory, and reports. Several links reflect README-documented behavior; unsampled implementation details are not inferred as direct calls.

Main entry points: [`tradingagents/graph/trading_graph.py`](https://github.com/jaspalkahlon/tradingagents/blob/main/tradingagents/graph/trading_graph.py) (Trading graph), [`tradingagents/dataflows/router.py`](https://github.com/jaspalkahlon/tradingagents/blob/main/tradingagents/dataflows/router.py) (Data router), [`cli/run.py`](https://github.com/jaspalkahlon/tradingagents/blob/main/cli/run.py) (Run interface), [`tradingagents/agents/analysts`](https://github.com/jaspalkahlon/tradingagents/tree/main/tradingagents/agents/analysts) (Analyst team)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Run interface"]
  node_cli["CLI<br/>[main.py]"]
  node_runner["Run interface<br/>[run.py]"]
end

subgraph group_workflow["Analysis workflow"]
  node_graph["Trading graph<br/>[trading_graph.py]"]
  node_analysts["Analyst team"]
  node_research["Research debate"]
  node_risk["Risk debate"]
  node_trader["Trader<br/>[trader.py]"]
  node_portfolio["Portfolio decision"]
end

subgraph group_data["Data access"]
  node_data_router["Data router<br/>[router.py]"]
  node_market["Market and fundamentals<br/>[market.py]"]
  node_fundamentals["Yahoo fundamentals<br/>[fundamentals.py]"]
  node_other_vendors["Other data vendors"]
end

subgraph group_models["Model access"]
  node_llm_factory["LLM providers"]
  node_config["Run configuration<br/>[default_config.py]"]
end

subgraph group_outcomes["Results and history"]
  node_backtest["Backtesting<br/>[backtest.py]"]
  node_memory[("Decision memory<br/>[log.py]")]
  node_settlement["Outcome settlement<br/>[settlement.py]"]
  node_reporting["Reports<br/>[reporting.py]"]
  node_checkpoints[("Checkpoints<br/>[checkpointer.py]")]
end

node_user(("Analyst user"))

node_user -->|"starts run"| node_cli
node_cli -->|"invokes"| node_runner
node_runner -.->|"runs analysis"| node_graph
node_graph -->|"coordinates"| node_analysts
node_analysts -->|"reports inform"| node_research
node_research -->|"informs decision"| node_trader
node_trader -.->|"enters debate"| node_risk
node_risk -->|"informs decision"| node_portfolio
node_data_router -->|"dispatches calls"| node_market
node_data_router -->|"dispatches calls"| node_fundamentals
node_data_router -->|"dispatches calls"| node_other_vendors
node_analysts -.->|"requests data"| node_data_router
node_graph -->|"uses providers"| node_llm_factory
node_config -.->|"configures models"| node_llm_factory
node_runner -->|"offers backtest"| node_backtest
node_graph -->|"stores decisions"| node_memory
node_graph -->|"settles outcomes"| node_settlement
node_graph -->|"creates reports"| node_reporting
node_graph -->|"resumes runs"| node_checkpoints

click node_cli "https://github.com/jaspalkahlon/tradingagents/blob/main/cli/main.py"
click node_runner "https://github.com/jaspalkahlon/tradingagents/blob/main/cli/run.py"
click node_graph "https://github.com/jaspalkahlon/tradingagents/blob/main/tradingagents/graph/trading_graph.py"
click node_analysts "https://github.com/jaspalkahlon/tradingagents/tree/main/tradingagents/agents/analysts"
click node_research "https://github.com/jaspalkahlon/tradingagents/tree/main/tradingagents/agents/researchers"
click node_risk "https://github.com/jaspalkahlon/tradingagents/tree/main/tradingagents/agents/risk_mgmt"
click node_trader "https://github.com/jaspalkahlon/tradingagents/blob/main/tradingagents/agents/trader/trader.py"
click node_portfolio "https://github.com/jaspalkahlon/tradingagents/blob/main/tradingagents/agents/managers/portfolio_manager.py"
click node_data_router "https://github.com/jaspalkahlon/tradingagents/blob/main/tradingagents/dataflows/router.py"
click node_market "https://github.com/jaspalkahlon/tradingagents/blob/main/tradingagents/dataflows/vendors/yahoo/market.py"
click node_fundamentals "https://github.com/jaspalkahlon/tradingagents/blob/main/tradingagents/dataflows/vendors/yahoo/fundamentals.py"
click node_other_vendors "https://github.com/jaspalkahlon/tradingagents/tree/main/tradingagents/dataflows/vendors"
click node_llm_factory "https://github.com/jaspalkahlon/tradingagents/tree/main/tradingagents/llm_clients"
click node_config "https://github.com/jaspalkahlon/tradingagents/blob/main/tradingagents/default_config.py"
click node_backtest "https://github.com/jaspalkahlon/tradingagents/blob/main/tradingagents/backtest.py"
click node_memory "https://github.com/jaspalkahlon/tradingagents/blob/main/tradingagents/memory/log.py"
click node_settlement "https://github.com/jaspalkahlon/tradingagents/blob/main/tradingagents/memory/settlement.py"
click node_reporting "https://github.com/jaspalkahlon/tradingagents/blob/main/tradingagents/reporting.py"
click node_checkpoints "https://github.com/jaspalkahlon/tradingagents/blob/main/tradingagents/graph/checkpointer.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_runner,node_user toneBlue
class node_graph,node_analysts,node_research,node_risk,node_trader,node_portfolio toneAmber
class node_data_router,node_market,node_fundamentals,node_other_vendors toneMint
class node_llm_factory,node_config toneRose
class node_backtest,node_memory,node_settlement,node_reporting,node_checkpoints toneIndigo
```

## Components

### Run interface

- [CLI](https://github.com/jaspalkahlon/tradingagents/blob/main/cli/main.py): `cli/main.py`
- [Run interface](https://github.com/jaspalkahlon/tradingagents/blob/main/cli/run.py): `cli/run.py`

### Analysis workflow

- [Trading graph](https://github.com/jaspalkahlon/tradingagents/blob/main/tradingagents/graph/trading_graph.py): `tradingagents/graph/trading_graph.py`
- [Analyst team](https://github.com/jaspalkahlon/tradingagents/tree/main/tradingagents/agents/analysts): `tradingagents/agents/analysts`
- [Research debate](https://github.com/jaspalkahlon/tradingagents/tree/main/tradingagents/agents/researchers): `tradingagents/agents/researchers`
- [Risk debate](https://github.com/jaspalkahlon/tradingagents/tree/main/tradingagents/agents/risk_mgmt): `tradingagents/agents/risk_mgmt`
- [Trader](https://github.com/jaspalkahlon/tradingagents/blob/main/tradingagents/agents/trader/trader.py): `tradingagents/agents/trader/trader.py`
- [Portfolio decision](https://github.com/jaspalkahlon/tradingagents/blob/main/tradingagents/agents/managers/portfolio_manager.py): `tradingagents/agents/managers/portfolio_manager.py`

### Data access

- [Data router](https://github.com/jaspalkahlon/tradingagents/blob/main/tradingagents/dataflows/router.py): `tradingagents/dataflows/router.py`
- [Market and fundamentals](https://github.com/jaspalkahlon/tradingagents/blob/main/tradingagents/dataflows/vendors/yahoo/market.py): `tradingagents/dataflows/vendors/yahoo/market.py`
- [Yahoo fundamentals](https://github.com/jaspalkahlon/tradingagents/blob/main/tradingagents/dataflows/vendors/yahoo/fundamentals.py): `tradingagents/dataflows/vendors/yahoo/fundamentals.py`
- [Other data vendors](https://github.com/jaspalkahlon/tradingagents/tree/main/tradingagents/dataflows/vendors): `tradingagents/dataflows/vendors`

### Model access

- [LLM providers](https://github.com/jaspalkahlon/tradingagents/tree/main/tradingagents/llm_clients): `tradingagents/llm_clients`
- [Run configuration](https://github.com/jaspalkahlon/tradingagents/blob/main/tradingagents/default_config.py): `tradingagents/default_config.py`

### Results and history

- [Backtesting](https://github.com/jaspalkahlon/tradingagents/blob/main/tradingagents/backtest.py): `tradingagents/backtest.py`
- [Decision memory](https://github.com/jaspalkahlon/tradingagents/blob/main/tradingagents/memory/log.py): `tradingagents/memory/log.py`
- [Outcome settlement](https://github.com/jaspalkahlon/tradingagents/blob/main/tradingagents/memory/settlement.py): `tradingagents/memory/settlement.py`
- [Reports](https://github.com/jaspalkahlon/tradingagents/blob/main/tradingagents/reporting.py): `tradingagents/reporting.py`
- [Checkpoints](https://github.com/jaspalkahlon/tradingagents/blob/main/tradingagents/graph/checkpointer.py): `tradingagents/graph/checkpointer.py`

### Other components

- **Analyst user**

## Connections

- Analyst user → CLI: starts run (evidence: `cli/main.py`)
- CLI → Run interface: invokes (evidence: `cli/main.py`)
- Run interface → Trading graph: runs analysis
- Trading graph → Analyst team: coordinates
- Analyst team → Research debate: reports inform
- Research debate → Trader: informs decision
- Trader → Risk debate: enters debate
- Risk debate → Portfolio decision: informs decision (evidence: `tradingagents/agents/managers/portfolio_manager.py`)
- Data router → Market and fundamentals: dispatches calls (evidence: `tradingagents/dataflows/router.py`)
- Data router → Yahoo fundamentals: dispatches calls (evidence: `tradingagents/dataflows/router.py`)
- Data router → Other data vendors: dispatches calls (evidence: `tradingagents/dataflows/router.py`)
- Analyst team → Data router: requests data
- Trading graph → LLM providers: uses providers (evidence: `tradingagents/graph/trading_graph.py`)
- Run configuration → LLM providers: configures models (evidence: `tradingagents/llm_clients/chatgpt_auth.py`)
- Run interface → Backtesting: offers backtest (evidence: `cli/main.py`)
- Trading graph → Decision memory: stores decisions (evidence: `tradingagents/graph/trading_graph.py`)
- Trading graph → Outcome settlement: settles outcomes (evidence: `tradingagents/graph/trading_graph.py`)
- Trading graph → Reports: creates reports (evidence: `tradingagents/graph/trading_graph.py`)
- Trading graph → Checkpoints: resumes runs (evidence: `tradingagents/graph/trading_graph.py`)
