# Orderhistories

## Stream orderhistories in an accounts in Standard spot exchange

### ✅ Request

{% tabs %}
{% tab title="Subscription" %}
{% code title="Subscription" %}

```json
{
  "id": 1,
  "method": "spot.orderhistories.subscribe.accounts",
  "params": {
    "addresses": ["0x0000000000000000000000000000000000000000"]
  }
}
```

{% endcode %}
{% endtab %}

{% tab title="Unsubscription" %}
{% code title="Unsubscription" %}

```json
{
  "id": 1,
  "method": "spot.orders.unsubscribe.accounts",
  "params": {
    "addresses": ["0x0000000000000000000000000000000000000000"]
  }
}
```

{% endcode %}
{% endtab %}
{% endtabs %}

### 📤 Response

{% tabs %}
{% tab title="Success" %}
{% code title="Success" %}

```json
{
  "result": null,
  "id": 1
}
```

{% endcode %}
{% endtab %}

{% tab title="Error" %}
{% code title="Error" %}

```json
{
  "code": 1,
  "msg": "Internal Error: {error}"
}
```

{% endcode %}
{% endtab %}
{% endtabs %}

### 📡 Streamed Data Format

{% code title="Order Stream" %}

```json
[
  "spotOrderHistory",
  true,
  78901,
  "0xBaseTokenAddress",
  "ETH",
  "0xQuoteTokenAddress",
  "USDT",
  "ETH/USDT",
  "0xPairContractAddress",
  3150.5,
  "0xAssetAddress",
  "ETH",
  2.0,
  6301.0,
  1713659000,
  "0xUserAddress",
  "0xTransactionHash"
]
```

{% endcode %}

### 📄 Field Descriptions

| Index | Field         | Type      | Description                                |
| ----- | ------------- | --------- | ------------------------------------------ |
| 0     | `eventId`     | `string`  | Unique event identifier                    |
| 1     | `isBid`       | `boolean` | Whether the trade is a bid or ask          |
| 2     | `orderId`     | `integer` | Order ID of the trade                      |
| 3     | `base`        | `string`  | Base token address                         |
| 4     | `baseSymbol`  | `string`  | Symbol of base token                       |
| 5     | `quote`       | `string`  | Quote token address                        |
| 6     | `quoteSymbol` | `string`  | Symbol of quote token                      |
| 7     | `pairSymbol`  | `string`  | Symbol of the trading pair (e.g. ETH/USDT) |
| 8     | `pair`        | `string`  | Contract address of the trading pair       |
| 9     | `price`       | `float`   | Price of the trade                         |
| 10    | `asset`       | `string`  | Asset address involved in the trade        |
| 11    | `assetSymbol` | `string`  | Symbol of the asset                        |
| 12    | `amount`      | `float`   | Amount of the asset traded                 |
| 13    | `placed`      | `float`   | Amount placed (likely base × price)        |
| 14    | `timestamp`   | `integer` | Unix timestamp of the trade                |
| 15    | `account`     | `string`  | Address of the trader or executor          |
| 16    | `txHash`      | `string`  | Transaction hash                           |

### 📡 Streamed Data Format

```json
[
  "deleteSpotOrderHistory"      // eventId
  true,                         // isBid (true = buy order, false = sell order)
  "0xPairContractAddress",      // trading pair contract address
  "0xUserAddress",              // account that placed the order
  123456,                       // orderId
  1713657900                    // timestamp (Unix)
]
```

### 📄 Field Descriptions

| Index | Field       | Type      | Description                                  |
| ----- | ----------- | --------- | -------------------------------------------- |
| 0     | `eventId`   | `string`  | Unique event identifier                      |
| 1     | `isBid`     | `boolean` | `true` for bid (buy), `false` for ask (sell) |
| 2     | `pair`      | `string`  | Address of the trading pair contract         |
| 3     | `account`   | `string`  | Address of the user whose order was removed  |
| 4     | `orderId`   | `number`  | Unique identifier of the deleted order       |
| 5     | `timestamp` | `number`  | Unix timestamp of deletion event             |
