alchemist-x/all-polymarket-skill/api-trade-polymarket

Claude Code and agent skill by alchemist-x/all-polymarket-skill

Trust tier 3
  • community
Source check pending

Checking that the SKILL.md file is still in the repository.

Polymarket CLOB API 自动交易执行层。非交互式、指令驱动,支持买入/卖出(市价/限价)、撤单、余额查询、持仓查询、订单簿读取与智能定价。可被 orchestrator 或其他 skill 直接调用执行真实交易。当需要在 Polymarket 上执行实盘交易、查询余额、查看持仓、读取订单簿时使用此技能。

Install

npx vskill@latest install alchemist-x/all-polymarket-skill/api-trade-polymarket

SKILL.md

Polymarket CLOB API 交易执行

非交互式交易执行层,通过 $ARGUMENTS 接收指令,调用 Polymarket CLOB API 完成操作并返回结构化 JSON 结果。

工作流

按顺序执行,不可跳过。

第 0 步:环境准备
bash
cd ~/.claude/skills/api-trade-polymarket/scripts && npm install 2>/dev/null

验证 .env.aizen 存在(位于 scripts/ 目录下)。若不存在,提示用户参照 .env.aizen.example 创建。

第 1 步:解析指令

从 $ARGUMENTS 中提取操作类型和参数。支持的操作:

操作格式
买入`buy --market <slug> --direction Yes\No --amount <usd> [--order-type market\limit] [--price <p>]`
卖出`sell --market <slug> --direction Yes\No --shares <n> [--order-type market\limit] [--price <p>]`
撤单cancel --order-id <id> 或 cancel --all
余额balance
持仓positions
订单簿`orderbook --market <slug> --direction Yes\No`
第 2 步:市场解析(买入/卖出/订单簿操作需要)

当指令包含 --market <slug>,需要将 market slug 和 direction 转换为 CLOB token ID:

  1. 通过 Polymarket Gamma API 查询市场信息:

`` GET https://gamma-api.polymarket.com/events?slug=<slug> ``

  1. 从返回的 market 数据中,根据 --direction 找到对应 outcome 的 clobTokenId
  2. 如果 API 查询失败,提示用户直接提供 --token-id
第 3 步:预检查(买入/卖出操作需要)

余额检查:

bash
cd ~/.claude/skills/api-trade-polymarket/scripts && npx tsx balance.ts

验证 USDC 余额充足。

订单簿读取(限价单需要):

bash
cd ~/.claude/skills/api-trade-polymarket/scripts && npx tsx orderbook.ts --token-id <id> --side BUY|SELL --urgency medium

如果用户未指定价格但选择限价单,使用返回的 smart_price 作为限价。

风控验证:

  • 单笔金额不超过 $500(安全上限)
  • 价格在 best_bid 和 best_ask 范围内合理
  • 余额足够覆盖交易
第 4 步:执行操作

根据操作类型调用对应脚本:

买入/卖出:

bash
# 市价单 (FOK)
cd ~/.claude/skills/api-trade-polymarket/scripts && npx tsx trade.ts --token-id <id> --side BUY|SELL --order-type FOK --amount <usd>
# 限价单 (GTC)
cd ~/.claude/skills/api-trade-polymarket/scripts && npx tsx trade.ts --token-id <id> --side BUY|SELL --order-type GTC --price <p> --size <shares>

撤单:

bash
cd ~/.claude/skills/api-trade-polymarket/scripts && npx tsx cancel.ts --order-id <id>
cd ~/.claude/skills/api-trade-polymarket/scripts && npx tsx cancel.ts --all

余额查询:

bash
cd ~/.claude/skills/api-trade-polymarket/scripts && npx tsx balance.ts

持仓查询:

bash
cd ~/.claude/skills/api-trade-polymarket/scripts && npx tsx positions.ts

订单簿:

bash
cd ~/.claude/skills/api-trade-polymarket/scripts && npx tsx orderbook.ts --token-id <id> [--side BUY|SELL] [--urgency low|medium|high] [--depth 5]
第 5 步:更新组合状态

如果执行了买入/卖出操作且成功,更新 ~/polymarket-reports/portfolio.json:

  • status=matched/filled → 添加到 positions,扣减 cash_balance
  • status=live → 添加到 pending_orders,记录 real_order_id
  • 撤单成功 → 从 pending_orders 移除,恢复 cash_balance
第 6 步:输出结果

将脚本输出的 JSON 直接返回给调用者。所有脚本输出格式统一包含 status 字段。

错误处理

  • 环境缺失 → 返回 {"error": "...", "status": "config_error"}
  • 参数错误 → 返回 {"error": "...", "status": "arg_error"}
  • API 失败 → 返回 {"error": "...", "status": "execution_error"}
  • 执行出错时自动调用 cancelAll() 清理

参考文件

Security

  • Security scanPassed, 90 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

7-day trend score
0

Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/alchemist-x/all-polymarket-skill/api-trade-polymarket/badge)](https://verified-skill.com/skills/alchemist-x/all-polymarket-skill/api-trade-polymarket)

Something wrong with this skill or its page? Tell us.