跳到主要内容

对冲

Hyperliquid 对冲账户、策略、订单。均需 Bearer。 HL 钱包私钥用 ECIES 加密后提交,API 只回地址不回钥。

EciesCiphertext{ "ephemeral_public_key", "iv", "ciphertext" }

GET /api/hedge/accounts

200: { "accounts": [HedgeAccount] }

字段说明
id账户 id
name显示名
addressHL 钱包地址
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按市场筛
limit50条数
offset0偏移

200: { "orders": [HedgeOrderRecord], "total", "offset", "limit" }

订单字段:idaccount_idmarket_symbolcoinis_buyszpxdelta_beforehl_oidcloidstatuserrorcreated_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" } }