> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ekiden.fi/llms.txt
> Use this file to discover all available pages before exploring further.

# Trade

Subscribe to real-time trades for a symbol.

* Topic: `trade.<symbol>` (e.g., `trade.BTC-USDC`)
* Stream: Public (`wss://api.ekiden.fi/ws/public`)

## Subscribe

```json theme={null}
{ "op": "subscribe", "args": ["trade.BTC-USDC"], "req_id": "102001" }
```

Ack:

```json theme={null}
{ "op": "subscribed", "args": ["trade.BTC-USDC"], "req_id": "102001" }
```

## Events

Messages arrive with `op: "event"`, `topic: "trade.<symbol>"`, and `data` containing an array of `PublicTrade`.

Example:

```json theme={null}
{
	"op": "event",
	"topic": "trade.BTC-USDC",
	"server_ts_ms": 1731541800000,
	"data": [
		{ "i": "9723498234", "s": "BTC-USDC", "S": "Buy",  "p": "100200", "v": "1", "seq": 12345, "T": "1718000000000" },
		{ "i": "7349823987", "s": "BTC-USDC", "S": "Sell", "p": "100100", "v": "2", "seq": 12346, "T": "1718000001000" }
	]
}
```

Notes:

* `p` (price) and `v` (size) are strings to preserve precision.
* `T` is the trade timestamp in milliseconds (encoded as a string).
* `server_ts_ms` is the gateway processing time in milliseconds.

See schema details in [AsyncAPI](../websockets/public): `PublicTrade`.

### Trade ID

Field `i` is a stable string identifier for a given trade and unique within a market.

You can treat `i` + `s` as a primary key. Do not assume ordering by `i`; rely on `seq` and `T`.
