全面优化实盘对接没有验证

This commit is contained in:
2026-07-14 07:29:03 +08:00
parent a1963e58ed
commit b3f770c55f
391 changed files with 114674 additions and 528 deletions
+18
View File
@@ -191,6 +191,24 @@ curl "https://gamma-api.polymarket.com/events?tag_id=745&active=true&closed=fals
| `GET /holders?market={conditionId}` | 某市场的 top 持仓人 |
| `GET /trades` | 全市场成交流(见下) |
> **⚠️ 踩坑笔记(`/closed-positions`**
>
> 1. **`limit` 上限是 50,不是 100**。服务端会忽略超过 50 的请求或截断,导致 PnL/信誉分计算漏数据。`data_api.py:get_closed_positions` 已用 `min(limit, 50)` 防御性 clamp。
> 2. **默认 `sortBy=REALIZEDPNL` 是个坑**:返回的是"最赚/最亏的 50 条",而不是"最近的 50 条"。如果直接按 `timestamp >= cutoff` 在 Python 端过滤,窗口内的平仓可能根本不在前 50 盈亏里 → 静默漏数。正确做法:用 `sortBy=TIMESTAMP` + `sortDirection=DESC` + `offset` 翻页,直到拿到 `ts < cutoff` 的记录就停。封装见 `data_api.py:get_closed_positions_since`。
>
> 本项目曾因这两个问题导致 PnL 和信誉分偏小,已在 `wallet_pool.py` / `bayesian.py` 修复。
> **📝 `/markets` 端点用法(信号结果回填)**
>
> 信号回填服务(`outcome_resolver.py`)调 Gamma `/markets?condition_id=...` 拉市场结算结果。关键字段(按官方 `/markets/{id}` schema):
>
> - `closed` (bool):市场是否已关闭/结算
> - `closedTime` (str):结算时间
> - `outcomes` (str)JSON 数组,如 `'["Yes", "No"]'`
> - `outcomePrices` (str)JSON 数组,结算后赢家价格 = 1,输家 = 0
>
> 判定逻辑:`closed=true` 且 `outcomePrices` 中某 outcome 价格 ≥ 0.99 即为赢家。PnL 模型:win = `S*(1-p)/p`loss = `-S`(理论全仓执行,不建模滑点)。
### 4.2 `/trades`(成交历史)参数
| 参数 | 说明 |