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

### 字段說明

字段名中的 `24h` 不代表所有市場都按滾動 24 小時統計：加密貨幣通常採用滾動 24 小時，股票和期貨通常採用當日或當前交易時段口徑。除 `symbol`、`last_price`、`timestamp` 外，字段按產品類型和數據可用性返回。

| 字段 | 類型 | 描述 | 市場 |
| - | - | - | - |
| 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.zh-Hant.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.