Guide · Automation
How to build a trading bot for Polymarket (2026 guide)
Want to automate trading on Polymarket? This guide walks through what a bot does, the CLOB API and official clients you build on, a minimal market-making loop, the infrastructure to run it reliably, and the risk controls that keep a bug from emptying your account.
It is written for developers and quants. You will still need a live, funded account to run any of it, and a clear-eyed view of where returns really come from.
Disclosure. ReferLabs may earn a commission if you sign up through links on this page, at no extra cost to you. This does not affect our analysis.
Check availability in your jurisdiction before signing up.
What a Polymarket bot actually does
A trading bot is just software that places and manages orders faster and more consistently than you could by hand. On Polymarket, most bots fall into four archetypes:
- Market making: quote both sides of a market to earn the spread, plus a share of the platform's liquidity rewards.
- Cross-market / cross-venue arbitrage: capture price gaps between correlated markets, or between Polymarket and another venue such as Kalshi.
- Event-driven / news reaction: react to a result or headline faster than the book reprices.
- Inventory / hedging: manage and offset exposure you have taken on elsewhere.
All four sit on the same foundation: programmatic access to the order book. If the terms “bid”, “ask”, “maker” and “taker” are new, read markets explained first, then come back.
Prerequisites
Before a single line of code runs, you need the account and access set up:
- A funded account. On the international platform that means a wallet funded with USDC on Polygon; on Polymarket US it means a verified, funded US account. Our registration guide covers both.
- CLOB API access and allowances. You generate API credentials and set the on-chain token allowances that let the exchange contract move your USDC when orders fill.
- Order signing. Every order is cryptographically signed by your wallet before it is posted, so the bot needs secure access to the signing key (typically via a dedicated wallet, not your main one).
Architecture: the CLOB API and order lifecycle
Polymarket exposes trading through its CLOB API, with official clients: py-clob-client for Python and clob-client for TypeScript. You do not need to hand-roll HTTP calls; the clients wrap authentication, order construction and submission.
The order lifecycle is straightforward once you see it end to end:
- Read the book: pull current bids and asks for the market's token id.
- Build an order: outcome token, side, price and size.
- Sign it: your wallet signs the order (Polymarket uses a proxy-wallet model, so the signing wallet authorises trades against your funded balance).
- Post it: submit as a resting limit order (maker) or one that fills immediately (taker).
- Handle fills: listen for fills, update your inventory, and requote or hedge.
The maker/taker choice is the crux of bot economics: makers generally pay no fee and can earn rewards, while takers pay a fee for immediacy. A market-making bot lives almost entirely on the maker side.
Check availability in your jurisdiction before signing up.
A minimal market-making loop
The simplest useful bot quotes both sides around the mid-price, then adjusts as it accumulates inventory. The sketch below is illustrative pseudo-code to show the shape of the loop. Real bots add error handling, rate-limit backoff, partial-fill logic and the risk controls further down this page.
# Illustrative market-making loop (pseudo-code, not production-ready)
from py_clob_client.client import ClobClient
client = ClobClient(host, key=API_KEY, ...) # authenticated client
MARKET = "0x..." # token id for the Yes outcome
HALF_SPREAD = 0.02 # how far off mid we quote each side
SIZE = 50 # shares per side
MAX_INVENTORY = 500 # hard position cap
while running: # your main loop
book = client.get_order_book(MARKET)
mid = (book.best_bid + book.best_ask) / 2
inv = get_position(MARKET) # your own inventory tracker
# skew quotes against inventory so you don't pile up one side
skew = (inv / MAX_INVENTORY) * HALF_SPREAD
bid = round(mid - HALF_SPREAD - skew, 2)
ask = round(mid + HALF_SPREAD - skew, 2)
cancel_all(client, MARKET)
if inv < MAX_INVENTORY:
client.post_order(build_signed_order(MARKET, "BUY", bid, SIZE))
if inv > -MAX_INVENTORY:
client.post_order(build_signed_order(MARKET, "SELL", ask, SIZE))
sleep(REQUOTE_SECONDS) # requote on a timer or on fillsThe important idea is the inventory skew: as you accumulate Yes shares, you quote a little lower on both sides to encourage selling back down, so you earn the spread without drifting into a large directional position you never intended.
Infrastructure
A bot that only runs while your laptop is open is a liability. A minimal reliable setup:
- Hosting: a small always-on server such as an AWS EC2 instance, close to the API for low latency.
- Process management: a supervisor (systemd, pm2 or similar) that restarts the bot if it crashes.
- Monitoring and alerts: push key events and errors to a channel you actually watch, for example a Telegram bot, so you know within seconds if something breaks.
- Logging: record every order, fill and cancel so you can reconstruct what happened and measure performance.
- Secrets handling: keep API keys and the signing key out of your code, in environment variables or a secrets manager, never committed to a repo.
Risk controls and kill conditions
The fastest way to lose money with a bot is to let a bug run unattended. Hard, non-negotiable limits matter more than clever strategy:
- Max position per market and overall, enforced before every order.
- Inventory caps that stop the bot quoting the side that would breach them.
- Max drawdown: a daily or total loss limit that halts trading when hit.
- Circuit breaker / kill switch: an automatic stop on abnormal conditions (stale data, wild spreads, repeated errors) and a manual one you can trigger instantly.
Treat these as the parts you build first and test hardest. A strategy that is merely mediocre survives; a strategy with no kill switch does not.
Where the money actually comes from
For a market-making bot, returns come from two places: the spread you earn when both your quotes get filled, and the liquidity rewards Polymarket pays makers for posting competitive two-sided orders, distributed daily around midnight UTC.
Here is the honest part. Those rewards are real, but they exist to compensate for adverse selection: informed traders pick you off when the price is about to move, and naive strategies often bleed exactly what they earn in spread back to those traders. There is no durable edge you can assume, only edge you can measure. Before you scale size, read how to find and measure edge, which covers markout analysis and sizing so you can tell a real advantage from a mirage.
Frequently asked questions
What language and library should I use to build a Polymarket bot?
Polymarket provides official clients for the CLOB API: py-clob-client for Python and clob-client for TypeScript. Both wrap authentication, order construction, signing and submission, so you can focus on strategy rather than raw HTTP calls.
Do I need to run my own server?
For anything beyond experimentation, yes. A bot needs to run continuously, so host it on an always-on server such as an AWS EC2 instance, with process management to restart it on crashes and monitoring to alert you when something breaks.
How does order signing work?
Every order is cryptographically signed by your wallet before submission. Polymarket uses a proxy-wallet model, so the signing wallet authorises trades against your funded balance. Give the bot access to a dedicated signing key kept out of your codebase, not your main wallet's keys.
Can a trading bot actually be profitable?
Sometimes, but not by default. Market making earns spread and liquidity rewards, yet those returns can be given back to better-informed traders through adverse selection. Any edge must be measured with markout analysis and controlled sizing, not assumed. Build the risk controls before you chase returns.
What risk controls are essential?
At minimum: a max position per market and overall, inventory caps that stop the bot quoting a side that would breach them, a max-drawdown limit that halts trading, and both an automatic circuit breaker and a manual kill switch. Build and test these first.
Get an account to build against
Every strategy on this page needs a funded, live account and API access. Create yours, then start with the market-making loop above.
Check availability in your jurisdiction before signing up.
Continue the guide
Risk & eligibility
Trading prediction markets involves risk, including loss of your entire stake. Availability and rules vary by country and US state. 18+ only. This is general information, not financial or legal advice. Verify current terms on Polymarket's official site before trading.
This page is operated by Refer Labs and contains a disclosed affiliate referral link to Polymarket. We may earn a commission if you sign up through it, at no extra cost to you. Referral rewards, fees, and country or US-state availability are set by Polymarket, change frequently, and are described here as current at the time of writing; always confirm the current terms on Polymarket's official documentation. Our full standards are at how we research.