Polymarket Paper Trader

io.github.agent-next由 GitHub 帳號 agent-next 發布v0.4.13更新於 Oct 25, 2026

Polymarket paper trading for AI agents: $10k paper money, real order books, official fees.

已驗證STDIO僅桌面金融AI 與機器學習

概覽

AI 產生的概覽

讓 AI 助理以模擬資金、依據即時訂單簿與官方費率模型,在 Polymarket 和 Kalshi 預測市場進行模擬交易。

可以做什麼
建立與重設模擬帳戶,查看餘額、持倉、損益與交易紀錄,並產生統計、排行榜與帳戶對戰卡片,以及供社群平台分享的內容卡片和可驗證的排行榜提交。
適用情境
適合讓代理在零財務風險下練習、評測或比較預測市場的判斷力,也適合在真實市場資料上進行策略實驗與回測而不需要錢包。
執行需求
本機 Python 3.10+ 程序,透過 pip 或 uvx(pm-trader-mcp)執行,或自架 streamable-http 端點。取得即時行情需能連線至 Polymarket 公開 API,無需 API 金鑰。選用環境變數 PM_TRADER_DATA_DIR 與 PM_TRADER_ACCOUNT 可指定資料目錄與帳戶。
安裝前請注意
僅限模擬:沒有錢包、私鑰或真實資金,結算為模擬支付。streamable-http 傳輸沒有身分驗證,呼叫者之間也沒有隔離,任何能連上該埠的人都能呼叫所有工具並共用全部模擬帳戶;應只綁定本機或在前面加上驗證代理。backtest 與 pk_battle 會讀取本機檔案並執行本機策略模組,僅在 stdio 下提供。重設與刪除指令會清空已儲存的資料。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 Polymarket Paper Trader,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

polymarket-paper-trader

[PyPI] [PyPI downloads] [Tests] [ClawHub] [License: MIT]

A zero-risk gym for AI agents on real prediction markets — real order books, official fees, verified fill fidelity. Practice, evaluate, and benchmark decision intelligence.

Agents make probability judgments all day. Polymarket is the world's largest prediction market, and its order books are the honest scoreboard: real money, real prices, real outcomes. But you cannot hand an agent a wallet to learn with. So this project gives every agent what SWE-bench gave coders — a faithful environment where judgment has consequences and gets scored:

  • Practice — your agent trades $10k of paper money against live Polymarket order books, with the same fee model and fill mechanics as the real exchange
  • Evaluate — the polymarket-benchmark harness in this repository (installed separately) scores any model on prediction-market decision sets (Brier score, calibration, alpha)
  • Compare — multi-account battles and leaderboards rank agents against each other
  • Compete — Forecast Arena: the live public leaderboard where AI models and simple baselines forecast the same Polymarket questions daily and are scored by real outcomes (Brier score). Runs from this repo (enter your model · workflow · raw data).

Part of agent-next — building an agentic world.

60-second demo

bash
pip install polymarket-paper-traderpm-trader init --balance 10000                 # $10k paper moneypm-trader markets search "bitcoin"             # find marketspm-trader buy will-bitcoin-hit-100k yes 500    # buy $500 of YESpm-trader stats --card                         # shareable stats card

Prefer not to install? uvx --from polymarket-paper-trader pm-trader-mcp runs the MCP server your agent connects to (see Works with below).

That's it. Your AI agent is now trading Polymarket with zero risk.

Install

bash
# via pip (CLI + MCP server)pip install polymarket-paper-trader
# or the MCP server alone, with no installuvx --from polymarket-paper-trader pm-trader-mcp
# from source (development)uv pip install -e ".[dev]"

Requires Python 3.10+.

Works with

RuntimeOne-line install
Claude Code/plugin marketplace add agent-next/polymarket-paper-trader
Codex CLIcodex mcp add polymarket-paper-trader -- uvx --from polymarket-paper-trader pm-trader-mcp
Cursor[Add to Cursor]
Gemini CLIgemini extensions install https://github.com/agent-next/polymarket-paper-trader
OpenCode / Goose / Cline / Windsurf / Copilotadd pm-trader-mcp to the client's MCP config
OpenClaw / ClawHubnpx clawhub install polymarket-paper-trader
Hermes Agent / LangChain / OpenAI Agents SDK / CrewAIwrap uvx --from polymarket-paper-trader pm-trader-mcp
ChatGPT / Claude.ai (remote MCP)add the remote /mcp URL in the host's remote-MCP settings

Full copy-paste config for every runtime above (plus Grok/xAI remote MCP): docs/integrations.md. Hosts that implement MCP Apps render portfolio and stats as an inline dashboard; every other host gets the same text result.

Use it from ChatGPT / Claude.ai / personal agents

Remote mode exists for hosts that only speak HTTP: run pm-trader-mcp --transport streamable-http with the opt-in --auth-issuer, --auth-audience and --resource-url flags, then add your server's /mcp URL in the host's remote-MCP settings. It is off by default, and it needs an OAuth/OIDC issuer you operate — pm-trader verifies bearer tokens against it and gives every verified subject its own paper accounts. There is no hosted endpoint to add: you run the server yourself. Setup, threat model and the environment equivalents: docs/remote-mcp.md.

Quick start

bash
# Initialize with $10k paper balancepm-trader init --balance 10000
# Browse marketspm-trader markets list --sort liquiditypm-trader markets search "bitcoin"
# Tradepm-trader buy will-bitcoin-hit-100k yes 100      # buy $100 of YESpm-trader sell will-bitcoin-hit-100k yes 50       # sell 50 shares
# Check portfolio and P&Lpm-trader portfoliopm-trader stats

How it works — and why to trust it

  • Your order walks the real book. A buy consumes live ask levels from the lowest price upward, exactly like a real taker order — slippage is real and reported in basis points
  • Fees follow the official per-match curve — fee = C × rate × p × (1-p), rounded to 5 decimals, makers exempt (exact spec in the CHANGELOG) — charged per filled level from each market's published fee schedule, not an approximation
  • Paper cash, real discipline. Resting buys reserve their cash, partial fills keep their remainder open, closed or paused markets reject trades, and limit prices are validated against tick size
  • Resolution pays $1/share. Call resolve (or resolve --all) when a market closes and winners pay out like the real thing
  • Verified fidelity. The live test suite asserts that simulated fills land inside the band of prices the market actually quoted (Data API v2 price history) and that fees match the official curve exactly — run against real APIs on CI
  • Upstream-aligned. The client tracks the current Gamma / CLOB / Data API surface, contract-verified by live probes
  • Multi-outcome markets — any number of outcomes, not just YES/NO
  • Kalshi too. Paper trade Kalshi markets with the same commands and tools by passing a kalshi:<ticker> slug (pm-trader buy kalshi:KXNBAGAME-26OCT16DENLAL-LAL yes 25); find them with kalshi markets. Fees follow each series' published curve (docs/kalshi.md)
  • 100% coverage gate on the core package, plus end-to-end tests against the live API

CLI commands

CommandDescription
init [--balance N]Create paper trading account
balanceShow cash, reserved/available cash, positions value, total P&L
reset --confirmWipe all data
markets list [--limit N] [--sort volume|liquidity]Browse active markets
markets search QUERYFull-text market search
markets get SLUGMarket details
markets tagsList all market categories/tags
markets event SLUGEvent details — a group of related markets
price SLUGYES/NO midpoints and spread
book SLUG [--depth N]Order book snapshot
watch SLUG [SLUG...] [--outcome yes|no]Monitor live prices
buy SLUG OUTCOME AMOUNT [--type fok|fak]Buy at market price
sell SLUG OUTCOME SHARES [--type fok|fak]Sell at market price
portfolioOpen positions with live prices
history [--limit N]Trade history
kalshi markets [--limit N] [--status open|closed|settled] [--series T] [--event T]Kalshi markets (read-only)
kalshi market TICKEROne Kalshi market (read-only)
kalshi book TICKER [--depth N]Kalshi YES order book (read-only)
orders place SLUG OUTCOME SIDE AMOUNT PRICELimit order (GTC/GTD)
orders listOpen limit orders (pending and partially filled)
orders cancel IDCancel a limit order
orders cancel-allCancel all pending limit orders at once
orders checkFill limit orders if price crosses
stats [--card|--tweet|--plain]Win rate, ROI, profit, max drawdown
resolve [SLUG] [--all]Resolve a closed market, or all closed markets (winners get $1/share)
leaderboardLocal account rankings
pk ACCOUNT_A ACCOUNT_BBattle: who's the better trader?
export trades [--format csv|json]Export trade history
export positions [--format csv|json]Export positions
strategy run MODULE.FUNCRun a trading strategy
strategy compare ACCT1 ACCT2Compare account performance
strategy pk STRAT_A STRAT_BBattle: who's the better trader?
benchmark run MODULE.FUNCAlias of strategy run
benchmark compare ACCT1 ACCT2Alias of strategy compare
benchmark pk STRAT_A STRAT_BAlias of strategy pk
accounts listList named accounts
accounts create NAMECreate account for A/B testing
accounts delete NAME --confirmDelete a named account and all its data
mcpStart MCP server (stdio transport)

Global flags: --data-dir PATH, --account NAME (or env vars PM_TRADER_DATA_DIR, PM_TRADER_ACCOUNT).

MCP server — what your agent can do

Your agent gets the following tools via the Model Context Protocol. The server also carries the full trading playbook with it — as MCP server instructions, as a trading_playbook prompt, and as a skill://trading-playbook resource — so MCP-only clients (Cursor, Claude.ai connectors, Grok API remote MCP, ChatGPT apps) get the same guidance skill-aware agents get from skill/polymarket-paper-trader/SKILL.md.

bash
pm-trader-mcp  # starts on stdio
# or, with no local install:uvx --from polymarket-paper-trader pm-trader-mcp

Add to your Claude Code config:

json
{  "mcpServers": {    "polymarket-paper-trader": {      "command": "pm-trader-mcp"    }  }}

Remote transport (streamable-http)

For MCP clients that only speak HTTP, run the server with --transport streamable-http:

bash
pm-trader-mcp --transport streamable-http --host 127.0.0.1 --port 8000# or: pm-trader mcp --transport streamable-http --host 127.0.0.1 --port 8000

The MCP endpoint is then http://<host>:<port>/mcp. There is no isolation between callers — everyone who reaches the server shares all of its paper accounts; it is self-host-only, not a public multi-user service. There is no authentication on this transport; anyone who can reach the port can call every exposed tool. backtest and pk_battle (local file reads + local strategy-module execution) are stdio-only and are not registered when serving over streamable-http.

Docker

bash
docker build -t pm-trader-mcp .docker run -p 127.0.0.1:8000:8000 -v pm-trader-data:/root/.pm-trader pm-trader-mcp

Publish the port to 127.0.0.1 only (as above) unless you put a real authenticating proxy in front of it — the container has no auth of its own.

MCP tools

ToolWhat it does
init_accountCreate paper account with starting balance
get_balanceCash, reserved/available cash, positions value, total P&L
reset_accountWipe all data and start fresh
search_marketsFind markets by keyword
list_marketsBrowse markets sorted by volume/liquidity
get_tagsAll market categories/tags for filtering
get_markets_by_tagMarkets in a specific category/tag
get_eventEvent details — a group of related markets
get_marketMarket details with outcomes and prices
get_order_bookLive order book snapshot (bids + asks)
kalshi_marketsKalshi markets, read-only (open/closed/settled, by series or event)
kalshi_marketOne Kalshi market by ticker, read-only
kalshi_bookLive Kalshi YES order book, read-only
watch_pricesMonitor prices for multiple markets
buyBuy shares at best available prices
sellSell shares at best available prices
portfolioOpen positions with live valuations and P&L
historyRecent trade log with execution details
place_limit_orderLimit order — stays open until filled or cancelled/expired
list_ordersPending limit orders
cancel_orderCancel a pending order
cancel_all_ordersCancel all pending limit orders at once
check_ordersExecute pending orders against live prices
statsWin rate, ROI, profit, max drawdown
resolveResolve a closed market (winners get $1/share)
resolve_allResolve all closed markets
backtestBacktest a strategy against historical snapshots (stdio only)
stats_cardShareable stats card (tweet/markdown/plain)
share_contentPlatform-specific content (twitter/telegram/discord)
leaderboard_entryGenerate verifiable leaderboard submission
leaderboard_cardTop 10 ranking card from all local accounts
pk_cardHead-to-head comparison between two accounts
pk_battleRun two strategies head-to-head, auto-compare (stdio only)

Strategy examples

Three ready-to-use strategies in examples/:

Momentum (examples/momentum.py)

Buys when YES price crosses above 0.55, takes profit at 0.70, stops loss at 0.35.

bash
pm-trader strategy run examples.momentum.run

Mean reversion (examples/mean_reversion.py)

Buys when YES price drops 12+ cents below 0.50 fair value, sells when it reverts.

bash
pm-trader strategy run examples.mean_reversion.run

Limit grid (examples/limit_grid.py)

Places a grid of limit buy orders below current price with take-profit sells above.

bash
pm-trader strategy run examples.limit_grid.run

Jev edge (examples/jev_edge.py)

"Jev vs the market": asks Jev for a YES probability per binary market and buys the side it favors, skipping markets priced outside [0.05, 0.95] where fees dominate — pm-trader strategy run examples.jev_edge.run (needs pip install -e "benchmark").

Writing your own strategy

Strategies are imported from the examples. package (the allowlist lives in pm_trader/benchmark.py), so drop your file there:

python
# examples/my_strategy.pyfrom pm_trader.engine import Engine
def run(engine: Engine) -> None:    """Your strategy receives a fully initialized Engine."""    markets = engine.api.search_markets("crypto")    for market in markets:        if market.closed or market.yes_price < 0.3:            continue        engine.buy(market.slug, "yes", 100.0)
bash
pm-trader strategy run examples.my_strategy.run

For backtesting with historical data:

python
def backtest_strategy(engine, snapshot, prices):    """Called once per historical price snapshot."""    if snapshot.midpoint > 0.6:        engine.buy(snapshot.market_slug, snapshot.outcome, 50.0)

Evaluate your agent: polymarket-benchmark

The paper trader is the gym; the polymarket-benchmark package in this repository is the scoreboard. It is a separate install (not part of the pm-trader CLI — pm-trader strategy replays trading strategies (pm-trader benchmark remains as an alias), see the CLI table above):

bash
pip install -e "benchmark[dev]"cd benchmark && polymarket-benchmark run --model opencode/jev-1.13-free --market-set mini

Run two models head-to-head to see whose judgment is actually better. Market sets, scoring (Brier, calibration, alpha) and model setup: benchmark/README.md.

Multi-account support

Run parallel strategies with isolated accounts:

bash
pm-trader --account aggressive init --balance 5000pm-trader --account conservative init --balance 5000
pm-trader --account aggressive buy some-market yes 500pm-trader --account conservative buy some-market yes 100
pm-trader strategy compare aggressive conservative

Share your results

Generate a shareable stats card and post to X/Twitter:

bash
pm-trader stats --tweet    # X/Twitter optimizedpm-trader stats --card     # markdown for Telegram/Discordpm-trader stats --plain    # plain text

AI agents can use the stats_card MCP tool to generate and share cards automatically.

Honest limits

  • Paper only. No wallet, no keys, no real trades, no real money — ever. Resolution payouts are simulated $1/share
  • Simulation quality is verified against live order books and price history, but real execution adds queue position, latency, and counterparty behavior no simulator can promise
  • Live market data needs network access to Polymarket's public APIs (no key required)

OpenClaw / ClawHub

Available on ClawHub as polymarket-paper-trader:

bash
npx clawhub install polymarket-paper-trader

GitHub bot

Comment /oc or /opencode on an issue or PR. New issues get a triage reply; non-draft PRs get a shallow review. Implementation starts only if a human adds bot:implement or comments /oc implement (FreeInference deepseek-v4-flash; the implement push uses GITHUB_TOKEN scoped to contents/issues/PRs only — no Actions access — so a separate dispatch-tests job, the only job holding actions: write, re-validates the pushed branch ref, verifies .github/workflows/test.yml on that ref is identical to the default branch, then runs gh workflow run Tests --ref — token pushes do not trigger CI). Merging is always manual: the bot never merges, and required checks are enforced by branch protection. Q&A / triage / review stay on qwen3.6-35b. No wallet, no real trades. Sessions are not shared.

Also in this repository

The paper-trader is the product; three companion packages live alongside it.

PackageDirectoryWhat it is
polymarket-benchmarkbenchmark/LLM evaluation harness — see Evaluate your agent
polymarket-leaderboard-clientleaderboard-client/Client SDK for a compatible leaderboard server: register an agent, trade, read portfolio and stats.
polymarket-leaderboardleaderboard-server/FastAPI leaderboard service for agents — accounts, trading, rankings, and a small website

See CONTRIBUTING.md for how to work on each package and CHANGELOG.md for release history.

Tests

bash
pytest -m "not live"             # unit + integration, 100% coverage gatepytest                           # full suite (requires network)pytest tests/test_e2e_live.py    # live API integration tests only

License

MIT

來源:README.md,提交 55bb35b

工具

0
SourceWeft 尚未在沙箱中啟動過該軟體包,因此其工具未知。

版本歷史

8
  1. v0.4.13最新Oct 16, 2026
  2. v0.4.12Oct 15, 2026
  3. v0.4.11Oct 15, 2026
  4. v0.4.10Oct 15, 2026
  5. v0.4.8Oct 14, 2026
  6. v0.4.5Oct 1, 2026
  7. v0.4.2Sep 29, 2026
  8. v0.4.1Sep 26, 2026

評分

已滿足適用檢查項的 50%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分

    請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。

  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具15 分

    請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。

  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分