> ## Documentation Index
> Fetch the complete documentation index at: https://dexbuilder.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# 私有频道

> 订阅当前认证用户的订单、成交、持仓和结算更新。

私有频道需要 Broker API Key 签名认证及已绑定的钱包地址。API Secret 只在本地用于签名，不能通过网络发送。详见[WebSocket 认证](https://dexbuilder.mintlify.site/zh/event-markets/websocket/authentication.md)。

## 订阅

使用 `pred` 前缀。可以使用 `items` 订阅指定条件，也可以使用 `all: true` 订阅全部私有推送。

```json theme={null}
{
  "t": 1720000000123,
  "id": "private-1",
  "op": "subscribe",
  "ch": "pred.orders",
  "payload": {
    "items": [
      {
        "condition_id": "ge_condition-1"
      }
    ]
  },
  "auth": {
    "method": "broker_api_key",
    "key": "YOUR_BROKER_API_KEY",
    "sign": "SIGNATURE",
    "wallet_address": "<USER_WALLET>"
  }
}
```

取消订阅时使用相同的 payload，并将 `op` 设置为 `unsubscribe`。

## `pred.orders`

账户订单状态变化。返回字段包括 `order_id`、`client_order_id`、`event_id`、`condition_id`、`token_id`、`outcome`、`side`、`order_mode`、`order_type`、`px`、`qty`、`filled_qty`、`left_qty`、`status`、`created_ts` 和 `updated_ts`。

```json theme={null}
{
  "type": "update",
  "ch": "pred.orders",
  "err": null,
  "result": {
    "order_id": "order-1",
    "condition_id": "ge_condition-1",
    "token_id": "ge_token-yes",
    "side": "BUY",
    "px": "0.45",
    "qty": "10",
    "filled_qty": "4",
    "left_qty": "6",
    "status": "OPEN",
    "updated_ts": 1720000001123
  }
}
```

WebSocket 的 `status` 是上游大写 UI 状态，与 REST 接口的小写五态不同。常见值包括 `PROCESSING`、`OPEN`、`CANCELLING`、`MATCHED`、`CANCELED` 和 `FAILED`。

## `pred.usertrades`

账户成交推送。返回 `trade_id`、`order_id`、`condition_id`、`token_id`、`side`、`role`、`px`、`qty`、`fee_rate`、`status` 和 `created_ts`。

```json theme={null}
{
  "type": "update",
  "ch": "pred.usertrades",
  "err": null,
  "result": {
    "trade_id": "trade-1",
    "order_id": "order-1",
    "condition_id": "ge_condition-1",
    "token_id": "ge_token-yes",
    "side": "BUY",
    "role": "MAKER",
    "px": "0.45",
    "qty": "4",
    "fee_rate": "0.001",
    "status": "CONFIRMED",
    "created_ts": 1720000000123
  }
}
```

仅推送已确认的账户成交；具体是否推送 MATCHED 事件取决于服务配置。

## `pred.positions`

账户仓位变化。返回 `position_id`、`event_id`、`token_id`、`outcome`、`qty`、`avg_px`、`settle_status`、`locked_qty`、`available_qty`、`claimable_amount` 和 `updated_ts`。

```json theme={null}
{
  "type": "update",
  "ch": "pred.positions",
  "err": null,
  "result": {
    "position_id": "12345",
    "event_id": "event-1",
    "token_id": "ge_token-yes",
    "outcome": "Yes",
    "qty": "10",
    "avg_px": "0.45",
    "settle_status": "UNSETTLED",
    "locked_qty": "0",
    "available_qty": "10",
    "claimable_amount": "0",
    "updated_ts": 1720000001123
  }
}
```

## `pred.settlements`

结算和可领取金额变化。

```json theme={null}
{
  "type": "update",
  "ch": "pred.settlements",
  "err": null,
  "result": {
    "position_id": "12345",
    "condition_id": "ge_condition-1",
    "event_id": "event-1",
    "winning_outcome": "Yes",
    "is_winner": true,
    "claimable_amount": "10.00",
    "created_ts": 1720000002123
  }
}
```

私有频道是事件驱动的。重连后应通过对应 REST 接口恢复当前状态；订阅私有频道不会自动返回完整账户快照。


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.