# richkuo/go-trader architecture

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

- Interactive diagram: https://gitdiagram.com/richkuo/go-trader
- Repository: https://github.com/richkuo/go-trader

## Overview

go-trader is a Go-orchestrated, Python-powered trading system. Its principal workflow is a scheduler cycle that launches Python strategy checks, receives JSON signals, applies portfolio risk controls, executes paper or live trades through supported venue integrations, persists state, and reports through status and messaging channels. The repository also includes a substantial research workflow for fetching market data, backtesting strategies, and analyzing regime and Hurst-gate behavior. The README establishes the runtime flow; source-index references support selected Python-module connections. Unsampled scheduler and strategy implementations are represented only at documented subsystem level.

Main entry points: [`scheduler/main.go`](https://github.com/richkuo/go-trader/blob/main/scheduler/main.go) (Go scheduler), [`backtest/eval_windows.py`](https://github.com/richkuo/go-trader/blob/main/backtest/eval_windows.py) (Window evaluation), [`backtest/backtester.py`](https://github.com/richkuo/go-trader/blob/main/backtest/backtester.py) (Simulation engine), [`backtest/research/hurst_1410_gate_calibration.py`](https://github.com/richkuo/go-trader/blob/main/backtest/research/hurst_1410_gate_calibration.py) (Hurst gate studies)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Trading runtime"]
  node_scheduler["Go scheduler<br/>[main.go]"]
  node_risk["Portfolio risk<br/>[risk.go]"]
  node_execution["Trade execution<br/>[executor.go]"]
  node_state[("Runtime state<br/>[state_store.go]")]
  node_status["Status and UI<br/>[ui_server.go]"]
  node_alerts["Trade alerts<br/>[notifier.go]"]
end

subgraph group_strategies["Strategy execution"]
  node_python_checks["Python strategy checks"]
  node_strategy_registry["Strategy registry<br/>[registry.py]"]
  node_open_strategies["Entry strategies"]
  node_close_strategies["Exit strategies"]
end

subgraph group_venues["Venue integrations"]
  node_venue_adapters["Venue adapters"]
end

subgraph group_research["Backtesting research"]
  node_backtest_entry["Backtest runner<br/>[run_backtest.py]"]
  node_backtester["Simulation engine<br/>[backtester.py]"]
  node_window_eval["Window evaluation<br/>[eval_windows.py]"]
  node_regime_labels["Regime labels"]
  node_regime_stats["Regime statistics<br/>[regime_stats.py]"]
  node_research_hurst["Hurst gate studies"]
end

subgraph group_shared["Shared Python services"]
  node_market_data["Market data fetch<br/>[data_fetcher.py]"]
  node_ohlcv_store[("Market-data store<br/>[storage.py]")]
  node_egress["Egress policy<br/>[egress_policy.py]"]
  node_indicators["Strategy indicators<br/>[indicators_core.py]"]
  node_atr["ATR calculations<br/>[atr.py]"]
  node_closed_bar["Closed-bar data<br/>[closed_bar.py]"]
end

node_operator(("Operator"))
node_researcher(("Researcher"))

node_operator -->|"configures and starts"| node_scheduler
node_scheduler -->|"spawns each cycle"| node_python_checks
node_python_checks -->|"returns JSON signals"| node_scheduler
node_scheduler -->|"manages risk"| node_risk
node_scheduler -->|"executes trades"| node_execution
node_scheduler -->|"persists state"| node_state
node_scheduler -->|"serves status"| node_status
node_scheduler -->|"posts alerts"| node_alerts
node_execution -.->|"uses venue integrations"| node_venue_adapters
node_python_checks -.->|"loads strategies"| node_strategy_registry
node_strategy_registry -->|"loads entry strategies"| node_open_strategies
node_strategy_registry -.->|"loads exit strategies"| node_close_strategies
node_researcher -->|"runs backtests"| node_backtest_entry
node_backtest_entry -.->|"runs simulations"| node_backtester
node_window_eval -->|"evaluates legs"| node_backtester
node_window_eval -->|"loads market data"| node_market_data
node_window_eval -->|"uses regime labels"| node_regime_labels
node_research_hurst -->|"evaluates windows"| node_window_eval
node_research_hurst -->|"computes significance"| node_regime_stats
node_research_hurst -->|"uses indicators"| node_indicators
node_backtester -->|"uses ATR"| node_atr
node_backtester -->|"uses storage"| node_ohlcv_store
node_market_data -->|"reads and writes candles"| node_ohlcv_store
node_market_data -->|"uses network policy"| node_egress
node_open_strategies -->|"uses closed-bar data"| node_closed_bar

click node_scheduler "https://github.com/richkuo/go-trader/blob/main/scheduler/main.go"
click node_risk "https://github.com/richkuo/go-trader/blob/main/scheduler/risk.go"
click node_execution "https://github.com/richkuo/go-trader/blob/main/scheduler/executor.go"
click node_state "https://github.com/richkuo/go-trader/blob/main/scheduler/state_store.go"
click node_status "https://github.com/richkuo/go-trader/blob/main/scheduler/ui_server.go"
click node_alerts "https://github.com/richkuo/go-trader/blob/main/scheduler/notifier.go"
click node_python_checks "https://github.com/richkuo/go-trader/tree/main/shared_scripts"
click node_strategy_registry "https://github.com/richkuo/go-trader/blob/main/shared_strategies/open/registry.py"
click node_open_strategies "https://github.com/richkuo/go-trader/tree/main/shared_strategies/open"
click node_close_strategies "https://github.com/richkuo/go-trader/tree/main/shared_strategies/close"
click node_venue_adapters "https://github.com/richkuo/go-trader/tree/main/platforms"
click node_market_data "https://github.com/richkuo/go-trader/blob/main/shared_tools/data_fetcher.py"
click node_ohlcv_store "https://github.com/richkuo/go-trader/blob/main/shared_tools/storage.py"
click node_egress "https://github.com/richkuo/go-trader/blob/main/shared_tools/egress_policy.py"
click node_backtest_entry "https://github.com/richkuo/go-trader/blob/main/backtest/run_backtest.py"
click node_backtester "https://github.com/richkuo/go-trader/blob/main/backtest/backtester.py"
click node_window_eval "https://github.com/richkuo/go-trader/blob/main/backtest/eval_windows.py"
click node_regime_labels "https://github.com/richkuo/go-trader/blob/main/backtest/regime_label_columns.py"
click node_regime_stats "https://github.com/richkuo/go-trader/blob/main/backtest/regime_stats.py"
click node_research_hurst "https://github.com/richkuo/go-trader/blob/main/backtest/research/hurst_1410_gate_calibration.py"
click node_indicators "https://github.com/richkuo/go-trader/blob/main/shared_strategies/open/indicators_core.py"
click node_atr "https://github.com/richkuo/go-trader/blob/main/shared_tools/atr.py"
click node_closed_bar "https://github.com/richkuo/go-trader/blob/main/shared_tools/closed_bar.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_scheduler,node_risk,node_execution,node_state,node_status,node_alerts toneBlue
class node_python_checks,node_strategy_registry,node_open_strategies,node_close_strategies toneAmber
class node_venue_adapters toneMint
class node_backtest_entry,node_backtester,node_window_eval,node_regime_labels,node_regime_stats,node_research_hurst toneRose
class node_market_data,node_ohlcv_store,node_egress,node_indicators,node_atr,node_closed_bar,node_operator,node_researcher toneIndigo
```

## Components

### Trading runtime

- [Go scheduler](https://github.com/richkuo/go-trader/blob/main/scheduler/main.go): `scheduler/main.go`
- [Portfolio risk](https://github.com/richkuo/go-trader/blob/main/scheduler/risk.go): `scheduler/risk.go`
- [Trade execution](https://github.com/richkuo/go-trader/blob/main/scheduler/executor.go): `scheduler/executor.go`
- [Runtime state](https://github.com/richkuo/go-trader/blob/main/scheduler/state_store.go): `scheduler/state_store.go`
- [Status and UI](https://github.com/richkuo/go-trader/blob/main/scheduler/ui_server.go): `scheduler/ui_server.go`
- [Trade alerts](https://github.com/richkuo/go-trader/blob/main/scheduler/notifier.go): `scheduler/notifier.go`

### Strategy execution

- [Python strategy checks](https://github.com/richkuo/go-trader/tree/main/shared_scripts): `shared_scripts`
- [Strategy registry](https://github.com/richkuo/go-trader/blob/main/shared_strategies/open/registry.py): `shared_strategies/open/registry.py`
- [Entry strategies](https://github.com/richkuo/go-trader/tree/main/shared_strategies/open): `shared_strategies/open`
- [Exit strategies](https://github.com/richkuo/go-trader/tree/main/shared_strategies/close): `shared_strategies/close`

### Venue integrations

- [Venue adapters](https://github.com/richkuo/go-trader/tree/main/platforms): `platforms`

### Backtesting research

- [Backtest runner](https://github.com/richkuo/go-trader/blob/main/backtest/run_backtest.py): `backtest/run_backtest.py`
- [Simulation engine](https://github.com/richkuo/go-trader/blob/main/backtest/backtester.py): `backtest/backtester.py`
- [Window evaluation](https://github.com/richkuo/go-trader/blob/main/backtest/eval_windows.py): `backtest/eval_windows.py`
- [Regime labels](https://github.com/richkuo/go-trader/blob/main/backtest/regime_label_columns.py): `backtest/regime_label_columns.py`
- [Regime statistics](https://github.com/richkuo/go-trader/blob/main/backtest/regime_stats.py): `backtest/regime_stats.py`
- [Hurst gate studies](https://github.com/richkuo/go-trader/blob/main/backtest/research/hurst_1410_gate_calibration.py): `backtest/research/hurst_1410_gate_calibration.py`

### Shared Python services

- [Market data fetch](https://github.com/richkuo/go-trader/blob/main/shared_tools/data_fetcher.py): `shared_tools/data_fetcher.py`
- [Market-data store](https://github.com/richkuo/go-trader/blob/main/shared_tools/storage.py): `shared_tools/storage.py`
- [Egress policy](https://github.com/richkuo/go-trader/blob/main/shared_tools/egress_policy.py): `shared_tools/egress_policy.py`
- [Strategy indicators](https://github.com/richkuo/go-trader/blob/main/shared_strategies/open/indicators_core.py): `shared_strategies/open/indicators_core.py`
- [ATR calculations](https://github.com/richkuo/go-trader/blob/main/shared_tools/atr.py): `shared_tools/atr.py`
- [Closed-bar data](https://github.com/richkuo/go-trader/blob/main/shared_tools/closed_bar.py): `shared_tools/closed_bar.py`

### Other components

- **Operator**
- **Researcher**

## Connections

- Operator → Go scheduler: configures and starts (evidence: `README.md`)
- Go scheduler → Python strategy checks: spawns each cycle (evidence: `README.md`)
- Python strategy checks → Go scheduler: returns JSON signals (evidence: `README.md`)
- Go scheduler → Portfolio risk: manages risk (evidence: `README.md`)
- Go scheduler → Trade execution: executes trades (evidence: `README.md`)
- Go scheduler → Runtime state: persists state (evidence: `README.md`)
- Go scheduler → Status and UI: serves status (evidence: `README.md`)
- Go scheduler → Trade alerts: posts alerts (evidence: `README.md`)
- Trade execution → Venue adapters: uses venue integrations
- Python strategy checks → Strategy registry: loads strategies
- Strategy registry → Entry strategies: loads entry strategies
- Strategy registry → Exit strategies: loads exit strategies
- Researcher → Backtest runner: runs backtests (evidence: `README.md`)
- Backtest runner → Simulation engine: runs simulations
- Window evaluation → Simulation engine: evaluates legs (evidence: `backtest/eval_windows.py`)
- Window evaluation → Market data fetch: loads market data (evidence: `backtest/eval_windows.py`)
- Window evaluation → Regime labels: uses regime labels (evidence: `backtest/eval_windows.py`)
- Hurst gate studies → Window evaluation: evaluates windows (evidence: `backtest/research/hurst_1410_gate_calibration.py`)
- Hurst gate studies → Regime statistics: computes significance (evidence: `backtest/research/hurst_1410_gate_calibration.py`)
- Hurst gate studies → Strategy indicators: uses indicators (evidence: `backtest/research/hurst_1410_gate_calibration.py`)
- Simulation engine → ATR calculations: uses ATR (evidence: `backtest/backtester.py`)
- Simulation engine → Market-data store: uses storage (evidence: `backtest/backtester.py`)
- Market data fetch → Market-data store: reads and writes candles (evidence: `shared_tools/data_fetcher.py`)
- Market data fetch → Egress policy: uses network policy (evidence: `shared_tools/data_fetcher.py`)
- Entry strategies → Closed-bar data: uses closed-bar data (evidence: `shared_strategies/open/adaptive_moving_average.py`)
