# voyzer10/claude-trading-bot architecture

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

- Interactive diagram: https://gitdiagram.com/voyzer10/claude-trading-bot
- Repository: https://github.com/voyzer10/claude-trading-bot

## Overview

This is a paper-trading bot with a Next.js dashboard and FastAPI APIs. The main workflow is dashboard controls and monitoring → the persistent runner scans enabled markets → strategies produce decisions → paper.py simulates trades and records state → the dashboard presents positions, performance, alerts, and operations. Research/backtests form a separate evaluation path. V6 adds a distinct paper-trading pipeline and read-only API. Several runner and API implementation details are unsampled, so links rely on README statements where noted; the V6 links use the supplied source index and excerpts.

Main entry points: [`live.py`](https://github.com/voyzer10/claude-trading-bot/blob/main/live.py) (Market runner), [`api/index.py`](https://github.com/voyzer10/claude-trading-bot/blob/main/api/index.py) (Dashboard API), [`components/Dashboard.tsx`](https://github.com/voyzer10/claude-trading-bot/blob/main/components/Dashboard.tsx) (Dashboard), [`v6_runtime/portfolio.py`](https://github.com/voyzer10/claude-trading-bot/blob/main/v6_runtime/portfolio.py) (Book portfolio)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_dashboard["Dashboard"]
  node_web["Dashboard<br/>[Dashboard.tsx]"]
  node_settings["Settings and controls<br/>[Settings.tsx]"]
  node_dashboard_api["Dashboard API<br/>[index.py]"]
  node_ops_api["Operations API<br/>[_ops.py]"]
  node_charts["Charts and opinion<br/>[_chart.py]"]
end

subgraph group_runner["Trading runner"]
  node_live["Market runner<br/>[live.py]"]
  node_market_scans["Market scanners<br/>[scan_nse.py]"]
  node_agents["Market agents<br/>[auto_crypto.py]"]
  node_us_agents["US agent tools<br/>[scan.py]"]
  node_paper["Paper trading<br/>[paper.py]"]
  node_alerts["Trade alerts<br/>[alerts.py]"]
end

subgraph group_v6["V6 paper system"]
  node_v6_api["V6 read API<br/>[app.py]"]
  node_v6_views["V6 views<br/>[views.py]"]
  node_candles["Validated market data<br/>[candle_models.py]"]
  node_structure["Structure and liquidity<br/>[choch.py]"]
  node_confirmation["Setup confirmation<br/>[confirmation.py]"]
  node_execution["Paper execution<br/>[execution.py]"]
  node_portfolio["Book portfolio<br/>[portfolio.py]"]
  node_ledger[("V6 ledger<br/>[ledger.py]")]
end

subgraph group_evaluation["Research and backtests"]
  node_backtest["V6 backtest engine<br/>[engine.py]"]
  node_research["Research backtests<br/>[research.py]"]
end

node_user(("Trader"))
node_data_provider["Market data providers"]

node_user -->|"uses"| node_web
node_web -->|"renders"| node_settings
node_web -.->|"requests data"| node_dashboard_api
node_settings -.->|"sends controls"| node_dashboard_api
node_dashboard_api -->|"routes operations"| node_ops_api
node_dashboard_api -->|"routes charts"| node_charts
node_ops_api -->|"controls runner"| node_live
node_live -->|"scans markets"| node_market_scans
node_live -->|"runs agents"| node_agents
node_live -->|"simulates trades"| node_paper
node_live -.->|"runs US tools"| node_us_agents
node_paper -.->|"emits trade alerts"| node_alerts
node_data_provider -.->|"supplies prices"| node_market_scans
node_user -->|"queries"| node_v6_api
node_v6_api -->|"dispatches reads"| node_v6_views
node_v6_views -->|"reads ledger"| node_ledger
node_candles -.->|"provides candles"| node_structure
node_structure -.->|"provides setup events"| node_confirmation
node_confirmation -->|"provides confirmed setups"| node_execution
node_portfolio -.->|"runs instrument streams"| node_execution
node_portfolio -.->|"records book state"| node_ledger
node_data_provider -.->|"supplies datasets"| node_backtest
node_backtest -.->|"simulates portfolio"| node_portfolio
node_user -->|"evaluates strategies"| node_research
node_user -->|"runs V6 backtests"| node_backtest

click node_web "https://github.com/voyzer10/claude-trading-bot/blob/main/components/Dashboard.tsx"
click node_settings "https://github.com/voyzer10/claude-trading-bot/blob/main/components/Settings.tsx"
click node_dashboard_api "https://github.com/voyzer10/claude-trading-bot/blob/main/api/index.py"
click node_ops_api "https://github.com/voyzer10/claude-trading-bot/blob/main/api/_ops.py"
click node_charts "https://github.com/voyzer10/claude-trading-bot/blob/main/api/_chart.py"
click node_live "https://github.com/voyzer10/claude-trading-bot/blob/main/live.py"
click node_market_scans "https://github.com/voyzer10/claude-trading-bot/blob/main/scan_nse.py"
click node_agents "https://github.com/voyzer10/claude-trading-bot/blob/main/auto_crypto.py"
click node_us_agents "https://github.com/voyzer10/claude-trading-bot/blob/main/us/trader-scanner/scan.py"
click node_paper "https://github.com/voyzer10/claude-trading-bot/blob/main/paper.py"
click node_alerts "https://github.com/voyzer10/claude-trading-bot/blob/main/alerts.py"
click node_v6_api "https://github.com/voyzer10/claude-trading-bot/blob/main/api_v6/app.py"
click node_v6_views "https://github.com/voyzer10/claude-trading-bot/blob/main/api_v6/views.py"
click node_candles "https://github.com/voyzer10/claude-trading-bot/blob/main/scanner_v6/data/candle_models.py"
click node_structure "https://github.com/voyzer10/claude-trading-bot/blob/main/scanner_v6/structure/choch.py"
click node_confirmation "https://github.com/voyzer10/claude-trading-bot/blob/main/scanner_v6/entry/confirmation.py"
click node_execution "https://github.com/voyzer10/claude-trading-bot/blob/main/scanner_v6/exit/execution.py"
click node_portfolio "https://github.com/voyzer10/claude-trading-bot/blob/main/v6_runtime/portfolio.py"
click node_ledger "https://github.com/voyzer10/claude-trading-bot/blob/main/v6_runtime/ledger.py"
click node_backtest "https://github.com/voyzer10/claude-trading-bot/blob/main/v6_runtime/backtest/engine.py"
click node_research "https://github.com/voyzer10/claude-trading-bot/blob/main/research.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_web,node_settings,node_dashboard_api,node_ops_api,node_charts toneBlue
class node_live,node_market_scans,node_agents,node_us_agents,node_paper,node_alerts toneAmber
class node_v6_api,node_v6_views,node_candles,node_structure,node_confirmation,node_execution,node_portfolio,node_ledger toneMint
class node_backtest,node_research toneRose
class node_user,node_data_provider toneIndigo
```

## Components

### Dashboard

- [Dashboard](https://github.com/voyzer10/claude-trading-bot/blob/main/components/Dashboard.tsx): `components/Dashboard.tsx`
- [Settings and controls](https://github.com/voyzer10/claude-trading-bot/blob/main/components/Settings.tsx): `components/Settings.tsx`
- [Dashboard API](https://github.com/voyzer10/claude-trading-bot/blob/main/api/index.py): `api/index.py`
- [Operations API](https://github.com/voyzer10/claude-trading-bot/blob/main/api/_ops.py): `api/_ops.py`
- [Charts and opinion](https://github.com/voyzer10/claude-trading-bot/blob/main/api/_chart.py): `api/_chart.py`

### Trading runner

- [Market runner](https://github.com/voyzer10/claude-trading-bot/blob/main/live.py): `live.py`
- [Market scanners](https://github.com/voyzer10/claude-trading-bot/blob/main/scan_nse.py): `scan_nse.py`
- [Market agents](https://github.com/voyzer10/claude-trading-bot/blob/main/auto_crypto.py): `auto_crypto.py`
- [US agent tools](https://github.com/voyzer10/claude-trading-bot/blob/main/us/trader-scanner/scan.py): `us/trader-scanner/scan.py`
- [Paper trading](https://github.com/voyzer10/claude-trading-bot/blob/main/paper.py): `paper.py`
- [Trade alerts](https://github.com/voyzer10/claude-trading-bot/blob/main/alerts.py): `alerts.py`

### V6 paper system

- [V6 read API](https://github.com/voyzer10/claude-trading-bot/blob/main/api_v6/app.py): `api_v6/app.py`
- [V6 views](https://github.com/voyzer10/claude-trading-bot/blob/main/api_v6/views.py): `api_v6/views.py`
- [Validated market data](https://github.com/voyzer10/claude-trading-bot/blob/main/scanner_v6/data/candle_models.py): `scanner_v6/data/candle_models.py`
- [Structure and liquidity](https://github.com/voyzer10/claude-trading-bot/blob/main/scanner_v6/structure/choch.py): `scanner_v6/structure/choch.py`
- [Setup confirmation](https://github.com/voyzer10/claude-trading-bot/blob/main/scanner_v6/entry/confirmation.py): `scanner_v6/entry/confirmation.py`
- [Paper execution](https://github.com/voyzer10/claude-trading-bot/blob/main/scanner_v6/exit/execution.py): `scanner_v6/exit/execution.py`
- [Book portfolio](https://github.com/voyzer10/claude-trading-bot/blob/main/v6_runtime/portfolio.py): `v6_runtime/portfolio.py`
- [V6 ledger](https://github.com/voyzer10/claude-trading-bot/blob/main/v6_runtime/ledger.py): `v6_runtime/ledger.py`

### Research and backtests

- [V6 backtest engine](https://github.com/voyzer10/claude-trading-bot/blob/main/v6_runtime/backtest/engine.py): `v6_runtime/backtest/engine.py`
- [Research backtests](https://github.com/voyzer10/claude-trading-bot/blob/main/research.py): `research.py`

### Other components

- **Trader**
- **Market data providers**

## Connections

- Trader → Dashboard: uses (evidence: `README.md`)
- Dashboard → Settings and controls: renders (evidence: `components/Dashboard.tsx`)
- Dashboard → Dashboard API: requests data
- Settings and controls → Dashboard API: sends controls
- Dashboard API → Operations API: routes operations (evidence: `api/index.py`)
- Dashboard API → Charts and opinion: routes charts (evidence: `api/index.py`)
- Operations API → Market runner: controls runner (evidence: `README.md`)
- Market runner → Market scanners: scans markets (evidence: `README.md`)
- Market runner → Market agents: runs agents (evidence: `README.md`)
- Market runner → Paper trading: simulates trades (evidence: `README.md`)
- Market runner → US agent tools: runs US tools
- Paper trading → Trade alerts: emits trade alerts
- Market data providers → Market scanners: supplies prices
- Trader → V6 read API: queries (evidence: `api_v6/app.py`)
- V6 read API → V6 views: dispatches reads (evidence: `api_v6/app.py`)
- V6 views → V6 ledger: reads ledger (evidence: `api_v6/views.py`)
- Validated market data → Structure and liquidity: provides candles (evidence: `scanner_v6/structure/choch.py`)
- Structure and liquidity → Setup confirmation: provides setup events (evidence: `scanner_v6/entry/confirmation.py`)
- Setup confirmation → Paper execution: provides confirmed setups (evidence: `scanner_v6/exit/execution.py`)
- Book portfolio → Paper execution: runs instrument streams (evidence: `v6_runtime/portfolio.py`)
- Book portfolio → V6 ledger: records book state (evidence: `v6_runtime/portfolio.py`)
- Market data providers → V6 backtest engine: supplies datasets
- V6 backtest engine → Book portfolio: simulates portfolio (evidence: `v6_runtime/backtest/engine.py`)
- Trader → Research backtests: evaluates strategies (evidence: `README.md`)
- Trader → V6 backtest engine: runs V6 backtests
