BTC's back at $80k — so I built an autonomous AI trader for crypto up/down markets

Sep 27, 2026

In August 2026, Bitcoin crawled back to $80,000. I'd been away from crypto for a while, but that number kept pulling me back — and this time I didn't just want to watch it. I wanted to build something that could act on it around the clock. The timing felt right: we're deep in the agentic era, where an LLM can do the thinking if you hand it the right guardrails. So I set out to build an autonomous money machine — an AI agent that trades BTC, ETH, and SOL up/down markets on prediction markets, 24/7, without me babysitting it.

This is the story of what I built, and what going from paper to real money taught me.

The idea

Polymarket's crypto up/down markets are the simplest bet in prediction markets: "Will BTC be above $X at 4pm ET?" Resolve "Up" or "Down," collect $1.00 per share if you're right. They roll every 5 minutes, 15 minutes, 4 hours, and daily, across BTC, ETH, and SOL — which means there's always a fresh market, always a price moving, and always a decision to make.

That's also the problem. Prediction markets trade 24/7, and any edge decays the moment you stop watching. I don't want to watch a market 24/7. I want a machine that watches for me, experiments to find an edge, and tells me how it's doing — without me babysitting it. That's the whole product.

The architecture

Three planes, kept strictly apart:

Execution plane (deterministic, boring, audited)
  market data: Polymarket Gamma + CLOB, Binance, Chainlink TWAP
  fill simulator · risk governor · executor · SQLite journal
        ▲
        │  structured proposals only
Decision plane (LLM, sandboxed)
  edge evaluator → order proposer  (OpenRouter / DeepSeek)
        ▲
Ops plane
  health · anomaly · self-review · Telegram digests

The rule that makes it safe: the LLM advises, deterministic code executes. The LLM never holds keys and never places an order. It emits a structured proposal, and the execution plane validates it against a risk governor — position limits, a daily loss cap, and a kill-switch — before anything touches the book. The LLM's freedom is in thinking; only that deterministic layer can spend money.

Paper first

I built the boring parts before anything exciting: adapters for market data (Polymarket Gamma and CLOB, Binance, and Chainlink TWAP), a fill simulator that models fees, slippage, and liquidity, and an append-only decision journal in SQLite that records every signal → decision → fill → outcome → reflection. The journal is the whole point — without an honest log, you can't tell an edge from a lucky month.

Paper trading needs no keys. The simulator fills against the real book, the journal accumulates, and after a few days I had a number to look at. On the VPS, paper printed +$395.76 over ~64.5 hours, driven almost entirely by the arbitrage strategy (+$463.45, profit factor 1.12), with the snipe and LLM paths turned off.

Encouraging. So I built the actual strategies.

The strategies

The first real idea was a split/merge arbitrage: in a two-outcome market, buying "YES" and "NO" should always cost $1.00 — but liquidity isn't symmetric, so sometimes YES + NO is available for less than a dollar, and the pair redeems for a full dollar. That's the classic arb.

I built two ways to play it:

  • Taker arb — cross the spread with fill-or-kill orders on both legs at once.
  • Maker arb — post passive, post-only bids on both sides and merge any filled pair back to $1.00. Slower, but it earns the spread instead of paying it.

On top of that, a two-tier LLM advisor: a fast, cheap model for the quick 5m/15m windows and a slower, deeper model for the 4h and daily ones. Plus a reflection loop — after every resolved trade, the agent writes one short reflection and re-injects it into the next decision, so it learns from its own record.

Going live

Paper is a sandbox. Real money lives on a VPS, 24/7, without me. And before I put a single dollar on the book, I had to answer the question I'd been avoiding: who am I racing?

Polymarket's order book got fast while I was away. The taker delay is now 50 milliseconds (down from 250), matching is off-chain, and settlement lands on Polygon a couple of seconds later. The exchange's origin lives in eu-west-2 (London) — but London is close-only for API traders, so nobody can legally co-locate there. The closest API-open hub is Dublin, about 10–20ms of cable away. My first box sat ~82ms out, which in a 50ms race isn't "behind" — it's not even on the track.

So I closed the gap as far as I could. I moved the trading process to a Dublin box (~19ms TCP, ~32.5ms WebSocket round-trip), instrumented every hop with p50/p95/p99 latency telemetry, replaced the 30-second poll with an event-driven WebSocket fast path that reacts to book updates the instant they arrive, subscribed to incremental price_change/best_bid_ask events instead of full-book snapshots, batched both arb legs into a single POST /orders round-trip, and scrubbed the hot path until there was nothing left but the decision — no SQLite re-query, no print().

Then I wired it to systemd so it restarts itself (Herdr on top for visibility), traded through a deposit wallet so the hot path stays gasless, and armed it with tight limits: $10 orders, a $5 daily loss cap, two positions max.

Polymarket agent terminal view showing open positions and running P&L

The agent's terminal view mid-run: open positions and running P&L, ticking in real time on the box.

That's when paper and live started to disagree.

The paper-to-live gap

The paper numbers and the live numbers told two different stories:

WhatPaper (sim/replay)Live
Maker, 4h/daily+$162.01 optimistic, +$112 to +$162 across realism knobs-$6.51/day, then kill-switched
Taker arb+$463.45 over 64.5h (PF 1.12)≈ -$5.60 on day one
Realized P&L+$395.76 (journal)-$46.74 on-chain (journal read -$2.73)

Three failures, each one a lesson.

The taker arb was structurally broken in live. Fill-or-kill means all-or-nothing on a moving book. Live, one leg would fill and the other wouldn't — a "naked leg." The fill log told the story in shorthand: SOL 6, ETH 3, BTC 0. When I did get filled, it was only half the pair — the YES leg crossed, the NO leg came back fok_not_filled, the unwind failed, and I was left holding a naked directional bet that resolved against me. Five dead legs lost about $14.56; three wins paid $8.96. My simulator assumed an order fills when it crosses the price; real FOK orders don't care about my model.

And the competition is merciless here. Every attempt pays the taker fee on both legs — roughly 0.07 × p × (1 − p) each — before I've earned a cent, so the edge I'm racing for is whatever's left after two fees. When only one leg fills, there's no consolation prize: I keep the losing side and pay for the privilege. One unwind failure was a race against my own code — the SELL leg fired before its BUY's shares had settled (balance: 0). The other, fok_not_filled, was the market simply having no buyer for my NO leg on a thin book. One I could fix; the other is just what happens when you're not the fastest person on the book.

The maker looked profitable in replay but lost in live. The maker was my answer to the latency race: skip the race entirely. Instead of crossing the spread, post passive, post-only bids on both sides, pay zero taker fee, and merge any complete pair back to $1.00. You don't need to be first — you need to be present with a good quote. Elegant, right? In its first ~22 hours live it placed 216 orders — 108 pairs — and merged zero of them. 62 winning legs redeemed to $1.00; 20 losing legs were held to zero. Net: -$40.23, about -6.5% on turnover.

The reason is the same opponent in a different costume. On 5m/15m markets, informed sellers were dumping the about-to-lose side into my resting bids — the market converges one-sided, the pair never completes, and every fill is a naked bet against someone who knows more than I do. That's adverse selection, and it's the maker's version of the taker's race: the spread you earn is exactly the premium for eating someone else's unwanted risk.

So I moved the maker to 4h/daily markets, where two-way flow means pairs can complete. Replaying ~2.4 days of real order-book snapshots, the passive maker earned +$162.01 (130 merged pairs, 13 naked legs) — and it stayed positive (+$112 to +$162) no matter how I dialed up the pessimism: queue priority, partial fills, marking naked legs to zero. Live, the same strategy lost -$6.51 a day. The gap wasn't a bug I could model away; it was the difference between a simulator and a market.

The journal was lying — and the kill-switch believed it. When I finally reconciled against the blockchain directly, I found the journal had seen only 24 of 245 fills and 23 of 122 redemptions — roughly 90% of on-chain activity was invisible to it. The kill-switch read the journal, so the circuit breaker that was supposed to stop the bleeding watched a screen that showed almost nothing. The bot traded blind. The journal said -$2.73; the chain said -$46.74.

⚠️

That last number is the honest one. The maker is currently kill-switch-halted (zero orders), and it stays that way until live data — not another model — shows a real edge.

What I learned

  • Your simulator is an optimist. A fill model without queue priority and partial fills will flatter every fast-market strategy. Treat every paper number as an upper bound, not a forecast.
  • Reconcile on-chain. The journal is a model of reality, not reality. True P&L is the signed sum of on-chain cash flows — nothing else counts.
  • A kill-switch is only as good as the source it reads. Gate on ground truth, not on the thing the bot itself writes.
  • Adverse selection is the real opponent. On one-sided 5m/15m markets, the pair never completes, so you keep the losing leg. That's a market-selection problem, not a code problem.
  • Competition shows up in the spread. Taker or maker, there's someone faster or better-informed on the other side of every fill. The fee you pay — or the spread you earn — is the price of that asymmetry, and on a thin book it's usually you paying it.
  • Measure first, then risk. Re-arm or scale only if live profit factor clears a bar (≥ 1.1) — not because a replay says it should work.
  • The seams paid off. Because the LLM only ever advised, and the executor was a paper/live seam, every bad call was a bounded loss — never a catastrophic one.

The agentic-era lesson is smaller than "AI trades crypto": the hard part isn't teaching an LLM to have an opinion — it's building the boring, auditable machinery around it so that opinion can't do more damage than you've already agreed to lose. The money machine runs. It just, so far, mostly tells me the truth.

Anthony Nguyen · llms.txt