Skip to main content
boxmining
Menu

How to Build a Polymarket AI Trading Agent—Paper Trading First

Michael GuMichael Gu
8 min read
Trading
Prediction-market paper-trading lab with a transparent order-book ladder, outcome tokens, and a disconnected wallet vault
Contents

An AI trading agent does not need a wallet to teach you something useful. In fact, connecting money first is usually the wrong order. The difficult part is not generating a “Buy Yes” sentence. It is proving that the agent used information available at the time, understood the market rules, priced uncertainty, accounted for execution costs, and knew when not to trade.

This guide builds that safer version: a paper-trading research agent. It reads public Polymarket data, produces an auditable probability estimate, and records a simulated order. It never authenticates, signs, submits, or cancels a real order.

Polymarket’s current API is well suited to this separation. The Gamma API discovers markets and events, the Data API exposes public activity and positions, and the CLOB API exposes public order books, prices, spreads, and price history. Actual order management is authenticated. That boundary should also be the boundary in your project.

What the agent is actually trying to do

A prediction-market share trades between $0 and $1 and pays according to the resolved outcome. A price can be read as an implied probability, but it is not automatically the probability at which you can trade. Polymarket’s price and order-book guide explains that the displayed price is normally the bid-ask midpoint; a buyer pays the ask and a seller receives the bid.

The agent therefore has four separate jobs:

  1. Interpret the contract. What exact event resolves Yes? Which source decides it? What are the edge cases?
  2. Estimate probability. Based only on time-valid evidence, what is the agent’s probability for Yes?
  3. Compare with executable prices. Is the estimated edge still present at the ask or bid, after fees and simulated slippage?
  4. Choose an action. Buy Yes, buy No, wait, or abstain—and explain why.

Keeping those jobs separate makes errors visible. A strong forecast attached to the wrong resolution rule is still a bad trade.

Step 1: Create a read-only market intake

Start with active markets from the public Gamma endpoint. Polymarket’s API quickstart shows that market data requires no API key and that each market record includes clobTokenIds, normally mapping to the Yes and No outcome tokens.

For each candidate, store an immutable intake record:

market_id
question
full_description
resolution_source
end_date
outcomes
token_ids
captured_at_utc
raw_response_hash

Do not feed the title alone to the model. Polymarket explicitly tells users to read the resolution rules: the title describes the question, but the rules define how the market resolves. Your agent should refuse any market with missing, contradictory, or poorly understood rules.

The captured_at_utc and hash are important. Without them, you cannot later prove which version of a description the agent saw. Polymarket notes that rare clarifications may add context without changing the question’s fundamental intent. A serious archive preserves both the original record and later clarifications.

Step 2: Collect prices the agent could really face

For each outcome token, query the public CLOB order book. The order-book documentation returns bids, asks, tick size, minimum order size, timestamp, and a hash of book state. Save the full depth, not just the midpoint.

At minimum, calculate:

  • best bid and best ask;
  • spread: best ask - best bid;
  • depth available at each level;
  • volume-weighted simulated fill for the intended size;
  • age of the book snapshot when the decision is made.

The midpoint is useful for comparing beliefs, but it is not an executable fill. If Yes is bid at 0.43 and offered at 0.49, the midpoint is 0.46. A simulated buyer starts at 0.49, and a larger order may consume offers above it. Read When the Winning Bet Still Loses before designing your fill engine.

For live observation, Polymarket provides a public market WebSocket that streams book snapshots, price-level changes, trades, and optional best-bid/ask and resolution messages. REST snapshots are easier for a first build. WebSockets are better once you can reliably sequence, timestamp, reconnect, and detect gaps.

Step 3: Give the model a bounded research packet

An LLM should not freely browse the modern web while scoring a historical checkpoint. That creates look-ahead leakage. Instead, assemble a packet of sources captured before the decision time:

MARKET RULES
- complete description and resolution source

MARKET STATE
- timestamped order book
- timestamped price history

EVIDENCE
- source, publication time, retrieval time, excerpt

OUTPUT CONTRACT
- P(Yes), confidence range, key evidence, counter-evidence,
  unknowns, invalidation conditions, action or abstention

Require structured output. The agent should distinguish “I estimate 62%” from “I am 62% confident in my estimate”; these are not the same statement. Also require at least one reason its forecast could be wrong. A model that cannot identify disconfirming evidence should not control the next stage.

The official open-source Polymarket Agents repository is useful as an architecture reference because it includes market clients, retrieval components, and agent utilities. It also includes autonomous trading paths and credential setup. Do not copy those live-execution parts into this project. Borrow the modular thinking, not the wallet access.

Step 4: Convert a forecast into a simulated decision

Use deterministic code—not the language model—to turn the forecast into a paper order. One simple policy is:

if rules_unclear or evidence_stale or book_stale:
    abstain
else:
    yes_cost = simulated_vwap(yes_asks, paper_size) + estimated_fees
    no_cost  = simulated_vwap(no_asks, paper_size) + estimated_fees

    yes_edge = p_yes - yes_cost
    no_edge  = (1 - p_yes) - no_cost

    if max(yes_edge, no_edge) < minimum_edge:
        wait
    else:
        paper_buy(side_with_larger_edge, capped_size)

This is deliberately incomplete as a trading strategy, but it establishes the correct controls. The model proposes a probability. Code applies freshness limits, cost assumptions, minimum edge, and position caps.

Fees must be market-specific. Polymarket’s current fee documentation says taker fees apply to certain categories, are determined per market at match time, and can be identified from market fee data. Do not hard-code “Polymarket has no fees,” and do not apply a single fee rate to every historical market.

Step 5: Build an honest paper fill engine

A useful simulator should support at least three fill assumptions:

  • Conservative taker: consume the visible asks or bids immediately, level by level.
  • Passive limit: record the order as resting, but do not call it filled merely because the market later touched that price.
  • No fill: reject the simulated trade if visible depth, freshness, minimum size, or price limits fail.

The order book tells you visible aggregate size. It does not tell a historical simulator exactly where your hypothetical order would have sat in the queue. Passive fills therefore need scenarios, not certainty. Save fill_assumption beside every result.

Your ledger should contain the forecast, model version, prompt version, evidence IDs, book hash, intended size, simulated fills, fee schedule, and decision reason. Never overwrite a forecast after the event. Corrections should be appended as new records.

Step 6: Score forecasts separately from trading

Use two scoreboards:

Forecasting: Brier score, calibration by probability bucket, coverage, and abstention rate.

Paper execution: simulated P&L, spread paid, slippage, maximum exposure, drawdown, rejected orders, and rule violations.

This separation stops a lucky high-risk trade from disguising poor forecasting. Our time-locked Polymarket experiment gives a reproducible protocol for evaluating the agent without inventing results.

Geography and eligibility still matter

Paper trading does not place an order, but the educational app should not imply that every reader can progress to live trading. Polymarket maintains a current geographic restrictions page and geoblock endpoint. The list and regional statuses can change, and orders from blocked locations are rejected.

Do not suggest VPN workarounds. Do not infer eligibility from a reader’s language, nationality, or a cached country list. If you ever build a separate live product, it needs current legal review, eligibility checks, platform terms, and security controls. None of that belongs in this paper-trading tutorial.

A sensible first milestone

Do not begin with an autonomous loop. Begin with one market and one button:

  1. capture the market rules and public book;
  2. attach a small, timestamped evidence packet;
  3. ask the agent for a probability and reasons;
  4. generate one simulated fill under explicit assumptions;
  5. export a human-readable trade card.

Then try to break it. Give it stale prices, a changed rule, conflicting evidence, an empty order book, and an attractive midpoint with a wide spread. The agent earns more trust by refusing those cases than by producing another confident prediction.

For background on the venue, see our Polymarket exchange review and the wider Technical Analysis library.

Polymarket AI agent FAQ

Can I build a Polymarket AI agent without a wallet?

Yes. Public market, order-book and activity APIs support read-only research and paper trading without private keys or authenticated order-management access.

Which Polymarket APIs are useful for a paper-trading agent?

Gamma supports market discovery, the Data API exposes public activity and positions, and the CLOB API provides public order books, prices, spreads and history.

Why must an agent read Polymarket resolution rules?

The title is only a summary. Rules define the deciding source, deadline and edge cases, so misunderstanding them means forecasting the wrong contract.

Why is the midpoint not a paper fill price?

A buyer faces available asks and a seller faces bids. Spread, visible depth and size determine a realistic immediate simulated fill.

What should a bounded research packet contain?

Include complete rules, timestamped approved evidence, current market data and explicit missing or conflicting information without granting the model arbitrary browsing authority.

What output should the model produce?

Require structured probability, uncertainty, evidence references, contract interpretation and abstention reasons. Deterministic code should decide whether a paper trade passes limits.

How should a paper Polymarket order be filled?

Use explicit scenarios: consume visible depth as a conservative taker, model passive queue uncertainty, or reject when freshness, size or price protection fails.

How should Polymarket fees be simulated?

Use market-specific fee data in force at the decision time. Do not assume one universal rate or that every market is fee-free.

How should an AI prediction agent be scored?

Score forecast calibration, Brier score, coverage and abstention separately from paper P&L, spread, slippage, exposure, drawdown and policy violations.

Should a paper-trading tutorial recommend bypassing geographic restrictions?

No. Eligibility changes and requires current verification. A paper system should not imply permission for live trading or suggest VPN workarounds.

Sources and further reading

Risk disclosure: This article is educational and describes a paper-trading system only. It does not provide investment, legal, or technical-security advice. Prediction-market and crypto prices can be volatile, APIs and fee schedules can change, simulations can materially overstate executable performance, and access may be restricted in your location. Do not connect a wallet, private key, funds, or live-order endpoint to experimental agent code.

Share

Found this useful?

Share it with someone who'd want to read it.

Related