一键导入
danger-auto-trade-polymarket
DANGER: Polymarket 全自动交易编排器。无需人工确认,AI 自主完成市场扫描、概率评估、仓位计算和实盘下单。一句话触发完整交易链路。当用户要求自动交易、全自动下单、danger trade、auto trade Polymarket 时使用此技能。
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
DANGER: Polymarket 全自动交易编排器。无需人工确认,AI 自主完成市场扫描、概率评估、仓位计算和实盘下单。一句话触发完整交易链路。当用户要求自动交易、全自动下单、danger trade、auto trade Polymarket 时使用此技能。
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Polymarket CLOB API 自动交易执行层。非交互式、指令驱动,支持买入/卖出(市价/限价)、撤单、余额查询、持仓查询、订单簿读取与智能定价。可被 orchestrator 或其他 skill 直接调用执行真实交易。当需要在 Polymarket 上执行实盘交易、查询余额、查看持仓、读取订单簿时使用此技能。
Backtest Polymarket recommendation history. Fetches current market prices, computes P&L for each historical recommendation, evaluates returns by category and direction, and generates a strategy reflection report. Use when the user asks to backtest, evaluate performance, review returns, or analyze P&L of their Polymarket recommendations.
回测 Polymarket 推荐历史。获取当前市价,计算每笔历史推荐的盈亏,按类别和方向评估收益,并生成策略反思报告。当用户要求回测、评估表现、查看收益、分析 Polymarket 推荐盈亏时使用此技能。
Monitor Polymarket positions and open orders for specific wallet addresses. Detects price anomalies, volume spikes, whale activity, and position changes across held markets, with alerts via terminal, Telegram, and email. Use when the user wants to monitor their Polymarket positions, track wallet activity, set up position alerts, or watch for market anomalies on held markets.
监控 Polymarket 持仓和挂单。检测价格异常、成交量暴涨、巨鲸活动和仓位变化,通过终端、Telegram 和邮件发送告警。当用户要求监控 Polymarket 持仓、追踪钱包活动、设置持仓告警、或监视持仓市场异动时使用此技能。
Track Polymarket markets by monitoring their resolution data sources. Fetches event data, parses resolution criteria, assesses trackability, scrapes the resolution source for current state, and runs continuous terminal monitoring with color-coded alerts for score changes, leader changes, and market/data misalignment. Use when the user wants to track a specific Polymarket market's resolution, monitor resolution data sources, or set up alerts for market resolution changes.
| name | danger-auto-trade-polymarket |
| description | DANGER: Polymarket 全自动交易编排器。无需人工确认,AI 自主完成市场扫描、概率评估、仓位计算和实盘下单。一句话触发完整交易链路。当用户要求自动交易、全自动下单、danger trade、auto trade Polymarket 时使用此技能。 |
全自动「扫描 -> 评估 -> 决策 -> 下单」链路。无需人工确认,AI 自主完成所有决策和交易执行。
警告:此 skill 会使用真金白银执行实盘交易。使用 --dry-run 可仅模拟不下单。
按顺序执行,不可跳过。共 8 步(第 0-7 步)。
确保 api-trade-polymarket 脚本可用:
cd ~/.claude/skills/api-trade-polymarket/scripts && npm install 2>/dev/null
检查余额:
cd ~/.claude/skills/api-trade-polymarket/scripts && npx tsx balance.ts
读取 ~/polymarket-reports/portfolio.json,计算当前总资产:
total_assets = cash_balance + sum(positions[].current_value)portfolio.json 不存在,用余额作为 total_assets,初始化空 portfolio 结构解析 $ARGUMENTS 中的风控参数(未指定则用默认值):
| 参数 | 说明 | 默认值 |
|---|---|---|
--max-per-trade <usd> | 单笔交易上限 | $50 |
--max-total <usd> | 本次运行总交易上限 | $150 |
--max-positions <n> | 最多同时持仓数 | 10 |
--dry-run | 仅模拟,不实际下单 | false |
--mode pulse|review|full | 操作模式 | full |
操作模式说明:
pulse — 仅扫描新机会并下单(跳过第 1 步)review — 仅审查现有持仓并执行 sell/rotate(跳过第 2-5 步)full — 先 review 再 pulse,完整链路审查现有持仓,决定 hold/sell/rotate。直接执行 portfolio-review 方法论(不调用 skill)。
1.1 读取持仓
读取 ~/polymarket-reports/portfolio.json 中的 positions[]。如果无持仓,跳到第 2 步。
1.2 逐仓评估
对每个持仓执行:
p_nowcd ~/.claude/skills/api-trade-polymarket/scripts && npx tsx orderbook.ts --token-id <token_id> --side SELL --urgency medium
从返回结果提取 smart_price 作为 c_nowedge = p_now - c_now
daily_expected_return = (p_now - c_now) / (c_now * d_remaining)
1.3 应用决策树
| 条件 | 决策 |
|---|---|
| edge <= 0 | SELL — edge 已消失 |
| 原始 thesis 已被推翻 | SELL — 基本面变化 |
| daily_ER < 0.02% 且有更好机会 | ROTATE — 标记为待卖 |
| 单仓位 > 总资产 25% | TRIM — 减仓至 15% |
| 否则 | HOLD |
1.4 执行卖出
对每个 SELL/TRIM 决策:
cd ~/.claude/skills/api-trade-polymarket/scripts && npx tsx orderbook.ts --token-id <token_id> --side SELL --urgency medium
--dry-run):
调用 api-trade-polymarket skill: sell --market <slug> --direction <dir> --shares <n> --order-type limit --price <smart_price>
如果是 --dry-run,仅打印将要执行的命令。1.5 记录 review 结果
将所有持仓的评估结果和决策记录到内存中,用于第 6 步报告。
调用 polymarket-market-pulse skill 扫描新机会:
使用 Skill tool 调用 polymarket-market-pulse
这会执行完整的 market pulse 流程:
~/polymarket-reports/market-pulse-{date}.md 报告recommendation-history.md使用 Glob 工具找到最新的 ~/polymarket-reports/market-pulse-*.md 文件
读取报告,提取每个推荐的:
过滤已持有市场:
portfolio.json 的 positions[]对每个通过筛选的新推荐,计算最终交易金额:
资金管理规则(按顺序应用,取最小值):
1. 基础上限 = min(建议金额, --max-per-trade, total_assets * 5%)
2. 置信度调整:
- High 或 Medium-High → 放宽到 total_assets * 8%
- Medium 或 Low → 维持 total_assets * 5%
3. 流动性约束:
- 获取 orderbook 的 2% 滑点深度(buy_capacity.max_cost_usd)
- 不超过该深度的 10%
4. 总敞口约束:
- 所有现有持仓 + 本次所有新交易 <= total_assets * 50%
- 如超出则按比例缩减新交易金额
5. Edge 加权缩放:
- Edge > 20%: 用满上限
- Edge 10-20%: 上限 * 60%
- Edge 5-10%: 上限 * 30%
- Edge < 5%: 跳过该推荐
6. 最小交易检查:金额 < $10 则跳过
7. 累计检查:本次运行所有买入累计不超过 --max-total
如剩余额度不足,按 Edge 优先级截断
按 Edge 从高到低排序,依次执行:
对每个推荐:
5.1 获取智能价格
cd ~/.claude/skills/api-trade-polymarket/scripts && npx tsx orderbook.ts --token-id <token_id> --side BUY --urgency medium
提取 smart_price 和流动性数据。
5.2 计算份数
shares = floor(amount / smart_price)
5.3 执行下单
如果是 --dry-run 模式,打印将要执行的命令,跳过实际下单:
[DRY-RUN] 将执行: api-trade-polymarket buy --market <slug> --direction <dir> --order-type limit --price <price> --amount <usd>
如果非 dry-run,调用 api-trade-polymarket skill 执行:
调用 api-trade-polymarket skill: buy --market <slug> --direction <dir> --order-type limit --price <smart_price> --amount <usd>
5.4 处理返回结果
解析返回 JSON:
status=matched 或 status=filled → 记录成功,累加已用金额status=live → 挂单中,记录 orderID,累加已用金额status=error → 记录失败原因,继续下一个(单笔失败不影响后续)5.5 更新累计金额
每笔成功后更新累计交易金额,确保不超过 --max-total。
使用 Write 工具生成报告:
文件路径: ~/polymarket-reports/auto-trade-{YYYY-MM-DD}-{HHMMSS}.md
报告模板:
# Auto-Trade Execution Report
**时间:** {timestamp UTC}
**模式:** {pulse|review|full}
**风控参数:** max_per_trade=${X}, max_total=${Y}, max_positions=${Z}
**Dry-Run:** {是/否}
## Portfolio Review 结果
| 市场 | 方向 | 买入价 | 现价 | p_now | Edge | Daily ER | 决策 | 原因 | 执行结果 |
|------|------|--------|------|-------|------|----------|------|------|----------|
(review/full 模式才有此节)
## 新建仓位
| # | 市场 | 方向 | Edge | 置信度 | 金额 | 价格 | 份数 | 状态 | OrderID |
|---|------|------|------|--------|------|------|------|------|---------|
(pulse/full 模式才有此节)
## 执行摘要
- 卖出: N 笔, 总计 $X
- 买入: N 笔, 总计 $Y
- 失败: N 笔
- 剩余现金: $Z
- 总持仓: N 个市场
- 总敞口: XX% of total_assets
## 风控检查
- [x/!] 单笔未超 $MAX_PER_TRADE
- [x/!] 本次总额未超 $MAX_TOTAL
- [x/!] 持仓数未超 MAX_POSITIONS
- [x/!] 总敞口 < 50% of total_assets
确保所有变更写入 ~/polymarket-reports/portfolio.json:
新增仓位(买入成功)→ 添加到 positions[]:
{
"market": "<slug>",
"event_slug": "<event_slug>",
"direction": "Yes|No",
"shares": <n>,
"entry_price": <price>,
"current_price": <price>,
"current_value": <value>,
"token_id": "<clobTokenId>",
"opened_at": "<timestamp>",
"source": "auto-trade"
}
挂单(status=live)→ 添加到 pending_orders[]:
{
"order_id": "<id>",
"market": "<slug>",
"direction": "Yes|No",
"side": "BUY|SELL",
"price": <price>,
"amount": <usd>,
"created_at": "<timestamp>"
}
卖出成功 → 从 positions[] 移除,添加到 trade_history[]:
{
"market": "<slug>",
"direction": "Yes|No",
"side": "SELL",
"shares": <n>,
"entry_price": <price>,
"exit_price": <price>,
"pnl": <usd>,
"closed_at": "<timestamp>"
}
更新顶层字段:
cash_balance — 从余额查询获取最新值total_assets — cash + 持仓市值updated_at — 当前 UTC 时间戳如果是 --dry-run 模式,不写入 portfolio.json,仅在报告中标注模拟结果。