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

# 市場狀態

> 查詢不同市場當前的交易階段和市場時間。

## 套餐權限

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

## 注意事項

* 這是全局接口，不接受 `market` 或 `symbol` 參數；狀態隨交易時段變化。

## 支持的市場

| 市場 | 示例 |
| - | - |
| 美股 | US |
| 港股 | HK |
| A股 | CN |

## 請求參數

該接口不需要查詢參數。

## 請求示例

```bash theme={null}
curl -H "X-API-Key: YOUR_API_KEY" \
  "https://api.tickdb.ai/v1/fundamentals/market/status"
```

## 返回字段說明

以下列出 `data` 中的字段；外層 `code=0` 表示成功。

| 字段 | 說明 |
| - | - |
| markets | 各市場交易狀態列表。 |
| └─ market | 市場代碼。 |
| └─ market\_time | 該市場的當前時間，RFC 3339 日期時間字符串，包含時區信息。 |
| └─ trade\_status | 交易狀態代碼。 |

返回 `CN`、`HK`、`US` 三個市場的市場時間和交易狀態。

### `trade_status` 狀態碼

不同市場只會返回適用的狀態。常見及特殊交易階段的代碼如下：

| 市場 | 狀態碼 | 含義 |
| - | -: | - |
| CN、HK | `101` | 開市前清算 |
| CN、HK | `102` | 開盤集合競價 |
| CN、HK | `105` | 正常交易 |
| CN、HK | `106` | 午間休市 |
| CN、HK | `107` | 收盤集合競價 |
| CN、HK | `108` | 已收市 |
| CN | `120` | 盤後固定價格交易 |
| CN、HK | `121` | 半日市收市 |
| CN、HK | `122` | 特殊情況下尚未開市 |
| CN、HK | `123` | 盤中臨時休市 |
| US | `201` | 盤前交易 |
| US | `202` | 正常交易 |
| US | `203` | 盤後交易 |
| US | `204` | 已收市 |
| US | `205` | 暫停交易 |
| US | `206` | 開市前清算及盤前時段 |
| US | `207` | 夜盤交易 |
| US | `209` | 盤前清算 |
| US | `210` | 盤後清算 |


## OpenAPI

````yaml openapi.zh-Hant.yaml GET /v1/fundamentals/market/status
openapi: 3.1.0
info:
  title: TickDB API
  description: TickDB 統一即時行情數據 API，提供 REST 和 WebSocket 接入。
  version: 1.0.3
  contact:
    email: support@tickdb.ai
servers:
  - url: https://api.tickdb.ai
    description: 正式環境
security:
  - ApiKeyAuth: []
paths:
  /v1/fundamentals/market/status:
    get:
      tags:
        - fundamentals-events
      summary: 市場狀態
      description: 查詢不同市場當前的交易階段和市場時間。
      operationId: getFundamentalsMarketStatus
      responses:
        '200':
          description: 請求成功。
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/SuccessEnvelope'
                  - type: object
                    properties:
                      data:
                        type: object
                        required:
                          - markets
                        properties:
                          markets:
                            type: array
                            items:
                              type: object
                              required:
                                - market
                                - market_time
                                - trade_status
                              properties:
                                market:
                                  type: string
                                  example: US
                                market_time:
                                  type: string
                                  format: date-time
                                trade_status:
                                  type: integer
        default:
          $ref: '#/components/responses/ErrorResponse'
components:
  schemas:
    SuccessEnvelope:
      type: object
      required:
        - code
        - data
      properties:
        code:
          type: integer
          const: 0
          description: 業務狀態碼，成功為 `0`。
    ErrorEnvelope:
      type: object
      required:
        - code
        - message
      properties:
        code:
          description: TickDB API 業務錯誤碼；可能是整數或字串，客戶端應先轉為字串再比較。
          oneOf:
            - type: integer
            - type: string
        message:
          type: string
          description: 錯誤說明。
        error:
          type: string
          description: 相容錯誤標識；僅部分錯誤回應返回。
        data:
          description: 可選的錯誤上下文；可能是 null、物件或陣列。
          oneOf:
            - type: 'null'
            - type: object
              additionalProperties: true
            - type: array
              items: {}
  responses:
    ErrorResponse:
      description: >-
        錯誤回應。常見 HTTP 狀態包括
        400（參數錯誤）、401（驗證失敗）、403（權限或配額限制）、404（無符合條件的數據）、429（請求頻率限制）及 503（服務暫不可用）。
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorEnvelope'
          examples:
            missingAPIKey:
              summary: 缺少 API Key
              value:
                code: '1002'
                message: API key is required. Provide via X-API-Key header
                error: '1002'
            missingKind:
              summary: 缺少必填參數
              value:
                code: 40001
                message: kind is required
                data: null
            endpointForbidden:
              summary: API Key 無權存取此介面
              value:
                code: 3009
                message: This endpoint is not allowed for your API key
                data: null
            marketForbidden:
              summary: API Key 未開放該市場
              value:
                code: 3010
                message: Fundamentals market not allowed for your API key
                data:
                  market: US
            noAvailableSource:
              summary: 數據暫不可用
              value:
                code: 5003
                message: Data is temporarily unavailable
                data: null
            notFound:
              summary: 無符合條件的數據
              value:
                code: 40404
                message: shareholder detail not found
                data: null
            businessNoData:
              summary: 查詢條件沒有有效業務數據
              value:
                code: 40405
                message: valuation time series not found
                data: null
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-Key

````

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