polymarket-pnl
安装方式
先用 Prompt 核对来源与依赖。也可下载安装包。
用 AI 助手安装
复制提示词,让助手先核对固定版本和依赖。
查看 Prompt收起 Prompt
先检查当前 Agent 是否已安装 SkillPI Skill Finder。如果尚未安装,请按官方仓库的说明安装并启用:https://github.com/Findskills/skillpi。然后使用 Skill Finder 打开此 SkillPI 详情页并定位 "polymarket-pnl":https://skillpi.com/zh/skills/deepskill-736754fee42632cc7bb615270b89d6511ab4e1ccfbc38a1962ab6d4c0e62885a。安装前核对上游来源和版本:https://github.com/runesleo/polymarket-toolkit。来源不一致时停止并说明差异。核对通过后,用 Skill Finder 安装目标 Skill,并报告安装路径和来源版本。
来源与配置
github.com
配置方式待核实
请查看原始来源中的适用工具、依赖和权限要求。
安装实测待补充
polymarket-pnl:适用于任意 Polymarket 地址的精确盈亏计算器。通过 Data API 的现金流(买入/卖出/赎回/合并/拆分/返利)重建已实现盈亏,并加上未实现持仓价值。排行榜验证中与官方 /profit 接口结果的平均绝对百分比误差(MAPE)约为 0.2%。需自备 Python 环境(使用 httpx 库)。
介绍来源: third_party · runesleo · 0.3.0 参考来源
SkillPi 解读
- 能完成的任务
- 翻译待完成,请参阅来源文档。
- 输入和输出
- 翻译待完成,请参阅来源文档。
- 软件、账号及付费要求
- 翻译待完成,请参阅来源文档。
- 限制与区别
- 翻译待完成,请参阅来源文档。
- 实测状态
- 未测试
文件浏览
Frontmatter
name: polymarket-pnl
description: Precise PnL calculator for any Polymarket address — reconstructs profit/loss from Data API cashflow (BUY/SELL/REDEEM/MERGE/SPLIT/REBATE) plus unrealized position value. Matches official /profit within ~0.2% MAPE on leaderboard validation. Bring-your-own Python (httpx).
allowed-tools: Bash(python3:*) Read Write Edit
metadata: {"version":"0.3.0","openclaw":{"skillKey":"polymarket-pnl","homepage":"https://leolabs.me","requires":{"anyBins":["python3"]}}}Polymarket Precise PnL
Compute precise, audit-grade PnL for any Polymarket address via the Data API cashflow method. Unlike position-level approximations used by most profilers, this reconstructs every BUY / SELL / REDEEM / MERGE / SPLIT / REBATE event and reconciles against current unrealized position value.
Validated against Polymarket's official /profit endpoint on the public leaderboard: MAPE ~0.2%, all top accounts within 1% error.
Trigger
Invoke this skill when the user wants:
- Audit-grade PnL for one or more Polymarket addresses
- Bulk PnL over a leaderboard or an address list
- Benchmark mode: compare a local PnL dataset vs. the official /profit values
If the user just wants a quick profile (win rate, positions, category breakdown), use the polymarket-profile skill instead — it's lighter and runs on curl alone.
Requirements
python3(3.9+)- One Python package:
httpx
Install once:
pip install -r ${SKILL_DIR}/requirements.txt
# or
pip install httpx
${SKILL_DIR} is the path where this skill lives (for example, /path/to/your/agent/skills/polymarket-pnl/).
Core CLI
All invocations run from the skill directory (or with python3 <skill_dir>/compute_precise_pnl.py):
# Single address
python3 compute_precise_pnl.py --address 0x63ce342161250d705dc0b16df89036c8e5f9ba9a
# Bulk: top N on the leaderboard (auto-fetched)
python3 compute_precise_pnl.py --leaderboard 50
# Address list from a text file (one 0x per line, `#` for comments)
python3 compute_precise_pnl.py --addresses-file targets.txt
# Benchmark: compare your local PnL JSONL against the recomputed precise PnL
python3 compute_precise_pnl.py --leaderboard 100 \
--benchmark local_pnl.jsonl \
-o precise_vs_local.jsonl
Output is JSONL streamed to --output (default: ./precise_pnl.jsonl).
Output schema
Each line is one address record:
| Field | Type | Meaning |
|---|---|---|
address |
str | The lowercase 0x proxy wallet |
pnl |
float | Trading cashflow PnL (BUY/SELL/REDEEM/MERGE/SPLIT/REBATE + unrealized). Primary metric. |
pnl_inclusive |
float | pnl + REWARD + REFERRAL_REWARD + CONVERSION (platform credits) |
total_buy, total_sell, total_redeem, total_merge, total_split, total_rebate, total_reward, total_referral, total_conversion |
float | Sum of each activity type |
unrealized |
float | Current mark-to-market value of open positions |
open_positions |
int | Number of open positions |
trade_count |
int | Total BUY + SELL events |
computed_at |
int | Unix seconds when record was produced |
complete |
bool | True if every paginated activity call returned fully |
pagination_incomplete |
bool | True if the Data API's ~10k offset ceiling was hit for at least one activity type |
pagination_incomplete_types |
list[str] | None | Which activity types hit the ceiling ("BUY", "SELL", ...) |
Known limitations
- Data API offset ceiling (~10k): extremely high-frequency accounts may hit it on one activity type. The record is still emitted with
pagination_incomplete=Trueand the field list so you can flag or re-fetch via timestamp-chunked backfill. - Same-second full-page boundary: the timestamp-based pagination uses
end = oldest - 1with a heuristic backfill pass that only triggers when the boundary timestamp already appears more than once in the current page. If a full page ends with exactly one row at timestampTand additional same-second rows continue onto the next page, those rows may be skipped withoutpagination_incompletebeing set. This affects a small subset of very-high-frequency accounts; most addresses stay within 1% of the official/profit. A stricter backfill is on the roadmap. pnlvspnl_inclusivechoice: Polymarket's official/profitendpoint inconsistently includes platform credits across addresses. The primarypnlfield deliberately excludes them so the number is reproducible from public trade data alone.- Requires
httpx: the only third-party dependency, for its robust TLS/HTTP/1.1 handling against the Data API. - No authentication: uses only public endpoints (
data-api.polymarket.com,gamma-api.polymarket.com), so there are no API keys to manage but also no access to private endpoints.
Comparison with polymarket-profile
| Aspect | polymarket-profile |
polymarket-pnl (this skill) |
|---|---|---|
| Runtime | curl + jq / node | Python 3 + httpx |
| PnL accuracy | Position-level cashPnL (approximate) | Cashflow reconstruction (~0.2% MAPE) |
| Bulk mode | Single address per call | Single / leaderboard / address list |
| Win rate / categories | ✅ | ❌ (PnL only) |
| Benchmarking | ❌ | ✅ vs local dataset |
| Best for | "Who is this address?" | "What is their audit-grade PnL?" |
Use them together: polymarket-profile for the qualitative picture, polymarket-pnl when the PnL number has to hold up to scrutiny.
Data sources
All public, no authentication required:
| API | What it provides |
|---|---|
data-api.polymarket.com/activity |
BUY / SELL / REDEEM / MERGE / SPLIT / REBATE / REWARD / REFERRAL_REWARD / CONVERSION events |
data-api.polymarket.com/positions |
Current open positions, for unrealized value |
data-api.polymarket.com/v1/leaderboard |
Ranked addresses with official /profit values |
Setup
# Claude Code
export AGENT_SKILLS_DIR=/path/to/your/agent/skills
cp -R skills/polymarket-pnl "$AGENT_SKILLS_DIR/"
pip install httpx
# OpenClaw
cp -R skills/polymarket-pnl ~/.openclaw/skills/
pip install httpx
New to Polymarket? Create an account here.
License
MIT — see repository root LICENSE.
版本历史
-
v0.7.0
GitHub ↗
原版更新说明
## v0.7 — MCP server for AI agents The toolkit's read-only CLI is now available as [Model Context Protocol](https://modelcontextprotocol.io) tools: [`mcp/`](https://github.com/runesleo/polymarket-toolkit/tree/main/mcp) · [docs/mcp.md](https://github.com/runesleo/polymarket-toolkit/blob/main/docs/mcp.md) - **10 read-only tools** for Claude / Codex / Cursor / any MCP client: `pm_profile`, `pm_activity`, `pm_brier`, `pm_pnl_check`, `pm_scan`, `pm_updown`, `pm_leaderboard`, `pm_redeem_watchdog`, `pm_v2_check`, `pm_rate_limits` - **The CLI is the contract**: every tool shells out to `pm` (argv array, no shell) — the server can do exactly what the read-only CLI can do, nothing more - **Hardened**: allowlist input validation (SDK layer + independent handler re-validation), pinned activity paging, 2MB subprocess output cap, spawn concurrency limit, 60s timeout - **No trading over MCP** — order placement stays in the separate opt-in `executor/` package, human-wired only - **npm packaging**: `npx -y polymarket-toolkit-mcp` one-liner (bundled dist, Node >=20) — npm listing goes live once published Setup: ```bash claude mcp add polymarket-toolkit -- npx -y polymarket-toolkit-mcp ``` (or from source: `cd mcp && npm install && npm start`)
-
v0.6.0
GitHub ↗
原版更新说明
## v0.6 — Opt-in executor sub-package The core stays **zero-dependency, read-only, key-free**. Order execution now lives in an isolated, opt-in sub-package: [`executor/`](https://github.com/runesleo/polymarket-toolkit/tree/main/executor) · [docs/executor.md](https://github.com/runesleo/polymarket-toolkit/blob/main/docs/executor.md) ### Executor - CLOB V2 limit orders (GTC/GTD) via `@polymarket/clob-client-v2`, isolated deps — never imported by the core - **Safety ladder**: narrow façade (raw client not exposed) · dry-run by default (`EXECUTOR_LIVE=1` to post) · full canonical-field re-validation + notional cap recomputed at the boundary (`EXECUTOR_MAX_USD`, default $10) · fail-closed credential validation with redacted errors · live-call console redaction (the underlying client logs auth headers on HTTP errors) - Builder attribution end-to-end: default / override / opt-out, resolved once per instance; dry-run preview matches live behavior. Disclosure: [docs/builder-attribution.md](https://github.com/runesleo/polymarket-toolkit/blob/main/docs/builder-attribution.md) ### Core fix - `src/builder.ts`: a malformed `POLY_BUILDER_CODE` override now **disables** attribution instead of silently falling back to the author's default ### Verification - 51 tests green (root 23 + executor 28), both typechecks clean - 3-round adversarial code review before ship
-
v0.5.0
GitHub ↗
原版更新说明
## Polymarket Toolkit v0.5.0 **For builders who run code** — CLI, TypeScript helpers, and AI skills over public Polymarket APIs. No API keys. No signing. ### Highlights - **`pm` CLI** — `profile`, `activity`, `scan`, `updown`, `v2-check`, `lb`, `pnl-check`, `limits`, `brier`, `redeem`, `markets` - **Activity ~4000 row cap warnings** — duplicate-page detection so truncated history is not mistaken for complete data - **V2 CTF FAQ** + read-only `pm v2-check` — split/merge infra alignment diagnostics (not execution) - **Validation templates** — handoff, backtest, paper, live-gate, platform runbook - **Bilingual README** — [README.zh.md](./README.zh.md) - **Builder attribution helper** — `src/builder.ts` for future executor paths (read-only tools unchanged) ### Quick try ```bash git clone https://github.com/runesleo/polymarket-toolkit.git && cd polymarket-toolkit ./bin/pm profile 0x63ce342161250d705dc0b16df89036c8e5f9ba9a ``` Node 22+ recommended. ### Boundaries This release does **not** sign transactions or run merge/split/redeem on your wallet. For audit-grade PnL use `skills/polymarket-pnl`. For normal redemption use the official Polymarket app. Full notes: [README.md](https://github.com/runesleo/polymarket-toolkit/blob/main/README.md)
-
v0.4.0
GitHub ↗
原版更新说明
**One-liner:** pUSD-era redeem observability for AI agents. No keys required. After Polymarket's pUSD redemption flow shipped, normal users redeem in-app. Agents still need a status lane: which wallet has redeemable value, which condition still surfaces as `redeemable=true` in the Data API, whether a low-cash strategy account needs attention. v0.4 adds three small helpers to fill that gap — read-only, zero-dep, no signing. ## New helpers (`src/index.ts`) - `fetchRedeemablePositionsPage(user, opts)` — Data API `/positions?redeemable=true` - `summarizeRedeemablePositions(rows)` — group by `conditionId`, sum `currentValue` (losing rows correctly contribute `$0`, not their `size`; negative values clamp to `0`) - `resolveRedeemMode({ mode, lowWatermark })` — returns `"watchdog"` or `"low_watermark"`. Intentionally no `"active"` value: this toolkit never executes a redeem, so an active label belongs in your own wallet system. ## New artifacts - `examples/15-redeem-watchdog.ts` — copy-paste demo - `docs/cookbook.md §11` — bilingual recipe (EN + ZH localized rewrite) - `tests/redeem_watchdog.test.ts` — 9 tests covering pure functions, network URL assembly, and the regression points caught during review ## Safety boundary This release **only reads public APIs**. It does not redeem tokens, sign Safe transactions, call relayers, move funds, or require private keys. The official Polymarket app remains the right place for normal user redemption. ## Review trail This release went through two rounds of independent Codex review: - **Round 1** caught `currentValue || size` falsely inflating losing redeemable rows: a demo wallet with three losing tokens (`size > 0`, `currentValue = 0`) was reporting `$1.84` payable, when the real payable amount is `$0`. Fixed by replacing the `||` fallback with a `currentValue == null` null-check. - **Round 2** caught a missing `>= 0` clamp on negative `currentValue`. Fixed by clamping at the summary level. Tests went from 2 → 9. Full review trail visible in PR #10 and commits `9f89557` + `64f9d15`. ## Tests - `npm test` — 9/9 pass - `tsc --noEmit` — clean - Example 15 smoke against demo wallet `0x63ce342161250d705dc0b16df89036c8e5f9ba9a` returns `estimatedRedeemableValue: 0` (was falsely `$1.84` before the fix) ## Quickstart ```bash npx tsx examples/15-redeem-watchdog.ts <proxy_wallet> [low_watermark] ```
当前收录版本
0.3.0
质量评测
满分100 · 来自 SkillPi LAB 实验室的评测报告。
亮点
- 提供 Polymarket 地址的审计级盈亏计算,误差仅 ~0.2%,具备高实用价值
- 支持单地址、批量、排行榜、基准测试等多种使用模式,功能完整
亮点
- Trigger 章节清晰定义三种典型使用场景,边界明确
- description 准确描述核心功能,与其他技能有明确区分
待提升项
-
requirements.txt 文件缺失 原报告严重程度:轻微
主文件提及 pip install -r ${SKILL_DIR}/requirements.txt,但该文件未传入 ZIP 包
改进建议:请补充 requirements.txt 文件或移除相关引用
亮点
- 文档结构清晰,包含 Setup/Core CLI/Output schema/Known limitations 等完整章节
- 提供多个端到端调用示例,便于用户理解和使用
亮点
- 明确处理 Data API offset ceiling 异常,提供 pagination_incomplete 标志位
- 所有数据源均为公开 API,无需认证,降低使用门槛
- Known limitations 章节诚实披露技术限制,增强可信度
取前四项原始分值的算术平均,四舍五入取整。可通过收录报告核对各项评分与说明,运行记录需单独查证。
正文静态检测
100 / 100 · skillpi-20261123-no-r3-v1
正文未命中当前规则。
分数仅反映正文中的规则命中,供使用前参考。附件与运行行为不在此评分范围内。
权限与使用前检查
根据当前主文档自动整理,命中内容可能是示例或防护说明;不是实际权限声明,也未覆盖附件、外部依赖或运行行为。
-
安装或获取外部依赖
使用官方来源并锁定版本,在隔离环境检查安装脚本。当前文档检查不覆盖后续下载的代码。
主文档提及 · 第 32, 34, 116, 120 行
文档引用的域名或地址
这些地址可能用于文档链接或示例,不是已批准的联网清单。使用前核对实际目的地及发送的数据。
- leolabs.me
- polymarket.com
安全评级与访问范围
safe · 静态证据核验,不代表运行安全保证。
翻译待完成,请参阅来源文档。
使用前请由宿主核对并授权实际文件读写、外部服务和联网目的地;本站的核验不会授予任何运行权限。
用户讨论
还没有已核实的点评。