hedge-execution.md 2.5 KB

对冲执行指令契约

1. 指令请求

  • 主题:控制平面对对冲执行器的内部调用
  • 请求体

    {
    "commandId": "uuid",
    "trigger": "delta-breach",
    "primaryAccountId": "pacifica-1",
    "hedgeAccountId": "aster-1",
    "symbol": "BTC",
    "deltaBefore": 0.00072,
    "targetDelta": 0.00000,
    "orders": [
    {
      "side": "sell",
      "type": "limit",
      "amount": "0.0007",
      "price": "109310",
      "timeInForce": "GTC",
      "proxyProfile": "proxy-main"
    },
    {
      "side": "buy",
      "type": "market",
      "amount": "0.0007",
      "routing": {
        "exchange": "aster",
        "slippageTolerance": 0.0005
      }
    }
    ],
    "riskEnvelope": {
    "maxSlippage": 0.001,
    "emergencyStopLossSeconds": 30
    },
    "createdAt": "2025-09-27T12:05:00Z"
    }
    
  • 说明

    • trigger:触发原因(utilization/delta/failover/manual)。
    • orders:对冲组合,按执行顺序排列;若需并发执行需标明 parallel: true 字段。
    • proxyProfile:指明代理配置 ID。

2. 执行响应

{
  "commandId": "uuid",
  "status": "completed",
  "deltaAfter": 0.00008,
  "executionDetails": [
    {
      "accountId": "pacifica-1",
      "exchangeOrderId": "1234567",
      "filledSize": "0.0007",
      "avgPrice": "109309.8",
      "fees": "0.02",
      "result": "filled"
    },
    {
      "accountId": "aster-1",
      "exchangeOrderId": "9876543",
      "filledSize": "0.0007",
      "avgPrice": "109312.0",
      "fees": "0.03",
      "result": "filled"
    }
  ],
  "durationMs": 4200,
  "alerts": [],
  "completedAt": "2025-09-27T12:05:04Z"
}
  • status:completed/partial/failed。
  • alerts:在对冲过程中触发的风险或回退提示(如“利用率仍超 80%”)。

3. 失败示例

{
  "commandId": "uuid",
  "status": "failed",
  "deltaAfter": 0.00070,
  "executionDetails": [
    {
      "accountId": "pacifica-1",
      "result": "partially_filled",
      "filledSize": "0.0003",
      "error": {
        "code": "ORDER_CANCELLED",
        "message": "Post-only limit order removed"
      }
    }
  ],
  "alerts": [
    {
      "type": "utilization-high",
      "message": "Account aster-1 utilization still 82%",
      "severity": "WARN"
    }
  ],
  "completedAt": "2025-09-27T12:05:05Z"
}

4. 业务规则

  • 对冲执行器必须在 30 秒内完成或触发紧急止损。
  • 部分成交后,控制平面需重新计算 Delta 并决定是否重试或改用市场单。
  • 所有结果需写入 HedgeExecutionMonitoringEvent