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

# 盤口深度（Depth）

## 套餐權限

| 套餐 | 可用 |
| - | :-: |
| 免費版 | ❌ |
| 基礎版 | ✅ |
| 專業版 | ✅ |
| 全量套餐（A 股、港股、美股） | ✅ |
| 企業版 | ✅ |

## 支援市場

支援市場：美股、港股、A股、中國期貨、加密貨幣

## 訂閱

```json theme={null}
{
  "cmd": "subscribe",
  "data": {
    "channel": "depth",
    "symbols": ["AAPL.US", "BTCUSDT"]
  }
}
```

> `type` 對本次訂閱中的全部代碼生效。混合訂閱不同產品類型時請省略 `type`；僅在代碼存在歧義時，按產品類型拆分訂閱並傳入對應值。

## 取消訂閱

```json theme={null}
{
  "cmd": "unsubscribe",
  "data": {
    "channel": "depth",
    "symbols": ["AAPL.US"]
  }
}
```

## 服務器響應

```json theme={null}
{
  "cmd": "depth",
  "data": {
    "symbol": "BTCUSDT",
    "bids": [
      ["43250.50", "0.125"],
      ["43250.00", "0.250"]
    ],
    "asks": [
      ["43251.00", "0.180"],
      ["43251.50", "0.320"]
    ],
    "timestamp": 1703123456789
  }
}
```

### 字段說明

| 字段 | 類型 | 描述 |
| - | - | - |
| symbol | string | 交易品種 |
| bids | array | 買盤檔位：`[價格, 數量]` |
| asks | array | 賣盤檔位：`[價格, 數量]` |
| timestamp | int | 服務器時間戳（毫秒） |

**排序**

* `bids`：價格降序
* `asks`：價格升序


## AsyncAPI

````yaml asyncapi.zh-Hant.json depth
id: depth
title: Depth
description: ''
servers:
  - id: production
    protocol: wss
    host: api.tickdb.ai
    bindings: []
    variables: []
address: /v1/realtime
parameters: []
bindings: []
operations:
  - &ref_3
    id: subscribeToDepth
    title: Subscribe to depth
    type: send
    messages:
      - &ref_5
        id: depthData
        contentType: application/json
        payload:
          - name: 盤口深度數據
            description: 即時推送的盤口深度數據。
            type: object
            properties:
              - name: cmd
                type: string
                description: 消息類型。
                required: true
              - name: data
                type: object
                required: true
                properties:
                  - name: symbol
                    type: string
                    description: 交易代碼。
                    required: true
                  - name: type
                    type: string
                    description: 標的類型。
                    enumValues:
                      - stock
                      - indices
                      - crypto
                      - forex
                      - futures
                    required: false
                  - name: bids
                    type: array
                    description: 買盤檔位，每項為 [價格, 數量]。
                    required: true
                    properties:
                      - name: item
                        type: array
                        required: false
                        properties:
                          - name: item
                            type: string
                            required: false
                  - name: asks
                    type: array
                    description: 賣盤檔位，每項為 [價格, 數量]。
                    required: true
                    properties:
                      - name: item
                        type: array
                        required: false
                        properties:
                          - name: item
                            type: string
                            required: false
                  - name: timestamp
                    type: integer
                    description: Unix 時間戳，單位為毫秒。
                    required: true
        headers: []
        jsonPayloadSchema:
          type: object
          additionalProperties: false
          properties:
            cmd:
              type: string
              const: depth
              description: 消息類型。
              x-parser-schema-id: <anonymous-schema-76>
            data:
              type: object
              additionalProperties: false
              properties:
                symbol:
                  type: string
                  example: BTCUSDT
                  description: 交易代碼。
                  x-parser-schema-id: <anonymous-schema-78>
                type:
                  type: string
                  enum:
                    - stock
                    - indices
                    - crypto
                    - forex
                    - futures
                  description: 標的類型。
                  x-parser-schema-id: <anonymous-schema-79>
                bids:
                  type: array
                  items:
                    type: array
                    items:
                      type: string
                      x-parser-schema-id: <anonymous-schema-82>
                    minItems: 2
                    maxItems: 2
                    x-parser-schema-id: <anonymous-schema-81>
                  example:
                    - - '43250.50'
                      - '0.125'
                    - - '43250.00'
                      - '0.250'
                  description: 買盤檔位，每項為 [價格, 數量]。
                  x-parser-schema-id: <anonymous-schema-80>
                asks:
                  type: array
                  items:
                    type: array
                    items:
                      type: string
                      x-parser-schema-id: <anonymous-schema-85>
                    minItems: 2
                    maxItems: 2
                    x-parser-schema-id: <anonymous-schema-84>
                  example:
                    - - '43251.00'
                      - '0.180'
                    - - '43251.50'
                      - '0.320'
                  description: 賣盤檔位，每項為 [價格, 數量]。
                  x-parser-schema-id: <anonymous-schema-83>
                timestamp:
                  type: integer
                  example: 1703123456789
                  description: Unix 時間戳，單位為毫秒。
                  x-parser-schema-id: <anonymous-schema-86>
              required:
                - symbol
                - bids
                - asks
                - timestamp
              x-parser-schema-id: <anonymous-schema-77>
          required:
            - cmd
            - data
          x-parser-schema-id: <anonymous-schema-75>
        title: 盤口深度數據
        description: 即時推送的盤口深度數據。
        example: No examples found
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: depthData
    bindings: []
    extensions: &ref_1
      - id: x-parser-unique-object-id
        value: depth
  - &ref_2
    id: receiveDepthData
    title: Receive depth data
    type: receive
    messages:
      - &ref_4
        id: subscribeRequest
        contentType: application/json
        payload:
          - name: 訂閱或取消訂閱盤口深度
            description: 訂閱或取消訂閱即時盤口深度。
            type: object
            properties:
              - name: cmd
                type: string
                description: 命令類型：訂閱或取消訂閱。
                enumValues:
                  - subscribe
                  - unsubscribe
                required: true
              - name: data
                type: object
                required: true
                properties:
                  - name: channel
                    type: string
                    description: 頻道名稱。
                    enumValues:
                      - ticker
                      - depth
                      - trade
                    required: true
                  - name: symbols
                    type: array
                    description: 要訂閱或取消訂閱的交易代碼列表。
                    examples: &ref_0
                      - AAPL.US
                      - 700.HK
                      - EURUSD
                      - XAUUSD
                      - BTCUSDT
                      - IC2606
                    required: true
                    properties:
                      - name: item
                        type: string
                        required: false
                  - name: type
                    type: string
                    description: 標的類型，可選；代碼無歧義時可不傳。若返回 AMBIGUOUS_SYMBOL 錯誤，請依提示指定類型。
                    enumValues:
                      - stock
                      - indices
                      - crypto
                      - forex
                      - futures
                    required: false
        headers: []
        jsonPayloadSchema:
          type: object
          additionalProperties: false
          properties:
            cmd:
              type: string
              enum:
                - subscribe
                - unsubscribe
              description: 命令類型：訂閱或取消訂閱。
              x-parser-schema-id: <anonymous-schema-69>
            data:
              type: object
              additionalProperties: false
              properties:
                channel:
                  type: string
                  enum:
                    - ticker
                    - depth
                    - trade
                  default: depth
                  description: 頻道名稱。
                  x-parser-schema-id: <anonymous-schema-71>
                symbols:
                  type: array
                  items:
                    type: string
                    x-parser-schema-id: <anonymous-schema-73>
                  examples: *ref_0
                  description: 要訂閱或取消訂閱的交易代碼列表。
                  x-parser-schema-id: <anonymous-schema-72>
                type:
                  type: string
                  enum:
                    - stock
                    - indices
                    - crypto
                    - forex
                    - futures
                  description: 標的類型，可選；代碼無歧義時可不傳。若返回 AMBIGUOUS_SYMBOL 錯誤，請依提示指定類型。
                  x-parser-schema-id: <anonymous-schema-74>
              required:
                - channel
                - symbols
              x-parser-schema-id: <anonymous-schema-70>
          required:
            - cmd
            - data
          x-parser-schema-id: <anonymous-schema-68>
        title: 訂閱或取消訂閱盤口深度
        description: 訂閱或取消訂閱即時盤口深度。
        example: No examples found
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: subscribeRequest
    bindings: []
    extensions: *ref_1
sendOperations:
  - *ref_2
receiveOperations:
  - *ref_3
sendMessages:
  - *ref_4
receiveMessages:
  - *ref_5
extensions:
  - id: x-parser-unique-object-id
    value: depth
securitySchemes:
  - id: apiKey
    name: api_key
    type: httpApiKey
    in: query
    extensions: []

````

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