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

# 实时行情（Ticker）

## 套餐权限

| 套餐 | 可用 |
| - | :-: |
| 免费版 | ✅ |
| 基础版 | ✅ |
| 专业版 | ✅ |
| 全量套餐（A 股、港股、美股） | ✅ |
| 企业版 | ✅ |

## 支持的市场

支持市场：外汇、贵金属、指数、美股、港股、A股、中国期货、香港期货、加密货币

## 订阅

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

> `type` 对本次订阅中的全部代码生效。混合订阅不同产品类型时请省略 `type`；仅在代码存在歧义时，按产品类型拆分订阅并传入对应值。

## 取消订阅

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

## 服务器响应

ticker 消息根据不同市场类型返回不同的字段。

### 指数

```json theme={null}
{
  "cmd": "ticker",
  "data": {
    "symbol": "SPX",
    "type": "indices",
    "last_price": "7342.86",
    "timestamp": 1779204386000
  }
}
```

### 贵金属

```json theme={null}
{
  "cmd": "ticker",
  "data": {
    "symbol": "XAUUSD",
    "type": "forex",
    "last_price": "5130.72000",
    "ask_price": "5131.07000",
    "bid_price": "5130.37000",
    "spread": "0.70000",
    "timestamp": 1773334355000
  }
}
```

### 外汇

```json theme={null}
{
  "cmd": "ticker",
  "data": {
    "symbol": "EURUSD",
    "type": "forex",
    "last_price": "1.15200",
    "ask_price": "1.15202",
    "bid_price": "1.15199",
    "spread": "0.00003",
    "timestamp": 1773334426000
  }
}
```

### 股票

美股：

`trade_session` 仅在盘前、盘后或夜盘等扩展交易时段返回，可选值为 `pre_market`、`post_market`、`overnight`。

```json theme={null}
{
  "cmd": "ticker",
  "data": {
    "symbol": "NVDA.US",
    "type": "stock",
    "last_price": "221.25",
    "volume_24h": "462724",
    "high_24h": "223.44",
    "low_24h": "220.04",
    "trade_session": "overnight",
    "timestamp": 1779171600000
  }
}
```

港股：

```json theme={null}
{
  "cmd": "ticker",
  "data": {
    "symbol": "700.HK",
    "type": "stock",
    "last_price": "461.4",
    "volume_24h": "24687716",
    "high_24h": "468.8",
    "low_24h": "448.6",
    "timestamp": 1779171608000
  }
}
```

A股：

```json theme={null}
{
  "cmd": "ticker",
  "data": {
    "symbol": "600519.SH",
    "type": "stock",
    "last_price": "1319.01",
    "volume_24h": "37263",
    "high_24h": "1329.99",
    "low_24h": "1318",
    "price_change_24h": "-3.99",
    "price_change_percent_24h": "-0.30",
    "timestamp": 1779171605000
  }
}
```

中国期货：

```json theme={null}
{
  "cmd": "ticker",
  "data": {
    "symbol": "BU2609",
    "type": "futures",
    "last_price": "4309",
    "bid_price": "4308",
    "ask_price": "4310",
    "volume_24h": "37263",
    "high_24h": "4336",
    "low_24h": "4278",
    "timestamp": 1784012398000
  }
}
```

### 加密货币

```json theme={null}
{
  "cmd": "ticker",
  "data": {
    "symbol": "BTCUSDT",
    "type": "crypto",
    "last_price": "70480.57000000",
    "volume_24h": "23737.52989000",
    "high_24h": "71321.00000000",
    "low_24h": "69205.91000000",
    "price_change_24h": "-362.06000000",
    "price_change_percent_24h": "-0.511",
    "timestamp": 1773335135026
  }
}
```

### 字段说明

| 字段 | 类型 | 描述 | 市场 |
| - | - | - | - |
| symbol | string | 交易产品代码 | 全部 |
| name | string | 产品名称；名称可用时返回 | 部分产品 |
| type | string | 产品类型 | 全部 |
| category | string | 产品细分类别；分类信息可用时返回 | A股市场产品 |
| last\_price | string | 最新价格 | 全部 |
| timestamp | int | Unix 时间戳，单位为毫秒 | 全部 |
| open | string | 开盘价；对应行情统计可用时返回 | 股票、期货、加密货币等 |
| prev\_close | string | 昨收或统计窗口参考价；数据可用时返回 | 股票、期货、加密货币等 |
| ask\_price | string | 最优卖价；报价可用时返回 | 外汇、贵金属、期货等 |
| bid\_price | string | 最优买价；报价可用时返回 | 外汇、贵金属、期货等 |
| spread | string | 买卖价差；报价可用时返回 | 外汇、贵金属 |
| volume\_24h | string | 成交量；统计窗口见上文 | 股票、期货、加密货币 |
| quote\_volume\_24h | string | 与 `volume_24h` 同一统计窗口的成交额；数据可用时返回 | 股票、加密货币等 |
| high\_24h | string | 最高价；统计窗口与 `volume_24h` 一致 | 股票、期货、加密货币 |
| low\_24h | string | 最低价；统计窗口与 `volume_24h` 一致 | 股票、期货、加密货币 |
| price\_change\_24h | string | 价格变化；统计窗口与 `volume_24h` 一致，数据可用时返回 | 股票、期货、加密货币 |
| price\_change\_percent\_24h | string | 价格变化百分比；数据可用时返回 | 股票、期货、加密货币 |
| trade\_session | string | 当前扩展交易时段：`pre_market`、`post_market` 或 `overnight` | 美股扩展交易时段 |
| quote\_volume | string | 当前扩展交易时段成交额；数据可用时返回 | 美股扩展交易时段 |


## AsyncAPI

````yaml asyncapi.json ticker
id: ticker
title: Ticker
description: ''
servers:
  - id: production
    protocol: wss
    host: api.tickdb.ai
    bindings: []
    variables: []
address: /v1/realtime
parameters: []
bindings: []
operations:
  - &ref_3
    id: subscribeToTicker
    title: Subscribe to ticker
    type: send
    messages:
      - &ref_5
        id: tickerData
        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: name
                    type: string
                    description: 产品名称；有数据时返回。
                    required: false
                  - name: type
                    type: string
                    description: 标的类型。
                    enumValues:
                      - stock
                      - indices
                      - crypto
                      - forex
                      - futures
                    required: false
                  - name: category
                    type: string
                    description: 产品细分类别；有数据时返回。
                    required: false
                  - name: last_price
                    type: string
                    description: 最新价。
                    required: true
                  - name: open
                    type: string
                    description: 开盘价；有数据时返回。
                    required: false
                  - name: prev_close
                    type: string
                    description: 昨收价或参考价；有数据时返回。
                    required: false
                  - name: bid_price
                    type: string
                    description: 最优买价；有数据时返回。
                    required: false
                  - name: ask_price
                    type: string
                    description: 最优卖价；有数据时返回。
                    required: false
                  - name: spread
                    type: string
                    description: 外汇或贵金属的买卖价差；有数据时返回。
                    required: false
                  - name: volume_24h
                    type: string
                    description: 成交量；加密货币通常为滚动 24 小时，股票和期货通常为当日或当前交易时段。
                    required: false
                  - name: quote_volume_24h
                    type: string
                    description: 与 volume_24h 相同统计窗口内的成交额；有数据时返回。
                    required: false
                  - name: high_24h
                    type: string
                    description: 与 volume_24h 相同统计窗口内的最高价。
                    required: false
                  - name: low_24h
                    type: string
                    description: 与 volume_24h 相同统计窗口内的最低价。
                    required: false
                  - name: price_change_24h
                    type: string
                    description: 相同统计窗口内的价格变化；有数据时返回。
                    required: false
                  - name: price_change_percent_24h
                    type: string
                    description: 价格变化百分比；有数据时返回。
                    required: false
                  - name: trade_session
                    type: string
                    description: 美股扩展交易时段；适用时返回。
                    enumValues:
                      - pre_market
                      - post_market
                      - overnight
                    required: false
                  - name: quote_volume
                    type: string
                    description: 当前扩展交易时段的成交额；有数据时返回。
                    required: false
                  - name: pre_market_quote
                    type: object
                    description: 盘前行情；有数据时返回。
                    required: false
                  - name: post_market_quote
                    type: object
                    description: 盘后行情；有数据时返回。
                    required: false
                  - name: overnight_quote
                    type: object
                    description: 夜盘行情；有数据时返回。
                    required: false
                  - name: timestamp
                    type: integer
                    description: Unix 时间戳，单位为毫秒。
                    required: true
        headers: []
        jsonPayloadSchema:
          type: object
          additionalProperties: false
          properties:
            cmd:
              type: string
              const: ticker
              description: 消息类型。
              x-parser-schema-id: <anonymous-schema-21>
            data:
              type: object
              additionalProperties: false
              properties:
                symbol:
                  type: string
                  example: AAPL.US
                  description: 交易代码。
                  x-parser-schema-id: <anonymous-schema-23>
                name:
                  type: string
                  description: 产品名称；有数据时返回。
                  x-parser-schema-id: <anonymous-schema-24>
                type:
                  type: string
                  enum:
                    - stock
                    - indices
                    - crypto
                    - forex
                    - futures
                  description: 标的类型。
                  x-parser-schema-id: <anonymous-schema-25>
                category:
                  type: string
                  description: 产品细分类别；有数据时返回。
                  x-parser-schema-id: <anonymous-schema-26>
                last_price:
                  type: string
                  example: '150.25'
                  description: 最新价。
                  x-parser-schema-id: <anonymous-schema-27>
                open:
                  type: string
                  description: 开盘价；有数据时返回。
                  x-parser-schema-id: <anonymous-schema-28>
                prev_close:
                  type: string
                  description: 昨收价或参考价；有数据时返回。
                  x-parser-schema-id: <anonymous-schema-29>
                bid_price:
                  type: string
                  description: 最优买价；有数据时返回。
                  x-parser-schema-id: <anonymous-schema-30>
                ask_price:
                  type: string
                  description: 最优卖价；有数据时返回。
                  x-parser-schema-id: <anonymous-schema-31>
                spread:
                  type: string
                  description: 外汇或贵金属的买卖价差；有数据时返回。
                  x-parser-schema-id: <anonymous-schema-32>
                volume_24h:
                  type: string
                  description: 成交量；加密货币通常为滚动 24 小时，股票和期货通常为当日或当前交易时段。
                  x-parser-schema-id: <anonymous-schema-33>
                quote_volume_24h:
                  type: string
                  description: 与 volume_24h 相同统计窗口内的成交额；有数据时返回。
                  x-parser-schema-id: <anonymous-schema-34>
                high_24h:
                  type: string
                  description: 与 volume_24h 相同统计窗口内的最高价。
                  x-parser-schema-id: <anonymous-schema-35>
                low_24h:
                  type: string
                  description: 与 volume_24h 相同统计窗口内的最低价。
                  x-parser-schema-id: <anonymous-schema-36>
                price_change_24h:
                  type: string
                  description: 相同统计窗口内的价格变化；有数据时返回。
                  x-parser-schema-id: <anonymous-schema-37>
                price_change_percent_24h:
                  type: string
                  description: 价格变化百分比；有数据时返回。
                  x-parser-schema-id: <anonymous-schema-38>
                trade_session:
                  type: string
                  enum:
                    - pre_market
                    - post_market
                    - overnight
                  description: 美股扩展交易时段；适用时返回。
                  x-parser-schema-id: <anonymous-schema-39>
                quote_volume:
                  type: string
                  description: 当前扩展交易时段的成交额；有数据时返回。
                  x-parser-schema-id: <anonymous-schema-40>
                pre_market_quote:
                  type: object
                  description: 盘前行情；有数据时返回。
                  x-parser-schema-id: <anonymous-schema-41>
                post_market_quote:
                  type: object
                  description: 盘后行情；有数据时返回。
                  x-parser-schema-id: <anonymous-schema-42>
                overnight_quote:
                  type: object
                  description: 夜盘行情；有数据时返回。
                  x-parser-schema-id: <anonymous-schema-43>
                timestamp:
                  type: integer
                  example: 1703123456789
                  description: Unix 时间戳，单位为毫秒。
                  x-parser-schema-id: <anonymous-schema-44>
              required:
                - symbol
                - last_price
                - timestamp
              x-parser-schema-id: <anonymous-schema-22>
          required:
            - cmd
            - data
          x-parser-schema-id: <anonymous-schema-20>
        title: 实时行情数据
        description: 实时推送的行情数据。
        example: No examples found
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: tickerData
    bindings: []
    extensions: &ref_1
      - id: x-parser-unique-object-id
        value: ticker
  - &ref_2
    id: receiveTickerData
    title: Receive ticker 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-62>
            data:
              type: object
              additionalProperties: false
              properties:
                channel:
                  type: string
                  enum:
                    - ticker
                    - depth
                    - trade
                  default: ticker
                  description: 频道名称。
                  x-parser-schema-id: <anonymous-schema-64>
                symbols:
                  type: array
                  items:
                    type: string
                    x-parser-schema-id: <anonymous-schema-66>
                  examples: *ref_0
                  description: 要订阅或取消订阅的交易代码列表。
                  x-parser-schema-id: <anonymous-schema-65>
                type:
                  type: string
                  enum:
                    - stock
                    - indices
                    - crypto
                    - forex
                    - futures
                  description: 标的类型，可选；代码无歧义时可不传。若返回 AMBIGUOUS_SYMBOL 错误，请根据提示指定类型。
                  x-parser-schema-id: <anonymous-schema-67>
              required:
                - channel
                - symbols
              x-parser-schema-id: <anonymous-schema-63>
          required:
            - cmd
            - data
          x-parser-schema-id: <anonymous-schema-61>
        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: ticker
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.