All About AI

Building a Polymarket AI Trading Bot From Scratch

I spent an afternoon building a Polymarket high-frequency AI trading bot from scratch using Claude Code. The strategy targets the Bitcoin 5-minute up/down market — the fastest-resolution market Polymarket offers — and the entire stack (wallet setup, market data, order placement, real-time React dashboard) was scaffolded by the agent. Two hours in I was up from $30 to roughly $34, every trade profitable so far. This post walks through how the bot was built, the strategy I copied, and the realistic expectations.

Watch the video:

Why the 5-minute Bitcoin market

Polymarket runs lots of long-tail prediction markets, but the highest-frequency thing they offer is the Bitcoin 5-minute up-or-down. Every 5 minutes a new market opens, you bet which direction BTC closes vs. the previous tick, and the market resolves immediately. That cadence — 288 markets a day — is what makes it interesting for a bot. There is no other place on Polymarket where you can iterate trade ideas this fast.

The strategy I am after also lines up with the format. I am not trying to predict price direction, which is hard. I am trying to scalp the late-window mispricings that show up when a market is already 95%+ certain to resolve a particular way. More on that in a second.

Setup: wallet, USDC.e, gas

The bootstrap was the easy part — Claude Code handled the wallet generation, key storage, and balance checks end to end. I made a folder, dropped a copy of the Polymarket gamma API quick-start into docs/polymarket.md, fired up Claude Code with dangerous-skip, and asked it to set up a trading wallet. Two constraints: everything goes into an .env file, and the private key never gets printed to the terminal. About a minute later I had a wallet address.

Funding takes three things:

  1. USDC.e on the Polygon network — this is what you actually trade with. I sent $30.
  2. Polygon (MATIC) — for gas. Roughly $5 worth.
  3. An approved Polymarket account — you sign up via the website with MetaMask, approve token spending, and enable auto-redeem so winnings settle automatically.

The last step is where I tripped up initially — without the CTF exchange allowance approval, the bot can technically connect but every order fails. The fix is a one-time sign-up flow on Polymarket itself; the bot just needs the resulting account address fed back into the config.

The Bone Reaper strategy

Picking a strategy is the actually hard part. I cheated. Polymarket has public leaderboards, and one trader — handle "Bone Reaper" — has been doing roughly $30K/month in profit on the 5-minute crypto markets, with a near-flat-upward equity curve over the last 30 days. Public blockchain data, public address. So I gave Claude Code the address and asked it to figure out how he trades.

This is the same pattern as my earlier Karpathy autoresearch on Polymarket work — spawn sub-agents to do broad parallel research, let them compress findings, then plan from the synthesis. After about 15 minutes of sub-agents picking through his trades the picture was clear:

It is the inverse of the gambling intuition. He is not betting on coinflips; he is selling tiny amounts of insurance against the few percent of markets that flip in the final seconds.

Translating the strategy into code

With the research synthesized, the build was standard Claude Code agent work — same general shape as my 3-part AI agent system: skill + headless model + tools. The agent scaffolded the spot-price reader, the order placement against the CTF exchange, the position tracker, the dry-run mode, and a config file with the strategy parameters.

The config knobs I ended up tuning:

One thing worth calling out: this strategy is not latency-sensitive in the way arbitrage is. My machine is far from the Polymarket servers and that has wrecked previous experiments with cross-venue arb. But "is the price above 0.95 with 20 seconds left" is not a millisecond-race decision. The bot has plenty of time to react.

The Bloomberg-style dashboard

The fun part. Once the backend was working in dry-run, I asked Claude Code to build a real-time dashboard — React + Tailwind, low-latency, Bloomberg-terminal aesthetic, with a 5-second flash on the screen whenever a trade fires. That last detail mattered more than I expected: in a 5-minute window with sub-second decisions, you cannot watch the terminal and the chart simultaneously. The flash means I can be in another tab and still notice the fill.

Dashboard surfaces I ended up wanting:

The decision log is the part you actually learn from. Most 5-minute markets do not trigger a trade — the price never gets above the 0.95 floor in the window, or it does but the time-remaining check fails. Watching the log scroll is how you build intuition for whether the parameters are tight or loose.

Live results, 2 hours in

The first trade fired about 30 seconds after I flipped from dry-run to live. The dashboard flash worked exactly as designed — buy at ~95 cents on "up", BTC held, the position resolved profitably for a few cents of edge. The next hour was more of the same: small fills, all green, no losses.

At the 2-hour mark the wallet was at roughly $34. That is $4 of profit on $30 of capital — call it 13% in two hours. Annualized, that is a number you should not take seriously, because the sample is tiny, the variance has not had a chance to bite, and one mistimed loss eats the entire run. The honest framing is: the bot worked, the strategy plumbing is correct, and the parameters are at least defensible. Whether it survives a week of running is a different question.

What I would do differently next time

A few things, in priority order:

  1. Run dry-run for longer. I went live after a single 5-minute dry pass. I should have let it dry-run for an hour to see how often it would have triggered and check the entry-price distribution.
  2. Add a daily-loss circuit breaker. The current bot will happily keep trading through a bad streak. A "kill switch at -X% of starting capital" would have made me sleep better.
  3. Log to a real database. Right now everything is JSON files. Two weeks in, I will want to query "trades by window-time-remaining bucket" and that is painful from JSON.
  4. Run two parallel parameter sets. Same wallet, two strategy configs, see which one drifts ahead. Cheaper than backtesting on synthetic data.

This is also the kind of automation that fits well into the bigger Claude Code passive-income setup — small loops, each on a clear-eyed budget, each producing real output. Whether the output is income or learning is a separate question, but the loops compound either way.

Realistic expectations

Is this going to make you rich? No. Two hours of green trades is not signal — it is variance. Even if the strategy edge is real, the per-trade edge is tiny, and the path to anything meaningful requires either (a) much more capital, or (b) many more parallel strategies. Bone Reaper makes $30K/month because he is moving roughly $1,000 per trade across 180K trades a week — that is what scale looks like when the per-trade edge is a few cents.

What it does do is teach you the actual mechanics of building an autonomous trading agent against a live market — wallet management, order placement, fill handling, position tracking, real-time monitoring — and those mechanics transfer to a lot more interesting problems than 5-minute BTC scalping. That is the actual payoff.

Resources

FAQ

How much capital do you need to start a Polymarket AI trading bot?

About $35 minimum: $30 in USDC.e for trading plus $5 in Polygon (MATIC) for gas fees. The Polymarket sign-up itself is free, but you need a funded MetaMask wallet on the Polygon network and the CTF exchange allowance approval before any order will go through.

What is the highest-frequency market on Polymarket?

The Bitcoin 5-minute up/down market — 288 fresh markets a day, resolving every 5 minutes against BTC price action. It is the only Polymarket venue where a trading bot can iterate ideas at a cadence that produces meaningful sample sizes within hours.

Is the late-window scalping strategy actually profitable?

It can be — public leaderboard data shows top traders like Bone Reaper running ~$30K/month profits on this strategy at roughly $1,000 per trade and 180K trades/week. The per-trade edge is small (a few cents), so it requires scale and tight risk parameters to be meaningful.

Does Polymarket trading latency matter for an AI bot?

Not for late-window scalping. The decision is "is the implied probability above 0.95 with ≥8 seconds left in the window" — a sub-second decision, not a millisecond race. Latency only matters for cross-venue arbitrage or true high-frequency order-book strategies.

How do you research a profitable Polymarket trader's strategy?

Polymarket settles on a public blockchain, so every trade is visible from the wallet address. Spawn Claude Code sub-agents to read the trade history, group by market type, and infer the strategy from entry price, size, and hold time. About 15 minutes of agent work produces a clear picture.

What's the biggest risk in a 5-minute Polymarket bot?

Variance. A few hours of green trades is not signal — the per-trade edge is small, and one mistimed loss in the late-resolution window can eat an entire day's gains. Add a daily-loss circuit breaker and run dry-run for at least an hour before going live.