> 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/en-docs/websocket/websocket-subscribe-method/latest-trade-subscription.md).

# 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`                          |
| `includeType` | `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`    |
| `tp`      | String  | No       | Transaction Type                              |                 |

## Transaction Types

### Hong Kong Stocks

* \* – Off-exchange Transaction
* D – Odd Lot Transaction
* M – Non-Automatic Matching
* P – Pre-market Matching Order
* U – Auction Transaction
* X – Same Broker Non-Automatic Matching
* Y – Same Broker Automatic Matching(Blank) – Automatic Matching

### US Stocks

* (Blank) – Automatic Matching
* A – Acquisition
* B – Block Trade
* D – Allocation
* F – Intermarket Sweep Order
* G – Block Sell
* H – Away-from-Market Trade
* I – Odd Lot Transaction
* K – Rule 155 Trade (NYSE Rule)
* M – Exchange Closing Price
* P – Prior Reference Price
* Q – Exchange Opening Price
* S – Split Order Trade
* V – Contingent Trade
* W – Average Price Execution
* X – Cross-Market Transaction
* 1 – Restricted Stock (Regular Trading)
