alchemist-x/all-polymarket-skill/api-trade-polymarket
Claude Code and agent skill by alchemist-x/all-polymarket-skill
- community
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-polymarketSKILL.md
Polymarket CLOB API 交易执行
非交互式交易执行层,通过 $ARGUMENTS 接收指令,调用 Polymarket CLOB API 完成操作并返回结构化 JSON 结果。
工作流
按顺序执行,不可跳过。
第 0 步:环境准备
验证 .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:
- 通过 Polymarket Gamma API 查询市场信息:
`` GET https://gamma-api.polymarket.com/events?slug=<slug> ``
- 从返回的 market 数据中,根据
--direction找到对应 outcome 的clobTokenId - 如果 API 查询失败,提示用户直接提供
--token-id
第 3 步:预检查(买入/卖出操作需要)
余额检查:
验证 USDC 余额充足。
订单簿读取(限价单需要):
如果用户未指定价格但选择限价单,使用返回的 smart_price 作为限价。
风控验证:
- 单笔金额不超过 $500(安全上限)
- 价格在 best_bid 和 best_ask 范围内合理
- 余额足够覆盖交易
第 4 步:执行操作
根据操作类型调用对应脚本:
买入/卖出:
撤单:
余额查询:
持仓查询:
订单簿:
第 5 步:更新组合状态
如果执行了买入/卖出操作且成功,更新 ~/polymarket-reports/portfolio.json:
status=matched/filled→ 添加到positions,扣减cash_balancestatus=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()清理
参考文件
- references/clob-trading-api.md — CLOB API 端点文档
- references/env-setup.md — .env.aizen 配置指南
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
- SKILL.md in the repositoryCheckingapi-trade-polymarket/SKILL.md
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
[](https://verified-skill.com/skills/alchemist-x/all-polymarket-skill/api-trade-polymarket)