Quant Arb Trading Architecture

MT5 + OKX + Binance semi-live monitor and paper execution scaffold as implemented in the current codebase.

Quant Arb Workspace /root/.openclaw/workspace/trading Viewer Browser Basic Auth -> / and /api/dashboard MT5 EA WebRequest POST /mt5/tick OKX Public REST /api/v5/market/ticker Binance Public REST /api/v3/ticker/bookTicker presentation / service boundary scripts/public_monitor_service.py ThreadingHTTPServer + DemoHandler /, /healthz, /api/dashboard, /mt5/tick presentation.dashboard render_dashboard_html() build_dashboard_api_payload() presentation.mt5_state store_mt5_quote_payload() load_mt5_quote_payload() presentation.service_state resolve_mt5_quote_payload() application orchestration and monitor core PaperOrchestrator ingest_quote_payload() -> OpportunityPlan -> OrchestrationReport record_report(), poll_mt5_command(), apply_fill_update() owns MT5Bridge, OpportunityPipeline, tracker, compensation, gateway OpportunityPipeline normalize + compare + dedupe build execution intent PublicPaperMonitor run_cycle_reports() wraps PublicQuoteRuntime CompareEngine maintains latest quotes emits CompareSnapshot produces PairComparison PublicMonitorRunner run_iterations() collects summary stats appends monitor logs InFlightOrderTracker track_intent() apply_update() CompensationEngine evaluate() hedge repair decision EdgeLogBook append() recent_log_lines() RuntimeTuning threshold, cooldown, pairs normalization scales adapters and state MT5Bridge parse_tick_payload() enqueue_intent(), poll_command(), acknowledge() in-memory command queue OkxTickerNormalizer / BinanceBookTickerNormalizer payload -> Quote source-specific normalization PublicQuoteRuntime OkxRestFetcher + BinanceRestFetcher requests.get() via asyncio.to_thread() poll_once_tagged() PaperExecutionGateway prepare_exchange_order() normalize only, no live placement File State logs/public_monitor_service.log logs/mt5_live_tick.json dashboard auth file and stdout/stderr logs Domain Model Quote -> DirectedEdge -> PairComparison ExecutionLeg -> ExecutionIntent -> ExchangeOrderRequest -> OrchestrationReport ExecutionGroup / InFlightOrder / CompensationAction support paper execution and repair logic HTTPS MT5 tick ingress OKX REST polling Binance REST polling build dashboard context reports + lines Legend Frontend / viewer Application core Adapter / state MT5 / ingress

Implemented flow

  • • MT5 tick can be pushed into the service and persisted as latest live quote.
  • • OKX and Binance are fetched from public REST endpoints.
  • • Orchestrator produces paper execution intent, reports, logs, and dashboard summaries.
  • • Dashboard service renders HTML plus JSON fragments for partial refresh.

Current boundaries

  • • Execution is still paper-oriented: PaperExecutionGateway only normalizes orders.
  • • MT5Bridge command queue is in memory; no public pull/ack API is exposed yet.
  • • Tracker and compensation state are in memory, not persisted in a ledger.
  • • Market data is semi-live via REST polling, not production WebSocket streaming.

Main source files

  • • scripts/public_monitor_service.py
  • • src/quant_arb/application/orchestration.py
  • • src/quant_arb/application/pipeline.py
  • • src/quant_arb/adapters/live_runners.py and mt5_bridge.py