对冲
Hyperliquid 对冲账户、策略、订单。均需 Bearer。 HL 钱包私钥用 ECIES 加密后提交,API 只回地址不回钥。
EciesCiphertext:{ "ephemeral_public_key", "iv", "ciphertext" }。
GET /api/hedge/accounts
200: { "accounts": [HedgeAccount] }
| 字段 | 说明 |
|---|---|
id | 账户 id |
name | 显示名 |
address | HL 钱包地址 |
enabled | 是否参与下单 |
created_at_ms / updated_at_ms / updated_by | 审计 |
margin | { account_value, withdrawable, updated_at_ms } 或 null |
POST /api/hedge/accounts
Body: { "name": "hl-1", "ciphertext": <EciesCiphertext> }
同一 HL 地址不可重复 → 400。成功会尝试种一条默认策略。
200: { "ok": true, "account": <HedgeAccount> }
PUT /api/hedge/accounts/{id}
Body: { "name"?, "ciphertext"?, "enabled"? }
200: { "ok": true }
DELETE /api/hedge/accounts/{id}
200: { "ok": true }
GET /api/hedge/policies
200: { "policies": [HedgePolicy] }
| 字段 | 说明 |
|---|---|
market_symbol | 市场 symbol |
hedge_ratio | 对冲比例 |
hedge_mode | 模式(如跟随 / 反向) |
account_id | 兼容字段;现行按账户池轮转,不强制绑死 |
enabled | 是否启用 |
threshold_notional / min_order_sz / max_order_sz | 可选覆盖 |
updated_at_ms / updated_by | 审计 |
PUT /api/hedge/policies
按 market_symbol upsert。
Body: { "market_symbol", "hedge_ratio", "hedge_mode", "account_id"?, "enabled", "threshold_notional"?, "min_order_sz"?, "max_order_sz"? }
200: { "ok": true }
DELETE /api/hedge/policies/{symbol}
symbol 需 URL 编码。
GET /api/hedge/config
全局:{ "interval_ms", "threshold_notional", "min_order_sz", "dry_run", "hl_network" }
PUT /api/hedge/config
字段均可选,缺省保持原值。200: { "ok": true }
GET /api/hedge/orders
| Query | 默认 | 说明 |
|---|---|---|
account_id | — | 按账户筛 |
symbol | — | 按市场筛 |
limit | 50 | 条数 |
offset | 0 | 偏移 |
200: { "orders": [HedgeOrderRecord], "total", "offset", "limit" }
订单字段:id、account_id、market_symbol、coin、is_buy、sz、px、
delta_before、hl_oid、cloid、status、error、created_at_ms。
POST /api/hedge/orders/reconcile
触发一次与 HL 的订单对账。200: { "ok": true, "triggered": true }
GET /api/hedge/book-b-stats
链上 Book B 市场净仓聚合(服务端拉链)。
200: { "height", "fetched_at_ms", "markets": [{ "symbol", "market_id", "lifecycle", "emergency_halt", "mark_price", "stats": { "long_size", "short_size", "net_size", "block_height" } | null, "detail_error" }], "totals": { "markets_with_stats", "markets_failed" } }