MQT
Home

Case study · Quant / Trading & Performance

CrossVenue

Multi-venue market-data and execution-simulation infrastructure

CrossVenue pipeline: venue adapters into local books, opportunity engine, risk, and simulated two-leg execution

The problem

Cross-exchange “arbitrage” on best bid/ask is misleading. Venues have different sequence rules, two-leg execution is not atomic, and a restart must not resume trading from stale books. CrossVenue is a trading-systems project: simulated execution, no live funds, no profitability claims.

What I built

Venue-specific market data

Binance, OKX, and Bybit adapters normalize into a shared event model while preserving each venue’s sequence/gap rules for local books.

Depth-aware opportunity pricing

Opportunities are computed from observed depth (VWAP) after configurable fees, modeled slippage, and a latency penalty, not top-of-book spreads.

Non-atomic two-leg simulation

Partial second-leg fills are first-class: residual directional exposure is journaled. Inventory-aware risk, stale quote rejection, daily loss limit, and a kill switch run before execution.

Record, replay, recover

Same recording + config + seed produces identical books, executions, balances, PnL, and journal digest. Restart restores portfolio state; books resynchronize from fresh market data.

Engineering decisions

Three modes, one ingest path

live-market-sim (public WS, paper fills), synthetic, and replay share a single engine ingest path. ENABLE_LIVE_EXECUTION=true refuses to start rather than trade.

Failure scenes as tests

Automated scenes cover sequence gap, venue disconnect, stale quote, partial second-leg fill, duplicate client order ID, restart, kill switch, and queue overload.

Replay digest as proof

Verified locally on commit e9be5ea (Go 1.26.5, windows/amd64): two replay runs produced identical digest de7495fd8b25d9dbb66726d1bb5aac61045b23d5eef79b19ec0abddcfe87f33c. Benchmarks on the same machine: ApplyDelta 41.4 ns/op (0 allocs).

Architecture

Venue adapters normalize Binance, OKX, Bybit, synthetic, and replay sources into per-book owner goroutines, then opportunity, risk, simulated execution, portfolio, and a PostgreSQL journal

Venue adapters normalize Binance, OKX, Bybit, synthetic, and replay sources into per-book owner goroutines, then opportunity, risk, simulated execution, portfolio, and a PostgreSQL journal

Testing & CI

go test ./... including integration and replay parity; go test -race; make verify (fmt, vet, staticcheck, tests, race, seed-42 replay, synthetic probe, failure scenes, docker build).

Go / PostgreSQL / Prometheus / Binance / OKX / Bybit