# ksksrbiz-arch/day-trade architecture

> Architecture diagram of the GitHub repository ksksrbiz-arch/day-trade, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-04). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ksksrbiz-arch/day-trade
- Repository: https://github.com/ksksrbiz-arch/day-trade

## Overview

paper-trader is a paper-only trading and measurement system, with a broader autonomous research/control center. Its documented core workflow turns RSS news into structured labels, applies a deterministic strategy, submits paper orders, and measures performance against a benchmark; archived labels also support deterministic replay. The repository additionally contains optional RL, prediction, agent, and visualization subsystems. Relationships are limited to README statements and shown source references; unsampled modules are represented by their exact paths without inferred call chains.

Main entry points: [`trader/agents/runtime.py`](https://github.com/ksksrbiz-arch/day-trade/blob/main/trader/agents/runtime.py) (Agent runtime), [`trader/agents/tools.py`](https://github.com/ksksrbiz-arch/day-trade/blob/main/trader/agents/tools.py) (Agent tools), [`trader/predict/engine.py`](https://github.com/ksksrbiz-arch/day-trade/blob/main/trader/predict/engine.py) (Prediction engine), [`trader/labels.py`](https://github.com/ksksrbiz-arch/day-trade/blob/main/trader/labels.py) (Label model)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_trading["Signals and execution"]
  node_news["News ingestion<br/>[news.py]"]
  node_labeler["News labeler<br/>[labeler.py]"]
  node_labels["Label model<br/>[labels.py]"]
  node_strategy["Deterministic strategy<br/>[strategy.py]"]
  node_broker["Paper broker<br/>[broker.py]"]
  node_config["Trading configuration<br/>[config.py]"]
  node_rl["RL trader<br/>[trader.py]"]
end

subgraph group_measurement["Replay and measurement"]
  node_backtest["Replay harness<br/>[backtest.py]"]
  node_sim_broker["Slippage simulator<br/>[simbroker.py]"]
  node_metrics["Performance metrics<br/>[metrics.py]"]
  node_walkforward["Walk-forward analysis<br/>[walkforward.py]"]
  node_crsp[("Point-in-time data<br/>[query.py]")]
end

subgraph group_autonomy["Research and autonomy"]
  node_alpha["Signal confluence<br/>[alpha.py]"]
  node_market_brain["Market brain<br/>[market_brain.py]"]
  node_agents_runtime["Agent runtime<br/>[runtime.py]"]
  node_orchestrator["Agent orchestrator<br/>[orchestrator.py]"]
  node_governor["Action governor<br/>[governor.py]"]
  node_agent_memory[("Agent memory<br/>[memory.py]")]
  node_agent_state[("Agent state<br/>[state.py]")]
  node_agent_tools["Agent tools<br/>[tools.py]"]
  node_cloudflare_ai["Cloudflare AI client<br/>[cloudflare.py]"]
  node_mesh[("Insight mesh<br/>[mesh.py]")]
  node_predict_engine["Prediction engine<br/>[engine.py]"]
  node_predict_store[("Prediction store<br/>[store.py]")]
  node_ml_infer["ML inference<br/>[infer.py]"]
end

subgraph group_interfaces["Control and visualization"]
  node_dashboard["Dashboard API<br/>[app.py]"]
  node_dashboard_bots["Bot controls<br/>[bots.py]"]
  node_brain_page["Brain page<br/>[page.tsx]"]
  node_brain_scene["3D brain scene<br/>[BrainScene.tsx]"]
  node_live_hook["Live data hook<br/>[useLive.ts]"]
end

node_operator(("Operator"))
node_rss["RSS feeds"]
node_claude{{"Anthropic Claude"}}
node_alpaca{{"Alpaca paper"}}

node_rss -->|"provides items"| node_news
node_news -->|"feeds news"| node_labeler
node_claude -->|"extracts features"| node_labeler
node_labeler -->|"emits labels"| node_labels
node_labels -->|"drives decisions"| node_strategy
node_strategy -->|"submits trades"| node_broker
node_broker -->|"places paper orders"| node_alpaca
node_labels -->|"replays history"| node_backtest
node_backtest -->|"simulates fills"| node_sim_broker
node_backtest -->|"scores results"| node_metrics
node_walkforward -->|"queries history"| node_crsp
node_operator -->|"uses"| node_dashboard
node_dashboard -->|"imports controls"| node_dashboard_bots
node_operator -->|"opens"| node_brain_page
node_brain_page -.->|"renders scene"| node_brain_scene
node_brain_scene -->|"uses live hook"| node_live_hook
node_live_hook -->|"updates scene"| node_brain_scene
node_live_hook -.->|"reads topology"| node_mesh
node_agents_runtime -->|"publishes insights"| node_mesh
node_agents_runtime -->|"runs cycle"| node_predict_engine
node_predict_engine -->|"records predictions"| node_predict_store
node_predict_engine -->|"loads prices"| node_crsp
node_orchestrator -->|"recalls context"| node_agent_memory
node_orchestrator -->|"selects tools"| node_agent_tools
node_agent_tools -->|"governs actions"| node_governor
node_governor -->|"records actions"| node_agent_memory
node_agent_tools -->|"scores headlines"| node_cloudflare_ai
node_agents_runtime -->|"checkpoints state"| node_agent_state
node_agents_runtime -->|"snapshots mesh"| node_mesh
node_agent_tools -->|"uses inference"| node_ml_infer
node_alpha -->|"scores signals"| node_ml_infer
node_alpha -->|"gets prediction score"| node_predict_engine
node_operator -.->|"opts into mode"| node_rl
node_rl -->|"uses guardrails"| node_strategy

click node_news "https://github.com/ksksrbiz-arch/day-trade/blob/main/trader/news.py"
click node_labeler "https://github.com/ksksrbiz-arch/day-trade/blob/main/trader/labeler.py"
click node_labels "https://github.com/ksksrbiz-arch/day-trade/blob/main/trader/labels.py"
click node_strategy "https://github.com/ksksrbiz-arch/day-trade/blob/main/trader/strategy.py"
click node_broker "https://github.com/ksksrbiz-arch/day-trade/blob/main/trader/broker.py"
click node_config "https://github.com/ksksrbiz-arch/day-trade/blob/main/trader/config.py"
click node_backtest "https://github.com/ksksrbiz-arch/day-trade/blob/main/trader/backtest.py"
click node_sim_broker "https://github.com/ksksrbiz-arch/day-trade/blob/main/trader/simbroker.py"
click node_metrics "https://github.com/ksksrbiz-arch/day-trade/blob/main/trader/metrics.py"
click node_walkforward "https://github.com/ksksrbiz-arch/day-trade/blob/main/trader/walkforward.py"
click node_crsp "https://github.com/ksksrbiz-arch/day-trade/blob/main/trader/crsp/query.py"
click node_rl "https://github.com/ksksrbiz-arch/day-trade/blob/main/trader/rl/trader.py"
click node_alpha "https://github.com/ksksrbiz-arch/day-trade/blob/main/trader/alpha.py"
click node_market_brain "https://github.com/ksksrbiz-arch/day-trade/blob/main/trader/market_brain.py"
click node_agents_runtime "https://github.com/ksksrbiz-arch/day-trade/blob/main/trader/agents/runtime.py"
click node_orchestrator "https://github.com/ksksrbiz-arch/day-trade/blob/main/trader/agents/orchestrator.py"
click node_governor "https://github.com/ksksrbiz-arch/day-trade/blob/main/trader/agents/governor.py"
click node_agent_memory "https://github.com/ksksrbiz-arch/day-trade/blob/main/trader/agents/memory.py"
click node_agent_state "https://github.com/ksksrbiz-arch/day-trade/blob/main/trader/agents/state.py"
click node_agent_tools "https://github.com/ksksrbiz-arch/day-trade/blob/main/trader/agents/tools.py"
click node_cloudflare_ai "https://github.com/ksksrbiz-arch/day-trade/blob/main/trader/agents/cloudflare.py"
click node_mesh "https://github.com/ksksrbiz-arch/day-trade/blob/main/trader/mesh.py"
click node_predict_engine "https://github.com/ksksrbiz-arch/day-trade/blob/main/trader/predict/engine.py"
click node_predict_store "https://github.com/ksksrbiz-arch/day-trade/blob/main/trader/predict/store.py"
click node_ml_infer "https://github.com/ksksrbiz-arch/day-trade/blob/main/trader/ml/infer.py"
click node_dashboard "https://github.com/ksksrbiz-arch/day-trade/blob/main/dashboard/app.py"
click node_dashboard_bots "https://github.com/ksksrbiz-arch/day-trade/blob/main/dashboard/bots.py"
click node_brain_page "https://github.com/ksksrbiz-arch/day-trade/blob/main/brain/app/brain/page.tsx"
click node_brain_scene "https://github.com/ksksrbiz-arch/day-trade/blob/main/brain/src/scene/BrainScene.tsx"
click node_live_hook "https://github.com/ksksrbiz-arch/day-trade/blob/main/brain/src/useLive.ts"

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_news,node_labeler,node_labels,node_strategy,node_broker,node_config,node_rl toneBlue
class node_backtest,node_sim_broker,node_metrics,node_walkforward,node_crsp toneAmber
class node_alpha,node_market_brain,node_agents_runtime,node_orchestrator,node_governor,node_agent_memory,node_agent_state,node_agent_tools,node_cloudflare_ai,node_mesh,node_predict_engine,node_predict_store,node_ml_infer toneMint
class node_dashboard,node_dashboard_bots,node_brain_page,node_brain_scene,node_live_hook toneRose
class node_operator,node_rss,node_claude,node_alpaca toneIndigo
```

## Components

### Signals and execution

- [News ingestion](https://github.com/ksksrbiz-arch/day-trade/blob/main/trader/news.py): `trader/news.py`
- [News labeler](https://github.com/ksksrbiz-arch/day-trade/blob/main/trader/labeler.py): `trader/labeler.py`
- [Label model](https://github.com/ksksrbiz-arch/day-trade/blob/main/trader/labels.py): `trader/labels.py`
- [Deterministic strategy](https://github.com/ksksrbiz-arch/day-trade/blob/main/trader/strategy.py): `trader/strategy.py`
- [Paper broker](https://github.com/ksksrbiz-arch/day-trade/blob/main/trader/broker.py): `trader/broker.py`
- [Trading configuration](https://github.com/ksksrbiz-arch/day-trade/blob/main/trader/config.py): `trader/config.py`
- [RL trader](https://github.com/ksksrbiz-arch/day-trade/blob/main/trader/rl/trader.py): `trader/rl/trader.py`

### Replay and measurement

- [Replay harness](https://github.com/ksksrbiz-arch/day-trade/blob/main/trader/backtest.py): `trader/backtest.py`
- [Slippage simulator](https://github.com/ksksrbiz-arch/day-trade/blob/main/trader/simbroker.py): `trader/simbroker.py`
- [Performance metrics](https://github.com/ksksrbiz-arch/day-trade/blob/main/trader/metrics.py): `trader/metrics.py`
- [Walk-forward analysis](https://github.com/ksksrbiz-arch/day-trade/blob/main/trader/walkforward.py): `trader/walkforward.py`
- [Point-in-time data](https://github.com/ksksrbiz-arch/day-trade/blob/main/trader/crsp/query.py): `trader/crsp/query.py`

### Research and autonomy

- [Signal confluence](https://github.com/ksksrbiz-arch/day-trade/blob/main/trader/alpha.py): `trader/alpha.py`
- [Market brain](https://github.com/ksksrbiz-arch/day-trade/blob/main/trader/market_brain.py): `trader/market_brain.py`
- [Agent runtime](https://github.com/ksksrbiz-arch/day-trade/blob/main/trader/agents/runtime.py): `trader/agents/runtime.py`
- [Agent orchestrator](https://github.com/ksksrbiz-arch/day-trade/blob/main/trader/agents/orchestrator.py): `trader/agents/orchestrator.py`
- [Action governor](https://github.com/ksksrbiz-arch/day-trade/blob/main/trader/agents/governor.py): `trader/agents/governor.py`
- [Agent memory](https://github.com/ksksrbiz-arch/day-trade/blob/main/trader/agents/memory.py): `trader/agents/memory.py`
- [Agent state](https://github.com/ksksrbiz-arch/day-trade/blob/main/trader/agents/state.py): `trader/agents/state.py`
- [Agent tools](https://github.com/ksksrbiz-arch/day-trade/blob/main/trader/agents/tools.py): `trader/agents/tools.py`
- [Cloudflare AI client](https://github.com/ksksrbiz-arch/day-trade/blob/main/trader/agents/cloudflare.py): `trader/agents/cloudflare.py`
- [Insight mesh](https://github.com/ksksrbiz-arch/day-trade/blob/main/trader/mesh.py): `trader/mesh.py`
- [Prediction engine](https://github.com/ksksrbiz-arch/day-trade/blob/main/trader/predict/engine.py): `trader/predict/engine.py`
- [Prediction store](https://github.com/ksksrbiz-arch/day-trade/blob/main/trader/predict/store.py): `trader/predict/store.py`
- [ML inference](https://github.com/ksksrbiz-arch/day-trade/blob/main/trader/ml/infer.py): `trader/ml/infer.py`

### Control and visualization

- [Dashboard API](https://github.com/ksksrbiz-arch/day-trade/blob/main/dashboard/app.py): `dashboard/app.py`
- [Bot controls](https://github.com/ksksrbiz-arch/day-trade/blob/main/dashboard/bots.py): `dashboard/bots.py`
- [Brain page](https://github.com/ksksrbiz-arch/day-trade/blob/main/brain/app/brain/page.tsx): `brain/app/brain/page.tsx`
- [3D brain scene](https://github.com/ksksrbiz-arch/day-trade/blob/main/brain/src/scene/BrainScene.tsx): `brain/src/scene/BrainScene.tsx`
- [Live data hook](https://github.com/ksksrbiz-arch/day-trade/blob/main/brain/src/useLive.ts): `brain/src/useLive.ts`

### Other components

- **Operator**
- **RSS feeds**
- **Anthropic Claude**
- **Alpaca paper**

## Connections

- RSS feeds → News ingestion: provides items
- News ingestion → News labeler: feeds news
- Anthropic Claude → News labeler: extracts features
- News labeler → Label model: emits labels
- Label model → Deterministic strategy: drives decisions
- Deterministic strategy → Paper broker: submits trades
- Paper broker → Alpaca paper: places paper orders
- Label model → Replay harness: replays history
- Replay harness → Slippage simulator: simulates fills
- Replay harness → Performance metrics: scores results
- Walk-forward analysis → Point-in-time data: queries history (evidence: `trader/crsp/query.py`)
- Operator → Dashboard API: uses (evidence: `dashboard/app.py`)
- Dashboard API → Bot controls: imports controls (evidence: `dashboard/app.py`)
- Operator → Brain page: opens (evidence: `brain/app/brain/page.tsx`)
- Brain page → 3D brain scene: renders scene
- 3D brain scene → Live data hook: uses live hook (evidence: `brain/src/scene/BrainScene.tsx`)
- Live data hook → 3D brain scene: updates scene (evidence: `brain/src/useLive.ts`)
- Live data hook → Insight mesh: reads topology
- Agent runtime → Insight mesh: publishes insights (evidence: `trader/agents/runtime.py`)
- Agent runtime → Prediction engine: runs cycle (evidence: `trader/agents/runtime.py`)
- Prediction engine → Prediction store: records predictions (evidence: `trader/predict/engine.py`)
- Prediction engine → Point-in-time data: loads prices (evidence: `trader/predict/engine.py`)
- Agent orchestrator → Agent memory: recalls context (evidence: `trader/agents/orchestrator.py`)
- Agent orchestrator → Agent tools: selects tools (evidence: `trader/agents/orchestrator.py`)
- Agent tools → Action governor: governs actions (evidence: `trader/agents/tools.py`)
- Action governor → Agent memory: records actions (evidence: `trader/agents/governor.py`)
- Agent tools → Cloudflare AI client: scores headlines (evidence: `trader/agents/tools.py`)
- Agent runtime → Agent state: checkpoints state (evidence: `trader/agents/runtime.py`)
- Agent runtime → Insight mesh: snapshots mesh (evidence: `trader/agents/runtime.py`)
- Agent tools → ML inference: uses inference (evidence: `trader/agents/tools.py`)
- Signal confluence → ML inference: scores signals (evidence: `trader/alpha.py`)
- Signal confluence → Prediction engine: gets prediction score (evidence: `trader/alpha.py`)
- Operator → RL trader: opts into mode
- RL trader → Deterministic strategy: uses guardrails (evidence: `trader/rl/trader.py`)
