# tiangehuang/tradingagents architecture

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

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

## Overview

TradingAgents is a multi-agent financial research and decision-support framework, exposed through a CLI or Python API. A user supplies an asset and date; the graph gathers market, fundamental, news, and sentiment evidence, coordinates analyst reports and bull/bear research, then produces a trader proposal and portfolio decision. Provider clients and dataflows connect the analysis to configurable LLMs and financial data sources. The README documents simulated order execution, while sampled code shows decision synthesis rather than an execution adapter. Graph wiring beyond the sampled entry points is represented only where documented.

Main entry points: [`tradingagents/graph/trading_graph.py`](https://github.com/tiangehuang/tradingagents/blob/main/tradingagents/graph/trading_graph.py) (Trading graph), [`cli/main.py`](https://github.com/tiangehuang/tradingagents/blob/main/cli/main.py) (Interactive CLI), [`tradingagents/agents/analysts`](https://github.com/tiangehuang/tradingagents/tree/main/tradingagents/agents/analysts) (Analyst team), [`tradingagents/graph/analyst_execution.py`](https://github.com/tiangehuang/tradingagents/blob/main/tradingagents/graph/analyst_execution.py) (Analyst execution)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["User entry"]
  node_cli["Interactive CLI<br/>[main.py]"]
  node_python_api["Python entry<br/>[trading_graph.py]"]
  node_reporting["Decision reports<br/>[reporting.py]"]
end

subgraph group_orchestration["Analysis orchestration"]
  node_graph["Trading graph<br/>[trading_graph.py]"]
  node_graph_setup["Graph setup<br/>[setup.py]"]
  node_analyst_team["Analyst team"]
  node_analyst_flow["Analyst execution"]
end

subgraph group_research["Research and decisions"]
  node_research_debate["Bull-bear debate"]
  node_research_manager["Research manager"]
  node_trader["Trader proposal<br/>[trader.py]"]
  node_risk_debate["Risk debate"]
  node_portfolio_manager["Portfolio decision"]
end

subgraph group_data["Data access"]
  node_data_tools["Agent data tools"]
  node_dataflows["Provider dataflows"]
end

subgraph group_integrations["Model and state"]
  node_llm_factory["LLM factory<br/>[factory.py]"]
  node_llm_clients["Provider clients"]
  node_checkpoint[("Graph checkpoint<br/>[checkpointer.py]")]
  node_memory[("Decision memory<br/>[memory.py]")]
  node_reflection["Decision reflection<br/>[reflection.py]"]
end

node_user(("Research user"))
node_market_services["Market data services"]
node_llm_providers["LLM providers"]

node_user -->|"configures run"| node_cli
node_user -->|"submits analysis"| node_python_api
node_cli -->|"runs analysis"| node_graph
node_python_api -->|"propagates input"| node_graph
node_graph -->|"builds workflow"| node_graph_setup
node_graph -->|"dispatches stages"| node_analyst_flow
node_analyst_flow -->|"runs analysts"| node_analyst_team
node_analyst_team -->|"requests evidence"| node_data_tools
node_data_tools -->|"fetches data"| node_dataflows
node_dataflows -.->|"queries providers"| node_market_services
node_analyst_team -->|"provides reports"| node_research_debate
node_research_debate -->|"debate history"| node_research_manager
node_research_manager -->|"investment plan"| node_trader
node_trader -->|"trade proposal"| node_risk_debate
node_risk_debate -->|"risk assessment"| node_portfolio_manager
node_graph -->|"selects model"| node_llm_factory
node_llm_factory -->|"creates client"| node_llm_clients
node_llm_clients -.->|"invokes model"| node_llm_providers
node_graph -->|"saves workflow state"| node_checkpoint
node_graph -->|"uses prior context"| node_memory
node_reflection -->|"records lessons"| node_memory
node_cli -->|"renders decision"| node_reporting
node_portfolio_manager -->|"supplies decision"| node_reporting

click node_cli "https://github.com/tiangehuang/tradingagents/blob/main/cli/main.py"
click node_python_api "https://github.com/tiangehuang/tradingagents/blob/main/tradingagents/graph/trading_graph.py"
click node_graph "https://github.com/tiangehuang/tradingagents/blob/main/tradingagents/graph/trading_graph.py"
click node_graph_setup "https://github.com/tiangehuang/tradingagents/blob/main/tradingagents/graph/setup.py"
click node_analyst_team "https://github.com/tiangehuang/tradingagents/tree/main/tradingagents/agents/analysts"
click node_analyst_flow "https://github.com/tiangehuang/tradingagents/blob/main/tradingagents/graph/analyst_execution.py"
click node_research_debate "https://github.com/tiangehuang/tradingagents/tree/main/tradingagents/agents/researchers"
click node_research_manager "https://github.com/tiangehuang/tradingagents/blob/main/tradingagents/agents/managers/research_manager.py"
click node_trader "https://github.com/tiangehuang/tradingagents/blob/main/tradingagents/agents/trader/trader.py"
click node_risk_debate "https://github.com/tiangehuang/tradingagents/tree/main/tradingagents/agents/risk_mgmt"
click node_portfolio_manager "https://github.com/tiangehuang/tradingagents/blob/main/tradingagents/agents/managers/portfolio_manager.py"
click node_reporting "https://github.com/tiangehuang/tradingagents/blob/main/tradingagents/reporting.py"
click node_data_tools "https://github.com/tiangehuang/tradingagents/tree/main/tradingagents/agents/utils"
click node_dataflows "https://github.com/tiangehuang/tradingagents/tree/main/tradingagents/dataflows"
click node_llm_factory "https://github.com/tiangehuang/tradingagents/blob/main/tradingagents/llm_clients/factory.py"
click node_llm_clients "https://github.com/tiangehuang/tradingagents/tree/main/tradingagents/llm_clients"
click node_checkpoint "https://github.com/tiangehuang/tradingagents/blob/main/tradingagents/graph/checkpointer.py"
click node_memory "https://github.com/tiangehuang/tradingagents/blob/main/tradingagents/agents/utils/memory.py"
click node_reflection "https://github.com/tiangehuang/tradingagents/blob/main/tradingagents/graph/reflection.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_python_api,node_reporting,node_user toneBlue
class node_graph,node_graph_setup,node_analyst_team,node_analyst_flow toneAmber
class node_research_debate,node_research_manager,node_trader,node_risk_debate,node_portfolio_manager toneMint
class node_data_tools,node_dataflows toneRose
class node_llm_factory,node_llm_clients,node_checkpoint,node_memory,node_reflection,node_market_services,node_llm_providers toneIndigo
```

## Components

### User entry

- [Interactive CLI](https://github.com/tiangehuang/tradingagents/blob/main/cli/main.py): `cli/main.py`
- [Python entry](https://github.com/tiangehuang/tradingagents/blob/main/tradingagents/graph/trading_graph.py): `tradingagents/graph/trading_graph.py`
- [Decision reports](https://github.com/tiangehuang/tradingagents/blob/main/tradingagents/reporting.py): `tradingagents/reporting.py`

### Analysis orchestration

- [Trading graph](https://github.com/tiangehuang/tradingagents/blob/main/tradingagents/graph/trading_graph.py): `tradingagents/graph/trading_graph.py`
- [Graph setup](https://github.com/tiangehuang/tradingagents/blob/main/tradingagents/graph/setup.py): `tradingagents/graph/setup.py`
- [Analyst team](https://github.com/tiangehuang/tradingagents/tree/main/tradingagents/agents/analysts): `tradingagents/agents/analysts`
- [Analyst execution](https://github.com/tiangehuang/tradingagents/blob/main/tradingagents/graph/analyst_execution.py): `tradingagents/graph/analyst_execution.py`

### Research and decisions

- [Bull-bear debate](https://github.com/tiangehuang/tradingagents/tree/main/tradingagents/agents/researchers): `tradingagents/agents/researchers`
- [Research manager](https://github.com/tiangehuang/tradingagents/blob/main/tradingagents/agents/managers/research_manager.py): `tradingagents/agents/managers/research_manager.py`
- [Trader proposal](https://github.com/tiangehuang/tradingagents/blob/main/tradingagents/agents/trader/trader.py): `tradingagents/agents/trader/trader.py`
- [Risk debate](https://github.com/tiangehuang/tradingagents/tree/main/tradingagents/agents/risk_mgmt): `tradingagents/agents/risk_mgmt`
- [Portfolio decision](https://github.com/tiangehuang/tradingagents/blob/main/tradingagents/agents/managers/portfolio_manager.py): `tradingagents/agents/managers/portfolio_manager.py`

### Data access

- [Agent data tools](https://github.com/tiangehuang/tradingagents/tree/main/tradingagents/agents/utils): `tradingagents/agents/utils`
- [Provider dataflows](https://github.com/tiangehuang/tradingagents/tree/main/tradingagents/dataflows): `tradingagents/dataflows`

### Model and state

- [LLM factory](https://github.com/tiangehuang/tradingagents/blob/main/tradingagents/llm_clients/factory.py): `tradingagents/llm_clients/factory.py`
- [Provider clients](https://github.com/tiangehuang/tradingagents/tree/main/tradingagents/llm_clients): `tradingagents/llm_clients`
- [Graph checkpoint](https://github.com/tiangehuang/tradingagents/blob/main/tradingagents/graph/checkpointer.py): `tradingagents/graph/checkpointer.py`
- [Decision memory](https://github.com/tiangehuang/tradingagents/blob/main/tradingagents/agents/utils/memory.py): `tradingagents/agents/utils/memory.py`
- [Decision reflection](https://github.com/tiangehuang/tradingagents/blob/main/tradingagents/graph/reflection.py): `tradingagents/graph/reflection.py`

### Other components

- **Research user**
- **Market data services**
- **LLM providers**

## Connections

- Research user → Interactive CLI: configures run
- Research user → Python entry: submits analysis
- Interactive CLI → Trading graph: runs analysis
- Python entry → Trading graph: propagates input
- Trading graph → Graph setup: builds workflow
- Trading graph → Analyst execution: dispatches stages
- Analyst execution → Analyst team: runs analysts
- Analyst team → Agent data tools: requests evidence
- Agent data tools → Provider dataflows: fetches data
- Provider dataflows → Market data services: queries providers
- Analyst team → Bull-bear debate: provides reports
- Bull-bear debate → Research manager: debate history
- Research manager → Trader proposal: investment plan
- Trader proposal → Risk debate: trade proposal
- Risk debate → Portfolio decision: risk assessment
- Trading graph → LLM factory: selects model
- LLM factory → Provider clients: creates client
- Provider clients → LLM providers: invokes model
- Trading graph → Graph checkpoint: saves workflow state
- Trading graph → Decision memory: uses prior context
- Decision reflection → Decision memory: records lessons
- Interactive CLI → Decision reports: renders decision
- Portfolio decision → Decision reports: supplies decision
