> For the complete documentation index, see [llms.txt](https://docs.hello.trade/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.hello.trade/developer-tools/websocket-api/market-data/live-trades.md).

# Live Trades

Real-time trade execution data.

**Channel:** `trades`

## Overview

The trades channel provides real-time trade executions for subscribed instruments. Each trade includes price, quantity, and timestamp information.

## Connection

Connect to the WebSocket endpoint:

```
wss://marketdata.app.hello.trade/ws
```

## Subscription Request

```json
{
  "type": "subscribe",
  "channel": "trades",
  "symbols": ["BTC", "ETH"],
  "limit": 1
}
```

| Field     | Type      | Required | Description                                                    |
| --------- | --------- | -------- | -------------------------------------------------------------- |
| `type`    | string    | Yes      | Must be `"subscribe"`                                          |
| `channel` | string    | Yes      | Must be `"trades"`                                             |
| `symbols` | string\[] | Yes      | List of instrument symbols                                     |
| `limit`   | Number    | No       | Number of recent trades to return on subscription (default: 1) |

## Unsubscription Request

```json
{
  "type": "unsubscribe",
  "channel": "trades",
  "symbols": ["BTC"]
}
```

## Response

```json
{
  "type": "marketData",
  "channel": "trades",
  "data": {
    "symbol": "BTC",
    "price": "45000.50",
    "quantity": "0.5",
    "timestamp": 1705596400000
  }
}
```

| Field       | Type   | Description                                      |
| ----------- | ------ | ------------------------------------------------ |
| `symbol`    | string | Instrument symbol                                |
| `price`     | string | Trade execution price                            |
| `quantity`  | string | Trade quantity                                   |
| `timestamp` | Number | Unix timestamp (milliseconds) of trade execution |

## Error Response

```json
{
  "type": "error",
  "message": "Invalid subscription request",
  "code": 400
}
```

## Notes

* Trades are sent in real-time as they occur
* Includes symbol, price, quantity, and timestamp information
