# Mark Price Stream

Mark price and funding rate for a single symbol pushed on update.

## Update Speed

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

## Subscribe Request

* Subscribe Schema

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

* Subscribe Ack Schema

See [`WsMarkPriceSubscriptionResult`](https://sodex.com/documentation/rest-v1/schema#wsmarkpricesubscriptionresult) 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: WsMarkPriceSubscriptionResult | 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": "markPrice",
    "symbols": ["BTC-USD"]
  }
}
```

* Example: Subscribe Ack

```json
{
  "op": "subscribe",
  "result": {
    "channel": "markPrice",
    "symbol": "BTC-USD"
  },
  "success": true,
  "connID": "0xcd5f500fa81f764e2eb96d4bd68695c1",
  "time_in": 1672515782130,
  "time_out": 1672515782136
}
```

## Unsubscribe Request

* Unsubscribe Schema

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

* Unsubscribe Ack Schema

See [`WsMarkPriceSubscriptionResult`](https://sodex.com/documentation/rest-v1/schema#wsmarkpricesubscriptionresult) 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: WsMarkPriceSubscriptionResult | 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": "markPrice",
    "symbols": ["BTC-USD"]
  }
}
```

* Example: Unsubscribe Ack

```json
{
  "op": "unsubscribe",
  "result": {
    "channel": "markPrice",
    "symbol": "BTC-USD"
  },
  "success": true,
  "connID": "0xcd5f500fa81f764e2eb96d4bd68695c1",
  "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 MarkPriceResponse {
  channel: "markPrice";
  type: "snapshot" | "update";
  data: Array<WsMarkPriceData>;
}
```

* Example: Snapshot

```json
{
  "channel": "markPrice",
  "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": "markPrice",
  "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
    }
  ]
}
```
