> For the complete documentation index, see [llms.txt](https://docs.outpoll.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.outpoll.com/api/futures-api/websockets/futures-market-data/mark-price.md).

# Mark Price

Real-time mark price for futures pairs.

Use this stream to follow the mark price — the fair price the exchange uses for risk checks such as liquidation. The mark price differs from the last traded price; do not use one in place of the other.

### Endpoint

```
wss://futures-marketdata-service.outpoll.com/ws/mark-price
```

### Authentication

No authentication required.

### Message Envelope

| Field | Type    | Description                |
| ----- | ------- | -------------------------- |
| `pi`  | integer | Pair ID                    |
| `mp`  | number  | Mark price                 |
| `t`   | integer | Calculation time, epoch ms |

### Message Types

| Type                        | Direction       | Description                                                                                    |
| --------------------------- | --------------- | ---------------------------------------------------------------------------------------------- |
| `subscribe` / `unsubscribe` | Client → Server | Start or stop pairs                                                                            |
| Mark price                  | Server → Client | New mark price of one pair                                                                     |
| Error                       | Server → Client | `{"er", "msg"}` — see [Errors](broken://pages/7b60c6363e2dcb27a5c7d2ef03222a2bd85342c5#errors) |
| `ping` / `pong`             | Both            | Plain-text keep-alive                                                                          |

### Subscribe

```json
{"act": "subscribe", "pi": 1}
```

Every pair:

```json
{"act": "subscribe", "all": true}
```

Server confirmation: there is no confirmation frame. When you subscribe by pair ID, the pair's current mark price arrives immediately. With `all: true`, mark prices arrive as each pair's value changes.

### When Frames Are Sent

The mark price is recalculated on a fixed short cycle. A frame is sent only when the value **changes**; while it stays the same, nothing is sent. Silence on this stream does not mean the connection is broken — use `ping` to check.

### Mark Price Payload

```json
{
  "pi": 1,
  "mp": 64248.7,
  "t": 1790662754945
}
```

| Field | Type    | Description                             |
| ----- | ------- | --------------------------------------- |
| `pi`  | integer | Pair ID                                 |
| `mp`  | number  | Mark price                              |
| `t`   | integer | Time the value was calculated, epoch ms |

### Python Example

{% code title="mark\_price.py" %}

```python
import asyncio
import json
from decimal import Decimal

import websockets

URL = "wss://futures-marketdata-service.outpoll.com/ws/mark-price"


async def main():
    async with websockets.connect(URL) as ws:
        await ws.send(json.dumps({"act": "subscribe", "ps": [1, 2]}))
        async for raw in ws:
            if raw == "pong":
                continue
            msg = json.loads(raw, parse_float=Decimal)
            if "er" in msg:
                print("error:", msg)
                continue
            print(f"pair {msg['pi']} mark price {msg['mp']} at {msg['t']}")


asyncio.run(main())
```

{% endcode %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.outpoll.com/api/futures-api/websockets/futures-market-data/mark-price.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
