360 Secure SkillHub
360 安全技能中心

vike-polymarket-order-book

通过 MCP 工具、vike-data 命令行或 REST 接口,按结果 token id 获取 Polymarket 订单簿快照(买卖各最多 25 档)、市场录制统计与价格变动记录,用于计算价差、盘口深度与流动性判断,支持指定历史时刻和 24 小时内时间窗。

分类:数据
vikeio
vikeio
热度 38.71
最近更新 2026-12-02 09:59:32

安装

发给 Agent
帮我安装这个技能:npx secure-skills-cli add vikeio/vike-polymarket-order-book
兼容性
通用兼容
联网要求
需要联网
数据出网
必须出网
Metadata
name
vike-polymarket-order-book
description
The order book of one Polymarket outcome - its bid and ask ladder up to 25 levels a side right now, or as it stood at any past moment since recording began on 2026-07-25, the spread and depth read from it, and how the best bid and ask moved through a day (every change to the book; best prices recorded since 2026-11-05), plus how much of that outcome was recorded and since when. Use when the user asks "what's the spread on this Polymarket market" / "how deep is the book on Yes" / "what did the order book look like at 3pm yesterday" / "how did the bid and ask move during the debate" / "is this outcome liquid enough to trade $10k".
allowed-tools
Bash(vike-data:*)

vike-polymarket-order-book

Every call here takes an outcome token id (a long decimal number), never the market's condition_id (0x...). Get the token id of the outcome you want, by its label, from outcomes[].token_id in vike-data polymarket markets or clob_token_ids in vike-data polymarket market <condition_id> (see vike-polymarket-find-market).

Call it

Use the first of these that is available:

  1. MCP: polymarket_orderbook (token_id, optional ts, depth); polymarket_market_stats (token_id); polymarket_tape (token_id, from_ms, to_ms, event_type: "price_change", optional cursor, limit).
  2. CLI:
    T=97531408855841405410232789703119036119573635076996943730887685044477538494161
    vike-data polymarket orderbook $T --depth 5 --json                       # the book now
    vike-data polymarket orderbook $T --ts 1796087347000 --depth 5 --json    # the last full snapshot at or before that moment
    vike-data polymarket market-stats $T --json                              # recorded since when, how much
    vike-data polymarket tape --token-id $T --from-ms 1796170000000 --to-ms 1796173700000 --event-type price_change --limit 5000 --json
    
  3. curl: the credential is VIKE_API_KEY, else api_key or anon_token from ~/.vike/config.json (Windows %USERPROFILE%\.vike\config.json); with none, get a free anonymous token with curl -s -X POST https://data.vike.io/v1/anon -H 'Content-Type: application/json' -d '{"source":"skill-curl"}' and save its token there as "anon_token" (see vike-core).
    curl -s "https://data.vike.io/v1/polymarket/orderbook?token_id=$T&depth=5&ts=1796087347000" -H "X-API-KEY: $TOKEN"
    curl -s "https://data.vike.io/v1/polymarket/market_stats?token_id=$T" -H "X-API-KEY: $TOKEN"
    curl -s "https://data.vike.io/v1/polymarket/events?token_id=$T&from_ms=1796170000000&to_ms=1796173700000&event_type=price_change&limit=5000" -H "X-API-KEY: $TOKEN"
    

--depth is levels per side, 1 to 25 (default 25). --ts is epoch milliseconds; omit it for the latest book. The tape window is at most 24 hours, --to-ms exclusive; page while has_more with --cursor <next_cursor> (--limit default 100 on the CLI and MCP, 5000 on REST, at most 50,000).

Output

  • orderbook: rows as_of_ts (epoch ms, the full snapshot actually used), side (ask or bid), level (1 = best), price (a probability, 0 to 1), size (shares); all asks first, then all bids, each (side, level) once.
  • market-stats: one row: first_ms and last_ms (first and last recorded event, epoch ms), snapshots, total_events, trades, trade_volume (in SHARES, not dollars).
  • tape --event-type price_change: {events, has_more, next_cursor}, oldest first. Each row: ts (Polymarket's time) and local_ts (ours), side (buy = the bid side, sell = the ask side), price (the level that changed), size (the new size there; 0 = the level is gone), best_bid and best_ask after the change, and bids / asks (the changed level as a JSON string).

Reading

  • Spread = level 1 ask - level 1 bid; mid = their average. Depth = sum of size within N cents of the best price on each side; dollars at a level = size x price. A side can be missing (a one-sided book): then there is no spread.
  • Check as_of_ts before quoting. A full snapshot is taken now and then, not every moment: asked for 24 h ago on 2026-12-02, the snapshot used was 26 minutes older than --ts. For the book exactly at T, replay the price_change rows from as_of_ts to T over it: each row sets size at price on its side. For a quiet or finished market as_of_ts can be days old.
  • Spread over time = best_bid / best_ask of the price_change rows: one row per change, so a busy day is tens of thousands of rows (page through, or take every Nth). These two fields are recorded since 2026-11-05 18:02 UTC; before that, and on row types that do not carry them, 0 means absent, not a price of 0. For hourly or daily bars of the price itself use vike-candles.
  • --event-type book returns the full snapshots in the window (the whole ladder in bids / asks, JSON strings).
  • The tape window counts OUR receive time (local_ts); ts is Polymarket's own and can differ by milliseconds.
  • market-stats: first_ms says from when this outcome is recorded. total_events: 0 means never recorded, not quiet: re-check the token id. Recorded markets are the most active ones and the up/down series since 2026-07-25, not every Polymarket market.
  • Prices are probabilities: 0.012 = 1.2 % chance. Sizes are shares; one share pays $1 if the outcome wins.

Errors

  • that is a condition_id (0x...); this tool takes an outcome token id, ... (exit 1): you passed the market id; take a token id instead. On REST a condition id is not refused: orderbook answers [] and market_stats a row of zeros.
  • orderbook []: no snapshot at or before --ts (before recording began for this token) or a token never recorded.
  • events window too wide: ...ms requested, max 86400000ms (24h): split the window into days, or for more than a few days take the daily Parquet files (vike-pm-l2-archive, stream book_events or l1_quotes).
  • invalid event_type '...' (must be one of book, price_change, trade, tick_size_change, status).
  • REST: errors are 400 {"error": "..."}, and an unknown parameter is refused (?start= gets did you mean 'from_ms').
  • Exit code 3: the anonymous token's daily limit; tell the user to run vike-data login, do not retry.

Anti-patterns

  • Don't quote a spread without its as_of_ts.
  • Don't call a market illiquid from an empty book until market-stats shows it is recorded.
  • Don't fetch book rows to get best prices: price_change rows already carry them.

Pairs well with

  • vike-polymarket-tape - the trades that hit this book, with wallets
  • vike-pm-market-diligence - the whole one-market check this book is a part of
  • vike-pm-l2-archive - whole days of the book as Parquet
  • vike-predictfun-market-detail - the order book of a Predict.fun market