TRADING SYSTEMS — ACTIVE 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
- STATUS
- ACTIVE DEVELOPMENT
- TIMELINE
- 2026-03 — 2026-06 · 84 DAYS
- LANGUAGES
- Rust / Python
- CATEGORY
- TRADING SYSTEMS
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.
METRICS
M.01 — MARKET EVENTS CAPTURED PER DAY
11 venues, 49 event streams, one capture day (2026-06-11); ~3,370 events/second
M.02 — DECISION SPEED, IN PRODUCTION
median time to price a bet and decide, measured over 506,243 live calls (2026-06-12)
M.03 — AUTOMATED TESTS
Rust workspace suite, zero failures at the last recorded full run (2026-06-11)
M.04 — QUALITY 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
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
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
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,223 — 2026-06-05 .. 2026-06-11 — pm_5m_export probe_events.parquet, stage=0 (PlaceLive), aggregated with DuckDB on the synced prod mirror
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
2872 COMMITS — IN 84 DAYS — AVG 34/DAY
FROM THE OPERATOR'S SCREEN


FEATURES
| Two parallel decision paths | A 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 ensemble | XGBoost and CatBoost models score 114 live market signals through ONNX Runtime in-process, with no network call on the decision path. |
| Microsecond internal data bus | Market 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 safe | An 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 gates | Every 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-rollback | Each 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 crate | Pure math: evaluate_reflex, 114-feature compute, PupGrid, fee-aware pricing, k=6 regime classifier, HARD4/TDA2/RES2 detector kernels. No I/O. |
| sim crate | Offline replay twin. Owns OrtPredictor (ONNX Runtime). Calls identical evaluate_reflex. Parity oracle asserts 100% fire-set match. |
| clob crate | Polymarket CLOB V2 wire surface: HTTP/2 client, EIP-712 V2 signer, 198-slot presign grid, canonical error classifier. |
| iceoryx2 IPC bus | 10 per-stream lock-free SHM payload services plus feature-advance notifier and boot-handshake. ~1 µs per hop, no kernel transition. |
| Dashboard | Plotly Dash operator UI on :8052, fed by ws_to_sqlite.py adapter off the bot's WebSocket broadcast. Mobile-reachable over Tailscale. |
STACK
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
