System Architecture
A modern microservices architecture designed for real-time algorithmic trading across multiple venues.
Technology Stack
High-Level Architecture
Data Flow
Two paths optimised for different requirements: minimal latency for the engine, and durable recording for history.
Venue WebSocket → StreamManager → PatchEngineService
Purpose: Minimal latency for live strategy execution. Sub-100ms from exchange to module processing.
All Venues → gRPC → Redis Streams → 3 parallel consumers
Consumers: MarketDataBridge (fan-out), MarketDataRecorder (TimescaleDB), BarAggregator (OHLCV)
Processing Engine
| Capability | Specification |
|---|---|
| Tick rate | 10 ticks/second (100ms interval) |
| Processing order | Topological sort via Kahn's algorithm |
| Cycle prevention | Rejected at cable-connection time |
| Probe system | Real-time signal inspection, throttled to 30 updates/sec |
| Transport protocol | SignalR with MessagePack binary encoding |
| Thread safety | Lock-based mutation, async probe broadcast |
Multi-Venue
Each venue runs as an independent Docker container with gRPC MarketData, TradeFlow, and Admin services.
| Venue | Symbol Format | Type | gRPC Port |
|---|---|---|---|
| Binance | BTCUSDT | Spot | 5060 |
| Bybit | BTCUSDT | Spot | 5061 |
| Kraken | BTC/USDT | Spot | 5062 |
| OKX | BTC-USDT | Spot | 5063 |
| Coinbase | BTC-USD | Spot | 5064 |
| Deribit | BTC-PERPETUAL | Derivatives | 5081 |
| Binance Futures | BTCUSDT | USD-M Perps | 5065 |
| OKX Futures | BTC-USDT-SWAP | Perp Swaps | 5068 |
Real-Time Communication
Bidirectional real-time communication via SignalR with MessagePack binary protocol.
| Hub | Endpoint | Purpose |
|---|---|---|
| PatchHub | /hubs/patch | Module/cable CRUD, parameter updates, patch state |
| ProbeHub | /hubs/probe | Real-time signal data streaming |
| StateHub | /hubs/state | Patch lifecycle and activation |
| LogHub | /hubs/logs | Structured log broadcasting |
| TradeHub | /hubs/trades | Trade fill notifications |
| StrategyHub | /hubs/strategy | Strategy lifecycle and status |
| MarketHub | /hubs/market | Live market ticker data (4Hz, multi-venue) |
| RiskHub | /hubs/risk | Risk events, dead-man switch heartbeat |
| BacktestHub | /hubs/backtest | Backtest progress and results streaming |
| OverwatchHub | /hubs/overwatch | Overwatch regime + strategy status (1Hz) |
| ScreenerHub | /hubs/screener | Multi-symbol screener scan results |
| SupervisorHub | /hubs/supervisor | AI supervisor decisions and audit trail |
Deployment
TimescaleDB (PostgreSQL 16), Redis 7, TigerBeetle — persistent data stores with bind-mounted volumes.
API server, Ledger gRPC service, MarketData poller, Python sidecar, React client — independently scalable services.
8 exchange connectors as independent containers. Each provides gRPC MarketData, TradeFlow, and Admin services.
Financial Accounting
Every financial event is recorded as a double-entry transaction. No balance can be lost or miscounted.
| Ledger | ID | Purpose |
|---|---|---|
| Cash | 1 | Available capital and margin |
| Position | 2 | Open position accounting |
| Fees | 3 | Trading fees and commissions |
| Realised PnL | 4 | Closed trade profit/loss |
| Margin | 5 | Locked margin for leveraged positions |
| Funding PnL | 6 | Perpetual swap funding payments |