# Account Order Updates Stream

Pushed when order created, order status changed.

## Update Speed

* Pushed on each block.

## Subscribe Request

* Subscribe Schema

See [`WsOrderUpdateSubscriptionParams`](https://sodex.com/documentation/rest-v1/schema#wsorderupdatesubscriptionparams) 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: WsOrderUpdateSubscriptionParams;
}
```

* Subscribe Ack Schema

See [`WsOrderUpdateSubscriptionResult`](https://sodex.com/documentation/rest-v1/schema#wsorderupdatesubscriptionresult) 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: WsOrderUpdateSubscriptionResult | 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": "accountOrderUpdate",
    "user": "0xed3e79ef16a7890e6eaef2aa6373b6bec5d59d5c",
    "symbols": ["vBTC_vUSDC", "vETH_vUSDC"]
  }
}
```

* Example: Subscribe Ack

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

## Unsubscribe Request

* Unsubscribe Schema

See [`WsOrderUpdateSubscriptionParams`](https://sodex.com/documentation/rest-v1/schema#wsorderupdatesubscriptionparams) 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: WsOrderUpdateSubscriptionParams;
}
```

* Unsubscribe Ack Schema

See [`WsOrderUpdateSubscriptionResult`](https://sodex.com/documentation/rest-v1/schema#wsorderupdatesubscriptionresult) 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: WsOrderUpdateSubscriptionResult | 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": "accountOrderUpdate",
    "user": "0xed3e79ef16a7890e6eaef2aa6373b6bec5d59d5c",
    "symbols": ["vBTC_vUSDC"]
  }
}
```

* Example: Unsubscribe Ack

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

## Update Response

* Update Schema

See [`WsSpotOrderUpdate`](https://sodex.com/documentation/rest-v1/schema#wsspotorderupdate), [`WsPerpsOrderUpdate`](https://sodex.com/documentation/rest-v1/schema#wsperpsorderupdate) in [Schema](https://sodex.com/documentation/api/rest-v1/schema).

```typescript
interface OrderUpdateResponse {
  channel: "accountOrderUpdate";
  type: "update";
  data: WsSpotOrderUpdate | WsPerpsOrderUpdate;
}
```

* Example: Update

```json
{
  "channel": "accountOrderUpdate",
  "type": "update",
  "data": [
    {
      "E": 1766849004730,
      "s": "vBTC_vUSDC",
      "c": "MAKER-ADJUST-0-70399739516726",
      "i": 58119,
      "S": "SELL",
      "o": "LIMIT",
      "f": "GTC",
      "p": "102650",
      "q": "0.36734",
      "X": "NEW",
      "z": "0",
      "v": "0",
      "M": "0.36734",
      "T": 1766848473207,
      "x": "REPLACED"
    },
    {
      "E": 1766849004730,
      "s": "vBTC_vUSDC",
      "c": "MAKER-ADJUST-0-34207928167487",
      "i": 58117,
      "S": "SELL",
      "o": "LIMIT",
      "f": "GTC",
      "p": "102514",
      "q": "0.69346",
      "X": "PARTIALLY_FILLED",
      "z": "0.00043",
      "v": "44.08102",
      "M": "0.69303",
      "T": 1766848473207,
      "t": 6860,
      "l": "0.00021",
      "L": "102514",
      "n": "0",
      "m": true,
      "x": "PARTIALLY_FILLED"
    },
    {
      "E": 1766849004730,
      "s": "vETH_vUSDC",
      "c": "MAKER-ADJUST-1-24418479600808",
      "i": 58137,
      "S": "SELL",
      "o": "LIMIT",
      "f": "GTC",
      "p": "3483.3",
      "q": "5.5874",
      "X": "PARTIALLY_FILLED",
      "z": "0.0306",
      "v": "106.62669",
      "M": "5.5568",
      "T": 1766848473207,
      "x": "REPLACED"
    },
    {
      "E": 1766849004730,
      "s": "vETH_vUSDC",
      "c": "MAKER-ADJUST-1-90786519701005",
      "i": 58139,
      "S": "SELL",
      "o": "LIMIT",
      "f": "GTX",
      "p": "3488.6",
      "q": "11.8604",
      "X": "NEW",
      "z": "0",
      "v": "0",
      "M": "11.8604",
      "T": 1766848473207,
      "x": "REPLACED"
    }
  ]
}
```
