> 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/funding.md).

# Funding

Real-time funding rates and next funding time for futures pairs.

Use this stream to show the funding each side of a position will pay or receive at the next funding time.

### Endpoint

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

### Authentication

No authentication required.

### Message Envelope

| Field | Type    | Description                      |
| ----- | ------- | -------------------------------- |
| `pi`  | integer | Pair ID                          |
| `nft` | integer | Next funding time, epoch ms      |
| `iv`  | integer | Funding interval, ms             |
| `elr` | number  | Funding rate for long positions  |
| `esr` | number  | Funding rate for short positions |

### Message Types

| Type                        | Direction       | Description                                                                                    |
| --------------------------- | --------------- | ---------------------------------------------------------------------------------------------- |
| `subscribe` / `unsubscribe` | Client → Server | Start or stop pairs                                                                            |
| Funding                     | Server → Client | Current funding state 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 funding frame arrives immediately. With `all: true`, frames arrive as each pair's funding is refreshed.

### When Frames Are Sent

Funding rates are refreshed periodically, and a frame is sent on each refresh. Each frame is the complete funding state of one pair — replace the previous value.

### Funding Rules

* Funding is settled every 8 hours, at 00:00, 08:00 and 16:00 UTC. `nft` is the next of these times.
* Rates are fractions per funding interval: `0.0001` = 0.01 %.
* Each side has its own rate. **Positive = the side pays, negative = the side receives.**
* Funding amount for a position = position size × mark price × rate of its side. The amount a receiving side gets can be capped by what the paying side contributes.

### Funding Payload

```json
{
  "pi": 1,
  "nft": 1790668800000,
  "iv": 28800000,
  "elr": 0.00012,
  "esr": -0.00008
}
```

| Field | Type    | Description                                                     |
| ----- | ------- | --------------------------------------------------------------- |
| `pi`  | integer | Pair ID                                                         |
| `nft` | integer | Next funding time, epoch ms, UTC                                |
| `iv`  | integer | Funding interval in ms (`28800000` = 8 hours)                   |
| `elr` | number  | Rate applied to long positions at `nft`; positive = longs pay   |
| `esr` | number  | Rate applied to short positions at `nft`; positive = shorts pay |

### Python Example

{% code title="funding.py" %}

```python
import asyncio
import json
from datetime import datetime, timezone
from decimal import Decimal

import websockets

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


def pct(rate):
    return f"{rate * 100:+.4f}%"


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
            nft = datetime.fromtimestamp(msg["nft"] / 1000, tz=timezone.utc)
            print(f"pair {msg['pi']}: long {pct(msg['elr'])}, short {pct(msg['esr'])}, "
                  f"next funding {nft:%Y-%m-%d %H:%M} UTC")


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/funding.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.
