# All Mark Prices Stream

Mark price and funding rate for all symbols pushed on updating. **Note that only tickers that have changed will be present in the array**.

## Update Speed

* Pushed on each block that is at least 1 second since the last push.

## Subscribe Request

* Subscribe Schema

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

* Subscribe Ack Schema

See [`WsAllMarkPriceSubscriptionResult`](https://sodex.com/documentation/rest-v1/schema#wsallmarkpricesubscriptionresult) 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: WsAllMarkPriceSubscriptionResult | 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": "allMarkPrice"
  }
}
```

* Example: Subscribe Ack

```json
{
  "op": "subscribe",
  "result": {
    "channel": "allMarkPrice"
  },
  "success": true,
  "connID": "0xb0922dfe2b14dadb1195ea4db2b45508",
  "time_in": 1672515782130,
  "time_out": 1672515782136
}
```

## Unsubscribe Request

* Unsubscribe Schema

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

* Unsubscribe Ack Schema

See [`WsAllMarkPriceSubscriptionResult`](https://sodex.com/documentation/rest-v1/schema#wsallmarkpricesubscriptionresult) 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: WsAllMarkPriceSubscriptionResult | 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": "allMarkPrice"
  }
}
```

* Example: Unsubscribe Ack

```json
{
  "op": "unsubscribe",
  "result": {
    "channel": "allMarkPrice"
  },
  "success": true,
  "connID": "0xb0922dfe2b14dadb1195ea4db2b45508",
  "time_in": 1672515782130,
  "time_out": 1672515782136
}
```

## Snapshot / Update Response

* Snapshot / Update Schema

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

```typescript
interface AllMarkPriceResponse {
  channel: "allMarkPrice";
  type: "snapshot" | "update";
  data: Array<WsMarkPriceData>;
}
```

* Example: Snapshot

```json
{
  "channel": "allMarkPrice",
  "type": "snapshot",
  "data": [
    {
      "E": 1766850625430,
      "s": "BTC-USD",
      "oi": "0",
      "p": "107631.584573417887609123",
      "i": "107702.323374585090119433",
      "r": "0.0000125",
      "T": 1766851200000
    },
    {
      "E": 1766850625430,
      "s": "ETH-USD",
      "oi": "0",
      "p": "3683.160423511361984797",
      "i": "3682.41578210670614588",
      "r": "0.0000125",
      "T": 1766851200000
    }
  ]
}
```

* Example: Update

```json
{
  "channel": "allMarkPrice",
  "type": "update",
  "data": [
    {
      "E": 1766850625430,
      "s": "BTC-USD",
      "oi": "0",
      "p": "107631.584573417887609123",
      "i": "107702.323374585090119433",
      "r": "0.0000125",
      "T": 1766851200000
    },
    {
      "E": 1766850625430,
      "s": "ETH-USD",
      "oi": "0",
      "p": "3683.160423511361984797",
      "i": "3682.41578210670614588",
      "r": "0.0000125",
      "T": 1766851200000
    }
  ]
}
```
