# Latest Trade Subscription

### **Overview**

This page provides detailed documentation on how to subscribe to **real-time trade detail data (Trade)** using the WebSocket API.\
Through this interface, users can receive continuous trade updates in real time, including transaction prices, volumes, directions, and timestamps for various products such as stocks, cryptocurrencies, forex, and futures.\
It explains how to establish a connection, manage request frequency, handle responses, and interpret the push data format for efficient integration into trading systems or analytics platforms.

### **Request Frequency**

For a single WebSocket connection, all requests (subscribe, unsubscribe, heartbeat) are limited to 60 times per minute. If the request frequency limit is exceeded, the connection will be automatically closed. If disconnections occur too frequently, and the system deems them to be malicious requests, the API key will be banned. Please be mindful of the calling logic during usage.

### **Error Code Explanation**

Please refer to the [WebSocket error code](/en-docs/getting-started/error-codes/websocket-error-codes.md) documentation for further details.

### **Subscription Address**

Please refer to the [WebSocket subscription addresses.](/en-docs/websocket/subscription-address.md)

### **Request Quantity**

Different subscription plans allow varying numbers of products per WebSocket subscription. Please refer to the [WebSocket restrictions](/en-docs/getting-started/api-limitation/websocket-limitation.md) documentation for specific details.

### Request (Protocol Number: 10000)

```json
{
    "code": 10000,
    "trace": "423afec425004bd8a5e02e1ba5f9b2b0",
    "data": {
        "codes": "BTCUSDT",
        "includeTy": false
    }
}
```

| Parameter | Type      | Required | Description                                       | Eaxmple                            |
| --------- | --------- | -------- | ------------------------------------------------- | ---------------------------------- |
| `code`    | `Integer` | Yes      | Protocol number for the request                   | `10000`                            |
| `trace`   | `String`  | Yes      | Trace ID (random string)                          | `423afec425004bd8a5e02e1ba5f9b2b0` |
| `data`    | `JSON`    | Yes      | Subscription data                                 |                                    |
| `codes`   | `String`  | Yes      | Subscribed symbol (separate multiple with commas) | `BTCUSDT`                          |
| includeTy | Boolean   | False    | Trade type.                                       | false                              |

### Response (Protocol Number: 10001)

```
{
    "code": 10001,
    "trace": "423afec425004bd8a5e02e1ba5f9b2b0",
    "msg": "ok"
}
```

| Parameter | Type      | Required | Description               | Eaxmple                            |
| --------- | --------- | -------- | ------------------------- | ---------------------------------- |
| `code`    | `Integer` | Yes      | Response protocol number  | `10001`                            |
| `trace`   | `String`  | Yes      | Trace ID from the request | `423afec425004bd8a5e02e1ba5f9b2b0` |
| `msg`     | `String`  | Yes      | Response message          | `ok`                               |

### Push (Protocol Number: 10002)

```
{
    "code": 10002,
    "data": {
        "p": "103482.94",
        "s": "BTCUSDT",
        "t": 1747552358393,
        "td": 2,
        "v": "0.00096",
        "vw": "99.3436224"
    }
}
```

| Parameter | Type    | Required | Description                                   | Example Value   |
| --------- | ------- | -------- | --------------------------------------------- | --------------- |
| `code`    | Integer | Yes      | Push protocol number                          | `10002`         |
| `data`    | JSON    | Yes      | Push data entity                              |                 |
| `s`       | String  | Yes      | Symbol name                                   | `BTCUSDT`       |
| `p`       | String  | Yes      | Current price                                 | `103482.94`     |
| `t`       | Long    | Yes      | Trade timestamp                               | `1747552358393` |
| `td`      | Integer | Yes      | Trade direction (0: default, 1: Buy, 2: Sell) | `2`             |
| `v`       | String  | Yes      | Trade volume                                  | `0.00096`       |
| `vw`      | String  | Yes      | Trade value                                   | `99.3436224`    |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.infoway.io/en-docs/websocket/websocket-subscribe-method/latest-trade-subscription.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
