> For the complete documentation index, see [llms.txt](https://docs.infoway.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.infoway.io/rest-api/http-endpoints/get-trade.md).

# GET获取产品的实时成交明细(Trade)

获取股票、加密货币、外汇、能源、商品等所有产品的实时成交明细

### 接口说明

该接口获取各市场最新成交明细。标的写法见 标的代码约定。

### 请求频率

与其他 HTTP 接口共用[频率限制](/getting-started/api-limitation/http.md)，具体每秒次数由套餐决定。

### 错误码说明

见 [HTTP错误码](/getting-started/error-codes/http.md)。地址总览见 [行情地址说明](/getting-started/api-endpoints.md)。

### 接口地址

| 市场              | 完整路径                                                 |
| --------------- | ---------------------------------------------------- |
| 股票（美股、港股、A 股）   | `https://data.infoway.io/stock/batch_trade/{codes}`  |
| 日本              | `https://data.infoway.io/japan/batch_trade/{codes}`  |
| 印度              | `https://data.infoway.io/india/batch_trade/{codes}`  |
| 韩国              | `https://data.infoway.io/korea/batch_trade/{codes}`  |
| 台湾              | `https://data.infoway.io/taiwan/batch_trade/{codes}` |
| 加密货币            | `https://data.infoway.io/crypto/batch_trade/{codes}` |
| 外汇、能源、商品、贵金属、期货 | `https://data.infoway.io/common/batch_trade/{codes}` |

### 请求头

| 参数       | 类型     | 必填 | 描述         |
| -------- | ------ | -- | ---------- |
| `apiKey` | String | 是  | 套餐 API Key |

### 入参说明

| 参数名             | 类型      | 必填 | 描述                                                                      | 示例值               |
| --------------- | ------- | -- | ----------------------------------------------------------------------- | ----------------- |
| `codes`         | String  | 是  | 路径参数。产品代码，逗号分隔，最多 100 个                                                 | `TSLA.US,AAPL.US` |
| `withMarkPrice` | Boolean | 否  | 仅加密货币接口支持的 Query 参数，默认 `false`。设为 `true` 时，`.P` 合约可追加指数价、标记价、资金费率和持仓量字段 | `true`            |

```http
GET https://data.infoway.io/stock/batch_trade/TSLA.US,AAPL.US
```

### 返回示例

以下数值仅用于展示字段格式。

```json
{
  "ret": 200,
  "msg": "success",
  "traceId": "27bdafb1-c735-4499-aad1-553820284895",
  "data": [
    {
      "s": "TSLA.US",
      "t": 1750177346523,
      "p": "298.310",
      "v": "100",
      "vw": "29831.000",
      "td": 0
    }
  ]
}
```

| 字段名  | 类型     | 描述                           | 示例值             |
| ---- | ------ | ---------------------------- | --------------- |
| `s`  | String | 标的代码                         | `USDCNY`        |
| `t`  | Long   | 成交时间（毫秒时间戳）                  | `1747382898892` |
| `p`  | String | 价格                           | `34.650`        |
| `v`  | String | 成交量                          | `439000`        |
| `vw` | String | **成交额**（不是均价 / VWAP）         | `15211350.000`  |
| `td` | Int    | 交易方向：`0` 默认，`1` Buy，`2` Sell | `0`             |

### 加密货币合约的标记价格与持仓量

在 `/crypto/batch_trade/{codes}` 的 URL 后添加 `?withMarkPrice=true`，可为以 `.P` 结尾的合约请求以下附加字段。该参数默认关闭，不改变 `p` 的成交价格含义，也不适用于其他市场的成交接口。

```http
GET https://data.infoway.io/crypto/batch_trade/BTCUSDT.P?withMarkPrice=true
apiKey: YOUR_API_KEY
```

```json
{
  "ret": 200,
  "msg": "success",
  "traceId": "27bdafb1-c735-4499-aad1-553820284895",
  "data": [
    {
      "s": "BTCUSDT.P",
      "t": 1791817200000,
      "p": "83460.10",
      "v": "0.001",
      "vw": "83.46010",
      "td": 1,
      "indexPx": "83499.49",
      "markPx": "83457.46",
      "fundRate": "0.00004277",
      "fundTime": 1791820800000,
      "openInt": "12345.678",
      "openIntTime": 1791817200000
    }
  ]
}
```

| 字段名           | 类型     | 描述                                           | 示例值             |
| ------------- | ------ | -------------------------------------------- | --------------- |
| `indexPx`     | String | 指数价格；可选                                      | `"83499.49"`    |
| `markPx`      | String | 标记价格；可选                                      | `"83457.46"`    |
| `fundRate`    | String | 最新资金费率的小数值；例如 `0.00004277` 对应 `0.004277%`；可选 | `"0.00004277"`  |
| `fundTime`    | Long   | 下次资金费用结算时间，Unix 毫秒时间戳；可选                     | `1791820800000` |
| `openInt`     | String | 持仓量；可选                                       | `"12345.678"`   |
| `openIntTime` | Long   | 持仓量时间，Unix 毫秒时间戳；可选                          | `1791817200000` |

附加字段仅在开启参数、代码以 `.P` 结尾且对应数据可用时返回。现货或未开启参数时不返回这些字段。四个字符串字段在值为 `null` 时省略，数值保留字符串格式；`fundTime` 和 `openIntTime` 仅在值大于 0 时返回。以上数值为格式示例。
