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