# Account Trades Stream

Fast trade stream reduces data latency compared to the original Account Order Updates stream. However, it only pushes TRADE Execution Type, and fewer data fields.

## Update Speed

* Pushed on each block.

## Subscribe Request

* Subscribe Schema

See [`WsUserTradeSubscriptionParams`](https://sodex.com/documentation/rest-v1/schema#wsusertradesubscriptionparams) in [Schema](https://sodex.com/documentation/api/rest-v1/schema).

```typescript
interface SubscribeRequest {
  op: "subscribe";
  id: number | null; // Optional client originated request identifier sent as acknowledgment in the response.
  params: WsUserTradeSubscriptionParams;
}
```

* Subscribe Ack Schema

See [`WsUserTradeSubscriptionResult`](https://sodex.com/documentation/rest-v1/schema#wsusertradesubscriptionresult) in [Schema](https://sodex.com/documentation/api/rest-v1/schema).

```typescript
interface SubscriptionResult {
  op: "subscribe";
  id: number | null; // Optional client originated request identifier sent as acknowledgment in the response.
  result: WsUserTradeSubscriptionResult | null;
  success: boolean; // Indicates if the request was successfully processed by the engine.
  connID: string;
  error: string | null; // Condition: If success is false. Error message.
  time_in: number; // The timestamp when the subscription was received on the wire, just prior to parsing data, in milliseconds.
  time_out: number; // The timestamp when the acknowledgement was sent on the wire, just prior to transmitting data, in milliseconds.
}
```

* Example: Subscribe

```json
{
  "op": "subscribe",
  "params": {
    "channel": "accountTrade",
    "user": "0xed3e79ef16a7890e6eaef2aa6373b6bec5d59d5c",
    "symbols": ["vBTC_vUSDC", "vETH_vUSDC"]
  }
}
```

* Example: Subscribe Ack

```json
{
  "op": "subscribe",
  "result": {
    "channel": "accountTrade",
    "user": "0xed3e79ef16a7890e6eaef2aa6373b6bec5d59d5c",
    "accountID": 1001,
    "symbol": "vBTC_vUSDC"
  },
  "success": true,
  "connID": "0xb0922dfe2b14dadb1195ea4db2b45508",
  "time_in": 1672515782130,
  "time_out": 1672515782136
}
{
  "op": "subscribe",
  "result": {
    "channel": "accountTrade",
    "user": "0xed3e79ef16a7890e6eaef2aa6373b6bec5d59d5c",
    "accountID": 1001,
    "symbol": "vETH_vUSDC"
  },
  "success": true,
  "connID": "0xb0922dfe2b14dadb1195ea4db2b45508",
  "time_in": 1672515782130,
  "time_out": 1672515782136
}
```

## Unsubscribe Request

* Unsubscribe Schema

See [`WsUserTradeSubscriptionParams`](https://sodex.com/documentation/rest-v1/schema#wsusertradesubscriptionparams) in [Schema](https://sodex.com/documentation/api/rest-v1/schema).

```typescript
interface UnsubscribeRequest {
  op: "unsubscribe";
  id: number | null; // Optional client originated request identifier sent as acknowledgment in the response.
  params: WsUserTradeSubscriptionParams;
}
```

* Unsubscribe Ack Schema

See [`WsUserTradeSubscriptionResult`](https://sodex.com/documentation/rest-v1/schema#wsusertradesubscriptionresult) in [Schema](https://sodex.com/documentation/api/rest-v1/schema).

```typescript
interface UnsubscriptionResult {
  op: "unsubscribe";
  id: number | null; // Optional client originated request identifier sent as acknowledgment in the response.
  result: WsUserTradeSubscriptionResult | null;
  success: boolean; // Indicates if the request was successfully processed by the engine.
  connID: string;
  error: string | null; // Condition: If success is false. Error message.
  time_in: number; // The timestamp when the subscription was received on the wire, just prior to parsing data, in milliseconds.
  time_out: number; // The timestamp when the acknowledgement was sent on the wire, just prior to transmitting data, in milliseconds.
}
```

* Example: Unsubscribe

```json
{
  "op": "unsubscribe",
  "params": {
    "channel": "accountTrade",
    "user": "0xed3e79ef16a7890e6eaef2aa6373b6bec5d59d5c",
    "symbols": ["vBTC_vUSDC"]
  }
}
```

* Example: Unsubscribe Ack

```json
{
  "op": "unsubscribe",
  "result": {
    "channel": "accountTrade",
    "user": "0xed3e79ef16a7890e6eaef2aa6373b6bec5d59d5c",
    "accountID": 1001,
    "symbol": "vBTC_vUSDC"
  },
  "success": true,
  "connID": "0xb0922dfe2b14dadb1195ea4db2b45508",
  "time_in": 1672515782130,
  "time_out": 1672515782136
}
```

## Update Response

* Update Schema

See [`WsSpotUserTrade`](https://sodex.com/documentation/rest-v1/schema#wsspotusertrade), [`WsPerpsUserTrade`](https://sodex.com/documentation/rest-v1/schema#wsperpsusertrade) in [Schema](https://sodex.com/documentation/api/rest-v1/schema).

```typescript
interface UserTradeResponse {
  channel: "accountTrade";
  type: "update";
  data: Array<WsSpotUserTrade> | Array<WsPerpsUserTrade>;
}
```

* Example: Update

```json
{
  "channel": "accountTrade",
  "type": "update",
  "data": [
    {
      "E": 1766848149693,
      "T": 1766847863273,
      "t": 6275,
      "s": "vETH_vUSDC",
      "i": 51101,
      "c": "MAKER-ADJUST-1-51126829939055",
      "S": "BUY",
      "p": "3511.6",
      "q": "0.0268",
      "f": "0",
      "m": true
    },
    {
      "E": 1766848149693,
      "T": 1766847863273,
      "t": 6276,
      "s": "vETH_vUSDC",
      "i": 51102,
      "c": "MAKER-ADJUST-1-75689534218758",
      "S": "SELL",
      "p": "3519.9",
      "q": "0.0096",
      "f": "0",
      "m": true
    }
  ]
}
```
