TRADING SYSTEMSACTIVE DEVELOPMENT

BTC 5-min Polymarket Bot

One engineer ran a 215k-line production trading system solo — under 13 quality gates that cannot be bypassed.

AT A GLANCE

AT A GLANCEBTC-BOT
STATUS
ACTIVE DEVELOPMENT
TIMELINE
2026-03 — 2026-06 · 84 DAYS
LANGUAGES
Rust / Python
CATEGORY
TRADING SYSTEMS
291M / day

MARKET EVENTS CAPTURED PER DAY

OUTCOME

A live system on AWS (paper mode, no real money) that decides in 21 microseconds — locked behind 65 frozen design records, 13 unskippable quality gates, and 102 stress tests, the same discipline you get on simpler automation work.

BTC 5-min Polymarket Bot cover

METRICS

291M / day

M.01MARKET EVENTS CAPTURED PER DAY

11 venues, 49 event streams, one capture day (2026-06-11); ~3,370 events/second

21 µs p50

M.02DECISION SPEED, IN PRODUCTION

median time to price a bet and decide, measured over 506,243 live calls (2026-06-12)

2,948 passing

M.03AUTOMATED TESTS

Rust workspace suite, zero failures at the last recorded full run (2026-06-11)

13 strict gates

M.04QUALITY GATES PER COMMIT

AI code review, supply-chain audit, schema-drift and doc checks block every commit; no bypass flag exists

 

 

THE CASE, CHAPTER BY CHAPTER

CH.01

The problem

Trading Bitcoin's 5-minute prediction markets is normally a four-person job — this project asks whether one engineer can do it.

The market reprices every 300 seconds, so a bot has to read 11 live exchanges and decide in well under a second. Doing that reliably usually needs a data engineer, a backend engineer, an SRE, and a quant. The question here: can one engineer with AI agents, under strict review gates, build and run the whole thing.

CH.02

What it does

A live Rust system on AWS prices a bet and decides in 21 microseconds — measured, not estimated.

Two always-on processes run on one small ARM box. The collector reads 11 exchanges and captured 291 million market events in a single day. The trading process scores a machine-learned model on every order-book change; production tracing puts the full decision pass at a 21 µs median over 506,243 calls. It runs in paper mode — every order takes the real signing and venue path but is rejected at size zero, so nothing is risked.

CH.03

How it stays fast

Nothing polls — every decision fires the instant a market event arrives, moved between processes in about a microsecond.

A venue message flows through lock-free shared memory in ~1 µs and either changes a decision or doesn't. Orders are pre-signed in a pool, so the hot path never waits on cryptography. Every order writes a timestamped audit row for each state change — replayable transition by transition.

THE DECISION, MEASURED

 

 

 

INITIALIZEDSUBMITTED+0 MSREJECTED+30 MS0 MS0 MS30 MS

CLIENT_ORDER_ID, TOKEN_ID, PRICE, QUANTITY SCRUBBED — STRUCTURE AND TIMING REAL

SOURCE: pm_5m_export order_lifecycle_events.parquet, one client_order_id, 2026-06-12; relative timestamps from ts_ms — MEASURED 2026-06-12

CH.04

Why you can trust it unattended

13 quality gates block every commit, and there is no flag to skip them.

Each commit passes link checks, schema-drift detectors, supply-chain audits, and an AI code reviewer that can block it — no bypass exists. The suite holds 2,948 passing tests, and 102 soak-test runners check the live data against a 5-minute mirror. An offline simulator replays recorded data and reproduces every live decision at 100% parity, so changes are proven safe before they hit the wire.

CH.05

What one person delivered

2,872 commits and 215,000 lines of Rust in 84 days — solo, with every number measured on the running system.

One engineer shipped this in 84 days with AI agent orchestration as the only toolchain. Coverage held at 99.8% of capture windows over 19 days, and 65 frozen design records explain why each major choice was made, so any future engineer inherits the reasoning — not just the code. The same discipline (spend caps, audit logs, unskippable tests) applies to automation work an order of magnitude simpler.

WHAT THE COLLECTOR CAPTURES

291M EVENTS — ONE CAPTURE DAY

100K1.0M10.0M100.0MPolymarket110.6M3 STREAMSCoinbase64.0M5 STREAMSBinance spot27.6M5 STREAMSKraken24.9M4 STREAMSGemini20.2M2 STREAMSBybit19.7M5 STREAMSOKX15.1M7 STREAMSDeribit3.8M6 STREAMSBinance futures3.4M6 STREAMSBitstamp1.2M2 STREAMS(collector internals)440K3 STREAMSChainlink280K1 STREAM

LOG SCALE · SOURCE: DuckDB row counts grouped by parquet table name over data/microstruct/2026-06-11/*/*/*.parquet, tables aggregated to their venue · MEASURED 2026-06-11

WHAT IT COSTS TO REACH THE VENUE

10MS100MS1SP1034MSP2536MSP5038MSMEDIAN 38 MSP7544MSP9074MSP95313MSP992.79STAIL 2.787S

THE SYSTEM DECIDES IN ~21 µs — THE VENUE ANSWERS IN ~38 MS (MEDIAN). THE WIRE IS THE COST. CANCEL MEDIAN 31 MS.

N=2,315,2232026-06-05 .. 2026-06-11 pm_5m_export probe_events.parquet, stage=0 (PlaceLive), aggregated with DuckDB on the synced prod mirror

9.6 GB24 MAY03 JUN12 JUN
MICROSTRUCT
PM 5 M EXPORT
SHORT PARTITION

99.8% OF 5-MINUTE PARTITIONS PRESENT — 2026-05-24 .. 2026-06-12 (2026-06-12 is a partial day)

SOURCE: per-day recursive file-size sums over data/microstruct and pm_5m_export on the synced prod mirror; coverage = count of 5-minute partitions containing collector_heartbeat.parquet out of 288 expected per day

THE BUILD, WEEK BY WEEK

569 COMMITS — PEAK WEEK16 MAR 202608 JUN 2026

2872 COMMITS — IN 84 DAYS — AVG 34/DAY

Docs
48.8% 349.5K
Rust
30.0% 214.6K
Python
14.7% 105.2K
Config
5.5% 39.5K
Shell
1.0% 7.0K

FROM THE OPERATOR'S SCREEN

LIVE OPERATOR VIEW — PRICE FEEDS, MODEL OUTPUT, ORDER LADDERS, COMPUTE TIME, MOMENTUM AND PROBE LATENCY ACROSS ONE TRADING WINDOW (PAPER MODE)
LIVE OPERATOR VIEW — PRICE FEEDS, MODEL OUTPUT, ORDER LADDERS, COMPUTE TIME, MOMENTUM AND PROBE LATENCY ACROSS ONE TRADING WINDOW (PAPER MODE)
DETAIL — REFLEX MOMENTUM AND PROBE PLACE/LIFE LATENCY PANELS
DETAIL — REFLEX MOMENTUM AND PROBE PLACE/LIFE LATENCY PANELS

FEATURES

Two parallel decision pathsA fast reflex path reacts to every order-book change while a slower path re-scores the ML model, running on separate CPU-pinned threads so neither blocks the other.
114-signal ML ensembleXGBoost and CatBoost models score 114 live market signals through ONNX Runtime in-process, with no network call on the decision path.
Microsecond internal data busMarket data moves between the two processes through lock-free shared memory in about one microsecond, with no kernel round-trip.
Offline simulator that proves changes safeAn offline twin replays recorded market data through the exact same decision code and asserts a 100% match against live decisions before any change ships.
13 unskippable quality gatesEvery commit must pass an AI code reviewer, supply-chain audit, schema-drift detector, and doc checks — all blocking, with no bypass flag in the codebase.
Atomic deploy with auto-rollbackEach deploy cross-compiles for ARM, swaps the binary atomically, and watches a health endpoint for up to 180 seconds — rolling back to the previous binary on failure.

ARCHITECTURE

microstruct (feeds crate)11-venue WebSocket + REST collector. Writes Parquet partitions and two SQLite WAL databases. Publishes BTC-only events on 10 iceoryx2 streams.
btc-bot-live (live crate)Event-driven orchestrator + reflex + GTC executor. Subscribes to iceoryx2, reads SQLite read-only, drains 13-variant DbRow stream to Parquet and WebSocket :9091.
core cratePure math: evaluate_reflex, 114-feature compute, PupGrid, fee-aware pricing, k=6 regime classifier, HARD4/TDA2/RES2 detector kernels. No I/O.
sim crateOffline replay twin. Owns OrtPredictor (ONNX Runtime). Calls identical evaluate_reflex. Parity oracle asserts 100% fire-set match.
clob cratePolymarket CLOB V2 wire surface: HTTP/2 client, EIP-712 V2 signer, 198-slot presign grid, canonical error classifier.
iceoryx2 IPC bus10 per-stream lock-free SHM payload services plus feature-advance notifier and boot-handshake. ~1 µs per hop, no kernel transition.
DashboardPlotly Dash operator UI on :8052, fed by ws_to_sqlite.py adapter off the bot's WebSocket broadcast. Mobile-reachable over Tailscale.

STACK

LANGRustPython
FXtokioiceoryx2ONNX Runtime (ORT)XGBoostCatBoostPlotly Dash
INFRAAWS eu-west-1 (Dublin)m8g.xlarge (Graviton 4 ARM)systemdWSL2 cross-compileSQLite WALApache Parquet
AIXGBoost (ONNX)CatBoost (ONNX)DeepSeek (AI pre-commit code critic)Claude Code (AI agent orchestration — sole developer toolchain)

SKILLS DEMONSTRATED

Building production systems solo with AI agents · Low-latency, event-driven Rust systems programming · Machine-learning inference in the live path (ONNX, XGBoost, CatBoost) · Real-time data pipelines across 11 live sources · Enforced quality gates that block bad commits automatically · Test-before-deploy verification with an offline simulator · Auditable order trails and unattended 24/7 operation · Atomic AWS deployment with automatic rollback · Documented, frozen design decisions for handoff · Spend caps and safe-by-default operating controls

THE CODE, MAPPED

SHOWING THE 350 MOST CONNECTED OF 35,163 NODES · 51,059 EDGES · 2,403 COMMUNITIES — EXTRACTED FROM THE CODEBASE BY TREE-SITTER

GRAPH