Polymarket CLOB Quant Guide: Deploy a 0%-Fee Maker & Whale Copy-Trading Bot with py-clob-client
Complete engineering walkthrough: derive Polygon L2 CLOB credentials, query Gamma condition token IDs, subscribe to whale fills, and place gasless 0%-fee EIP-712 limit orders.
3-Minute Beginner Pre-Flight Checklist
- ✓Windows/Mac computer or a $5/mo Ubuntu VPS with Python 3.10+ installed
- ✓A dedicated sub-wallet in OKX Web3 Wallet or MetaMask (never use your main cold wallet)
- ✓$50–$200 Polygon native USDC funded via OKX/Binance + ~$1 POL for initial contract approval
Never run a live trading bot on a home laptop that sleeps or drops Wi-Fi! We recommend RAKsmart Cloud VPS: (1) Choose Tokyo, Singapore, or Silicon Valley for ultra-low millisecond latency to OKX/Binance & Polygon RPCs; (2) Select Ubuntu 22.04 LTS (2 vCPU / 4GB RAM) for Docker Compose; (3) Bind your dedicated static IPv4 address to your exchange API whitelist.
Just Bought a VPS? How to Connect via SSH & Run Commands on Windows / Mac (3-Minute Guide)
Many first-time users get stuck right after buying a cloud server: 'Where do I type these terminal commands?' Follow these 5 simple steps:
• Server IPv4 Address (e.g.,
198.51.100.88কপি)• SSH Port: Usually
22কপি, or a custom security port like 22022কপি / 62134কপি shown in your panel• Username: Always
rootকপি on Ubuntu• Root Password: Your initial server password
powershellকপি, and hit Enter.• On Mac: Press Command ⌘ + Space, type
Terminalকপি, and hit Enter.ssh -p PORT root@SERVER_IPকপি (note lowercase -pকপি; omitting a custom port causes Connection refusedকপি):• Standard Port 22:
ssh -p 22 root@198.51.100.88কপি• Custom SSH Port (e.g.
62134কপি): ssh -p 62134 root@198.51.100.88কপিAre you sure you want to continue connecting (yes/no)?কপি, type the full word yesকপি and press Enter.• Prompt 2 ([!] Why doesn't the cursor move when I type my password?!): When asked for
password:কপি, Linux hides all characters (not even * asterisks appear) for security! Simply right-click in PowerShell (or press Cmd + Vকপি on Mac) to paste your password invisibly, then press Enter!root@ubuntu:~#কপি, you are inside your cloud server! Paste these setup commands once to install Docker, Git, and Python:docker compose ...কপি commands: Simply right-click to paste into your SSH window and press Enter.• For Python (
.pyকপি) scripts: Type nano bot.pyকপি and hit Enter → Right-click to paste the code → Press Ctrl + O then Enter to save → Press Ctrl + X to exit → Run nohup python3 bot.py > bot.log 2>&1 &কপি so your bot keeps running 24/7 even after you close your laptop!# 1. Update Ubuntu packages and install Git, Curl, and Python3
apt update -y && apt install -y curl git python3-pip python3-venv
# 2. One-line official Docker & Docker Compose installation
curl -fsSL https://get.docker.com | sh && systemctl enable --now docker
# 3. Verify Docker Compose is ready
docker compose version
import os
from py_clob_client.client import ClobClient
from py_clob_client.clob_types import OrderArgs, OrderType
from py_clob_client.order_builder.constants import BUY
# 1. 初始化 Polygon 主网 (chain_id=137) CLOB 客户端
HOST = "https://clob.polymarket.com"
CHAIN_ID = 137
PRIVATE_KEY = os.environ["POLY_PRIVATE_KEY"] # 仅存放于本地 .env,严禁硬编码上传 GitHub
FUNDER_ADDR = os.environ["POLY_PROXY_WALLET"] # Polymarket 代理合约钱包地址
client = ClobClient(HOST, key=PRIVATE_KEY, chain_id=CHAIN_ID, signature_type=1, funder=FUNDER_ADDR)
client.set_api_creds(client.create_or_derive_api_creds())
# 2. 半凯利公式 (Half-Kelly) 动态计算正期望值 (+EV) 下单份额
def compute_half_kelly_shares(bankroll_usdc: float, mkt_price: float, true_prob: float, max_cap: float = 0.15) -> float:
if true_prob <= mkt_price + 0.03: # 要求至少 +3% Alpha 安全边际才出手
return 0.0
full_kelly = (true_prob - mkt_price) / (1.0 - mkt_price)
alloc_pct = min(max_cap, 0.5 * full_kelly)
stake_usdc = bankroll_usdc * alloc_pct
return round(stake_usdc / mkt_price, 2)
# 3. 读取订单簿最优买一价并挂出 0% 手续费 Maker 限价单
TOKEN_ID = "21742633143463906290569050155826241533067272736897614950488156847949938836455"
book = client.get_order_book(TOKEN_ID)
best_bid = float(book.bids[0].price) if book.bids else 0.35
true_p = 0.52 # 来自 JEV / LLM 校准后的真实发生概率
shares = compute_half_kelly_shares(bankroll_usdc=1000.0, mkt_price=best_bid, true_prob=true_p)
if shares >= 5.0:
order_args = OrderArgs(price=best_bid, size=shares, side=BUY, token_id=TOKEN_ID)
signed_order = client.create_order(order_args)
resp = client.post_order(signed_order, OrderType.GTC)
print(f"[CLOB Maker] 挂单成功: price={best_bid:.2f} size={shares} resp={resp}")
Line-by-Line Plain-English Code & Command Breakdown
| Code / Command Line | Plain-English Explanation (What Does This Do?) |
|---|---|
from py_clob_client.client import ClobClient
|
Imports Polymarket's official Python SDK (pip install py-clob-clientকপি). |
CHAIN_ID = 137
|
137 is Polygon mainnet's chain ID where all Polymarket USDC contracts settle. |
PRIVATE_KEY = os.environ["POLY_PRIVATE_KEY"]
|
Reads your sub-wallet private key safely from a local .envকপি file. |
client.create_or_derive_api_creds()
|
Derives gasless L2 CLOB API credentials via EIP-712 signature. |
if true_prob <= mkt_price + 0.03: return 0.0
|
Safety filter: only trade if calibrated probability exceeds market price by at least +3%. |
alloc_pct = min(max_cap, 0.5 * full_kelly)
|
Applies Half-Kelly sizing with a hard 15% maximum cap per order. |
client.post_order(signed_order, OrderType.GTC)
|
Submits a passive Good-Til-Cancelled Maker limit order at 0% fee. |
[!] Top 3 Beginner Pitfalls & Troubleshooting Guide
✕ Pitfall 1: Confusing Market Slug with TOKEN_IDকপি
Query https://gamma-api.polymarket.com/markets?slug=<slug>কপি and copy clobTokenIds[0]কপি for YES or clobTokenIds[1]কপি for NO.
✕ Pitfall 2: Allowance / Balance not enoughকপি on First Order
Place and cancel one $1 limit order on the Polymarket web UI first so your proxy wallet approves USDC spending.
✕ Pitfall 3: Leaving Stale Limit Orders Unattended During Breaking News
Cancel and refresh resting Maker quotes every 60–90 seconds.
Step 1: Provision a Dedicated Sub-Wallet & Polygon Native USDC
Never run automated scripts with your main cold-storage seed phrase. Create an isolated sub-wallet, fund it with Polygon native USDC from OKX or Binance, and keep ~$2 in POL for initial approvals.
Step 2: Derive L2 CLOB API Credentials Locally in .envকপি
Run client.create_or_derive_api_creds()কপি once to generate your L2 API key/secret/passphrase. Lock .envকপি with chmod 600কপি and add it to .gitignoreকপি.
Step 3: Resolve clobTokenIdsকপি via Gamma REST API
Query https://gamma-api.polymarket.com/markets?slug=<market-slug>কপি to fetch clobTokenIds[0]কপি (YES token) and clobTokenIds[1]কপি (NO token).
Step 4: Post GTC Maker Limit Orders with Stale-Quote Protection
Posting passive limit orders enjoys 0% Maker fees and zero spread slippage. Always implement a 90-second heartbeat that cancels resting quotes during breaking macro announcements.
Headline Quant Guides Directory (With Reading Level, Time & Code Stack)
Start from L1 Beginner Essentials and progress to L4 Institutional Tick Backtesting. Every guide includes reading difficulty, estimated reading time, and production-ready code:
Beginner $1,000 Quant Starter Combo Deep-Dive: How Much Can You Earn Monthly Running Polymarket Penny Clipper & LP Bots?
Complete quantitative breakdown for first-time algorithmic traders starting with $1,000 USDC: ranking all 4 Polymarket open-source bot strategies by risk-adjusted edge, modeling 3 realistic monthly profit tiers ($60–$180/mo or 6%–18% monthly ROI) using 5×$200 position splitting, and enforcing the 3 iron survival rules.
Pionex Cloud AI Bots vs. Self-Hosted Polymarket Bots (CloddsBot / Grok Desk): 6 Key Differences & Dual-Engine Allocation Guide
Both are called 'quant trading bots,' yet Pionex's 16 built-in cloud bots and self-hosted open-source Polymarket bots (`CloddsBot`, `polymarket_lp_tool`, `Grok 4-Step Desk`) operate on completely different market mechanics. Pionex harvests crypto volatility and perpetual funding rates with zero code and massive liquidity capacity, while self-hosted Polymarket bots snipe $1.00 deterministic event settlement discounts and Daily LP Rewards with zero correlation to Bitcoin price swings.
Pionex AI Quantitative Trading Complete Guide: 16 Free Built-In Grid Bots, Funding-Rate Arbitrage & Polymarket Delta Hedging
Don't want to maintain a Linux VPS? Master Pionex's 16 free built-in AI trading bots (PionexGPT strategy generator, AI Infinity Grid, Spot-Futures Funding Rate Arbitrage, and 0.05% maker/taker fees) and learn how to pair Pionex BTC/ETH grids with Polymarket event tail-hedges.
CloddsBot & Polymarket LP Bot Complete Guide: Deploy 119-Skill AI Arbitrage, Penny Clipper & Daily Liquidity Rewards Bots
Why pay $5,000+ for black-box bots when the best Polymarket trading engines are MIT open-source on GitHub? Full deployment guide to `alsk1992/CloddsBot` (3.1k⭐, 119+ skills including cross-market arbitrage, Penny Clipper expiry decay, and smart-money copy trading) and `lihanyu81/polymarket_lp_tool` (passive LP market-making for daily USDC rewards).
Grok × Polymarket 4-Step Multi-Agent Trading Desk: SCAN · VERIFY · EXECUTE · EXIT Pipeline That Filters Out 90% of Bad Trades
The best agent on a quantitative trading desk has never placed a trade — its entire job is to say NO. Learn how to replace fragile single-prompt FOMO bots with an institutional 4-Agent Desk (SCAN -> VERIFY -> EXECUTE -> EXIT) for Polymarket CLOB & crypto markets: run free deterministic code filters first, invoke Grok `x_search` only on survivors, size off live cash + pool depth, and enforce 5 pre-written exit rules (`exits.py`) with full `tasks.csv` skip auditing.
Polymarket CLOB Quant Guide: Deploy a 0%-Fee Maker & Whale Copy-Trading Bot with py-clob-client
Complete engineering walkthrough: derive Polygon L2 CLOB credentials, query Gamma condition token IDs, subscribe to whale fills, and place gasless 0%-fee EIP-712 limit orders.
Quant VPS Security, API IP Whitelisting & Hard Drawdown Kill-Switch Engineering Guide
Production security checklist for quant traders: low-latency VPS selection, exchange API IP whitelisting, withdrawal-disabled keys, and automated 5% daily drawdown kill-switches.
AI LLM Probability Calibration + Half-Kelly Sizing: Step-by-Step DeepSeek / OpenAI / Ollama API Integration for +EV Orders
Complete step-by-step guide to connecting DeepSeek, OpenAI GPT-4o, or local Ollama LLMs via Python to parse breaking news into structured Bayesian likelihood ratios and Half-Kelly position sizes.
Freqtrade + FreqAI Docker Tutorial: Connect OKX / Binance, Download Historical Data & Audit Lookahead Bias
Step-by-step guide to deploying Freqtrade via Docker Compose, downloading multi-year OKX and Binance OHLCV data, running realistic fee-adjusted backtests, and running `lookahead-analysis`.
Hummingbot Market Making & Delta-Hedging Guide: Arbitraging Polymarket Odds vs. OKX / Binance Perps
How institutional desks combine Hummingbot V2 market-making controllers on OKX/Binance with Polymarket event contracts to construct delta-neutral macro volatility hedges.
NautilusTrader L2 Orderbook Backtesting Guide: Eliminating Slippage Illusions & Queue-Position Bias
How to run high-fidelity L2 orderbook tick backtests in NautilusTrader with realistic queue-position fills, latency modeling, and Walk-Forward validation.
Poly Day (p.day) — Complete Guide to Prediction Markets, Polymarket Invite Code, Kalshi vs Polymarket & Live CLOB Odds
High-volume Polymarket queries, live CLOB odds, referral code, and regulatory guides
Poly Day (p.day) is the flagship 15-language intelligence terminal for the global prediction market ecosystem. As searches for «prediction market», «what is prediction market», «polymarket gov shutdown», «polymarket president», «polymarket iran», and «clarity act polymarket» surge worldwide, Polymarket's Polygon Central Limit Order Book (CLOB) prices real-time probabilities between 1¢ and 99¢ USDC with deeper liquidity and faster price discovery than traditional polls.
Whether you are comparing «Kalshi vs Polymarket», researching «polymarket stocks» (note: Polymarket is private; traders buy event outcome shares rather than equity), querying the «polymarket api», or looking for an official «polymarket invite code» / «polymarket referral code», Poly Day (p.day) delivers 60-second orderbook telemetry, smart-money whale alerts (>75% win rate), and Half-Kelly position sizing.