Free playbooks in your inbox
Hands-on tutorials for people who want to build with AI.

Build a Polymarket Prediction Market Bot With Claude

Build a Polymarket prediction market bot: pull live contracts from the public Gamma API, have Claude estimate true probability, flag 10-point mispricings by EV.

From the youcanbuildthings catalog ▸ Build-tested 9 min read

Summary:

  1. Pull live Polymarket contracts from the public Gamma API, no auth required.
  2. Have Claude estimate the true probability, then compute expected value vs the market price.
  3. Flag only 10-point-plus mispricings at HIGH or MEDIUM confidence; the bot reads, you bet manually.
  4. Copy-paste the Gamma fetch, the EV math, and a runnable request you can fire right now.

A Polymarket prediction market bot has one job: find contracts where your probability estimate disagrees with the crowd’s by enough to matter. The crowd on prediction markets is mostly retail bettors reacting to headlines. The analytical bar is low. That gap is the entire game.

Here is the trade that sold me on it. A Polymarket contract asked whether the Fed would cut rates at the March 18, 2026 meeting. The market priced YES (a cut) at 35%. I asked Claude to estimate it from the actual data: the Cleveland Fed nowcast had Q1 GDP tracking 2.1%, February payrolls came in at +206K, unemployment at 4.1%. Claude estimated 18%. A 17-percentage-point gap.

Polymarket Fed-rate-cut case study: market priced a March cut at 35%, Claude estimated 18%, a 17-point gap; bought NO at $0.65, $110 became $169, a 54% return in 3 weeks when the Fed held rates

I bought 169 shares of the NO contract at $0.65 each. Total cost: $110. The Fed held rates on March 18 with one dissent (Governor Stephen Miran). NO settled at $1.00. My $110 became $169. A 54% return in three weeks, on a market that over-priced the cut because most bettors were anchored on old rate-cut headlines.

How does the analyzer work?

It scans the contract marketplace, scores every analyzable contract, and writes a ranked list to disk. It never places a bet. You place bets manually after KYC. The bot reads.

Five steps: fetch active contracts, filter to ones public data can inform, ask Claude for a true-probability estimate, compute expected value, rank and save the 10-point-plus mispricings.

You do not type the analyzer. Paste this into Claude Code and it writes prediction/prediction_analyzer.py for you:

Build me a read-only prediction-market analyzer for Polymarket.
1. Fetch active contracts from the Gamma API
   (gamma-api.polymarket.com/markets?active=true&closed=false&limit=100).
   Public, no auth. YES probability = float(outcomePrices[0])
   (may be a JSON-encoded string; parse both forms).
2. Filter to economic, corporate, political, market-level contracts.
3. Ask Claude (claude-sonnet-4-6) for true probability from base
   rates only; force confidence=LOW on time-sensitive questions.
4. Compute expected value vs market price.
5. Flag gap >= 10 points AND confidence HIGH/MEDIUM. Save the
   ranked list. Do NOT submit any orders.

How do you fetch live contracts?

You hit Polymarket’s Gamma Markets API, the public discovery endpoint. No auth. This is the exact call the bot makes, and you can run it right now:

import requests, json

def get_active_markets():
    r = requests.get(
        "https://gamma-api.polymarket.com/markets",
        params={"active": "true", "closed": "false", "limit": 100},
        timeout=15,
    )
    return r.json() if r.status_code == 200 else []

# YES probability is outcomePrices[0]. It may arrive as a
# JSON-encoded string, so parse defensively:
def yes_price(m):
    raw = m.get("outcomePrices", [])
    if isinstance(raw, str):
        raw = json.loads(raw)
    return float(raw[0]) if raw else 0.5

Want to confirm it is one unauthenticated call before writing any Python? Fire this:

curl -s "https://gamma-api.polymarket.com/markets?active=true&closed=false&limit=3" | head -c 400

Note the booleans are the strings "true"/"false", not Python booleans. There is no current_price field. The YES probability is outcomePrices[0]. Here is what that endpoint returned on a live pull:

Market (question)YES %Volume ($)
US x Iran permanent peace deal by May 31, 2026?8%$26,025K
Israel x Syria security agreement by June 30?6%$7,882K
Will Reza Pahlavi lead Iran in 2026?7%$3,514K
Spurs vs. Thunder32%$1,304K
Spread: Arsenal FC (-2.5)50%$867K

Source: Polymarket Gamma API (public, no auth, fetched 2026-05-18). Prices move, so re-pull when you run it. The point is that the data is one unauthenticated GET away.

How does Claude score a contract?

It estimates the true probability from base rates and structural reasoning, then you compute expected value. The standalone script has no web search, so the prompt forces LOW confidence on anything time-sensitive and the analyzer drops those.

def expected_value(prob, price):
    ev_yes = (prob * 1.0) - price
    ev_no  = ((1 - prob) * 1.0) - (1 - price)
    if ev_yes > ev_no and ev_yes > 0:
        return {"side": "YES", "ev": ev_yes, "gap": prob - price}
    if ev_no > 0:
        return {"side": "NO", "ev": ev_no, "gap": (1 - prob) - (1 - price)}
    return {"side": "SKIP", "ev": 0, "gap": 0}

The Fed trade in numbers: Claude estimated 18% (NO at 82%), the market had NO at 65%. Buying NO at $0.65 with a true probability near 82% is positive expected value by a wide margin. The analyzer flags a contract only when the gap is 10 points or more and confidence is HIGH or MEDIUM. A flagged opportunity prints like this:

PREDICTION MARKET OPPORTUNITIES
1. Will the Fed cut rates at the March FOMC?
   Market: 35% | Our estimate: 18% | Gap: -17%
   Side: BUY NO | EV: $0.17/share | Confidence: MEDIUM
   Reasoning: Cleveland Fed nowcast Q1 GDP 2.1%, payrolls
   +206K, unemployment 4.1%. Market anchored on old cut headlines.

What broke

My first version asked Claude to “list the top 20 Polymarket contracts.” It returned twenty beautifully formatted, completely fake contracts. Invented questions, invented prices. The vanilla Messages API has no live data, so it fabricated a marketplace. The rest of the script then processed fiction as truth.

The second trap was regulatory and it is current. Older Polymarket guides say “no KYC, log in with a crypto wallet.” That model is gone for US users. Polymarket’s US version relaunched as a CFTC Designated Contract Market. US users now complete KYC and trade through approved brokers. The Gamma API still serves public market data without auth, which is why the analyzer is read-only. Placing a real bet needs a Polygon-chain wallet funded through the broker layer, or the official py-clob-client library. If a guide tells you to skip KYC, it is describing a Polymarket that no longer exists.

Where does Claude have the most edge?

Not everywhere. Rank the markets by how much public data can inform them:

  • Economic data releases (biggest edge). CPI, jobs, GDP, Fed decisions. Claude reads the Cleveland Fed nowcast and ADP while bettors react to headlines. Estimates ran 8 to 15 points closer to reality than market price in calibration tracking.
  • Corporate earnings beats. Analyst consensus plus revenue trends. Edge 5 to 10 points, but more efficiently priced.
  • Political events with polling. Edge swings 3 to 20 points depending on how emotional the betting is.
  • Crypto price targets (smallest edge). 2 to 5 points at best. Sentiment and whale flow are hard to quantify.
  • Weather, celebrity, sports without models: no edge. Skip entirely.

The Fed trade worked because it was a Tier 1 economic-data question. That is not a coincidence. It is where the analytical gap between Claude and the crowd is widest.

What should you actually do?

  • If you are in the US → expect a KYC step and broker routing. Check your state. Nevada, Tennessee, and Massachusetts had open legal actions as of this writing.
  • If the analyzer prints “no contracts found” → that is the correct answer most days. Base-rate reasoning has no business inventing a HIGH-confidence call on a marketplace full of time-sensitive questions.
  • If you want estimates on a CPI print or live election → do not use the standalone script. Use Claude Code with web search, which can cite dated sources. The saved script is the always-on filter, not the always-current researcher.
  • If you want to place bets programmatically → install py-clob-client and wire the Polygon wallet yourself. The analyzer deliberately stops at “here is the edge.”

bottom_line

  • The edge in prediction markets is structural: you are reasoning against people betting on a tweet they read at lunch.
  • Read-only by design. The script finds mispricings; KYC and a wallet are your job, not the bot’s.
  • Hunt economic-data contracts first. That is where Claude’s 17-point gaps actually show up.
Why trust this? Every youcanbuildthings guide is pulled from a build-tested book: code that ran in production before it was written down.

Frequently Asked Questions

Can a US user still trade Polymarket without KYC?+

No. Polymarket's US relaunch as a CFTC-regulated contract market ended that. US users now complete KYC and trade through approved brokers. Public market data is still open without auth.

Does the Polymarket Gamma API need an API key?+

No. The Gamma markets endpoint is public, read-only, and needs no auth. You only need a funded Polygon wallet and broker access to place real bets, which the analyzer never does.

How does the bot decide a contract is mispriced?+

It compares Claude's probability estimate to the market price and computes expected value. It flags a contract only when the gap is 10 points or more and Claude's confidence is HIGH or MEDIUM.