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