> ## 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 股、港股、美股） | ✅ |
| 企业版 | ✅ |

## 注意事项

* side：买入（buy）/ 卖出（sell）/ 中性（neutral）
* 时间戳单位为毫秒（UTC）

## 支持的市场

| 市场 | 示例 |
| - | - |
| 美股 | AAPL.US, TSLA.US, MSFT.US |
| 港股 | 700.HK, 9988.HK, 3690.HK |
| A股 | 600519.SH, 000001.SZ, 920186.BJ |
| 中国期货 | BU2609, IC2606, AP8888 |
| 香港期货 | HSI8888, MHI8888, HTI8888 |
| 加密货币 | BTCUSDT, ETHUSDT, ADAUSDT |

## 请求参数

| 参数名 | 是否必须 | 描述 |
| - | - | - |
| symbol | 是 | 交易产品代码 |
| limit | 否 | 返回成交记录数，默认100，最大1000 |
| type | 否 | 产品类型，可选。代码无歧义时无需传递；若返回 `AMBIGUOUS_SYMBOL` 错误，按提示传入对应值即可。可选值：`stock`、`indices`、`crypto`、`forex`、`futures` |

## 返回字段说明

| 字段 | 说明 |
| - | - |
| symbol | 交易产品 |
| type | 产品类型 |
| trades | 成交记录数组 |
| └─ id | 成交ID |
| └─ price | 成交价格 |
| └─ quantity | 成交数量 |
| └─ side | 成交方向（`buy`、`sell` 或 `neutral`） |
| └─ timestamp | 成交时间（毫秒时间戳，UTC） |
| └─ open\_interest\_change | 持仓变化，仅期货返回 |
| └─ position\_effect | 持仓影响，仅期货返回；取值见下表 |

### `position_effect` 取值说明

| 类型 | 取值 |
| - | - |
| 开仓 | `long_open`（多开） `short_open`（空开） `both_open`（双开） |
| 平仓 | `long_close`（多平） `short_close`（空平） `both_close`（双平） |
| 换手 | `long_transfer`（多换） `short_transfer`（空换） |


## OpenAPI

````yaml openapi.yaml GET /v1/market/trades
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/market/trades:
    get:
      summary: 逐笔成交
      description: 获取交易品种的逐笔成交记录。
      parameters:
        - name: symbol
          in: query
          required: true
          description: 交易产品代码
          schema:
            type: string
            default: 700.HK
            example: 700.HK
        - name: limit
          in: query
          required: false
          description: 返回成交记录数，默认100，最大1000
          schema:
            type: integer
            minimum: 1
            maximum: 1000
            example: 100
        - name: type
          in: query
          required: false
          description: >-
            产品类型，可选。代码无歧义时无需传递；若返回 `AMBIGUOUS_SYMBOL`
            错误，按提示传入对应值即可。可选值：`stock`、`indices`、`crypto`、`forex`、`futures`
          schema:
            type: string
            enum:
              - stock
              - indices
              - crypto
              - forex
              - futures
            example: stock
      responses:
        '200':
          description: 请求成功。
          content:
            application/json:
              schema:
                type: object
                properties:
                  code:
                    type: integer
                    example: 0
                  message:
                    type: string
                    example: success
                  data:
                    type: object
                    properties:
                      symbol:
                        type: string
                        example: BU2609
                      type:
                        type: string
                        enum:
                          - stock
                          - indices
                          - crypto
                          - forex
                          - futures
                        example: futures
                      trades:
                        type: array
                        items:
                          type: object
                          properties:
                            id:
                              type: string
                              example: 1703123456789_0
                            price:
                              type: string
                              example: '4315.00'
                            quantity:
                              type: string
                              example: '2'
                            side:
                              type: string
                              enum:
                                - buy
                                - sell
                                - neutral
                              example: sell
                            timestamp:
                              type: integer
                              example: 1703123456789
                            open_interest_change:
                              type:
                                - integer
                                - 'null'
                              description: 持仓变化，仅期货返回
                              example: 0
                            position_effect:
                              type: string
                              description: 持仓影响，仅期货返回；取值见下表
                              enum:
                                - long_open
                                - short_open
                                - both_open
                                - long_close
                                - short_close
                                - both_close
                                - long_transfer
                                - short_transfer
                              example: short_transfer
components:
  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.