Skip to content

Latest commit

 

History

10 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Caerus

Low-latency cross-exchange market data and execution infrastructure for BTC perpetual futures, exploiting the price lag between Binance and Hyperliquid. Four pinned, hot-path processes connected by lock-free shared-memory queues, plus an off-path capture process streaming the same rings into Redpanda/ClickHouse. Measured end to end on live venues (honest attempt).

Strat and exec are pending review. See PR #6. Tests were not run on main branch

Headline results

4-hour session on a core-pinned c7i.2xlarge in ap-northeast-1 (Tokyo), 1,274 orders fired against live Binance + Hyperliquid feeds.

Metric Value
Tick-to-decision (book received → order fired), reactive fires n=1200 11.3 µs p50 · 16.3 µs p99 · 38.7 µs max
Queue transit + engine pickup (shared-memory hop) 0.50 µs p50 · 3.3 µs p99
Clock artifacts across all samples 0 (chrony vs Amazon Time Sync, sub-µs RMS)
Binance information age on arrival (Tokyo) ~3.1 ms p50 (floor 2.6 ms)
Hyperliquid public-book information age ~285 ms p50 (floor 204 ms — their block→publish pipeline, not the wire)

Architecture

Binance WSS ──> market_data_feed ──SWMR ring──>┬─> strategy ──> MPSC ring ──> execution_engine
HL WSS      ──> market_data_feed ──SWMR ring──>┤
                                               └─> pipeline ──> Redpanda  ──> ClickHouse

Repository map

Path Contents
libs/net Single-use async TLS WebSocket client (Boost.Asio/Beast), failure taxonomy
libs/ipc Shared-memory facades: SWMR writer/reader, MPSC writer/reader, POD wire types
libs/utils Lock-free queues (lf_swmr_queue, lf_spsc_queue, lf_mpsc_queue), time helpers
apps/feeds Per-venue feed processes: WSS supervision, simdjson parsers, book validation
apps/strategy Naive cross-venue latency-arb strategy + supervisor (entry/exit thresholds, cooldown, max-hold, staleness guards)
apps/execution Order-queue consumer; benchmark harness around the send_msg() network seam
apps/pipeline Historical capture: shm → Redpanda → ClickHouse (JSONEachRow)
tests Catch2 suites incl. a scripted local TLS WebSocket server harness
docs Latency reports, charts, setup guides
scripts Unattended EC2 benchmark orchestrator (provision → build → pinned fleet → collect)

Build and run

Dependencies are vcpkg-manifested (Boost, simdjson, fmt, librdkafka, Catch2, OpenSSL).

cmake -B build -S . -DCMAKE_TOOLCHAIN_FILE=$VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake -DCMAKE_BUILD_TYPE=Release
cmake --build build -j
ctest --test-dir build

Run order is arbitrary — every process retry-attaches:

./build/apps/feeds/market_data_feed --venue binance --segment caerus_md_binance
./build/apps/feeds/market_data_feed --venue hyperliquid --segment caerus_md_hl
./build/apps/pipeline/pipeline --brokers {HOSTNAME:PORT} --topic caerus_states --segment caerus_md_binance --segment caerus_md_hl
./build/apps/strategy/naive_strategy --segment caerus_md_binance --segment caerus_md_hl --order-segment caerus_orders
./build/apps/execution/execution_engine --segment caerus_orders

Status and roadmap

send_msg() is deliberately a stub: the measured interval ends at the network seam, and the report says so explicitly. models: to train something more complex Consider thread pooling to sustain more connections.

MIT licensed. © 2026 Kerk Tai Heng.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages