> ## 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 認證，並以 `auth.wallet_address` 指定當前 Broker 旗下的使用者。API Secret 只在本地用於簽名。詳見 [Broker WebSocket 認證](https://dexbuilder.mintlify.site/zh-TW/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": "HEX_SIGNATURE",
    "wallet_address": "<USER_WALLET>"
  }
}
```

取消訂閱時使用相同的 payload，並將 `op` 設定為 `unsubscribe`。如已透過 `server.sign` 認證連線，後續訂閱和取消訂閱可省略 `auth`。

## `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.