> ## Documentation Index
> Fetch the complete documentation index at: https://docs.polynode.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Python Settlement Stream

> Consume acknowledged Python settlement subscriptions with reconnect replay, deduplication, and overflow visibility.

The event client is asynchronous. `send()` returns only after the server acknowledges the subscription.

```python theme={null}
import asyncio
import os
from polynode import AsyncPolyNode

async def main() -> None:
    async with AsyncPolyNode(api_key=os.environ["POLYNODE_API_KEY"]) as pn:
        sub = await (
            pn.ws.subscribe("settlements")
            .status("all")
            .min_size(100)
            .send()
        )

        print({"subscription_id": sub.id, "warnings": sub.warnings})

        sub.on("settlement", lambda event: print(
            "pending", event.tx_hash, event.taker_size
        ))
        sub.on("status_update", lambda event: print(
            "confirmed", event.tx_hash, event.block_number
        ))
        sub.on_overflow(lambda notice: print("consumer fell behind", notice))
        pn.ws.on_replay(lambda notice: print("reconnect replay", notice))

        try:
            async for event in sub:
                if event.event_type == "unknown":
                    print("new event type", event.wire_event_type, event.raw)
        finally:
            sub.unsubscribe()
            pn.ws.disconnect()

asyncio.run(main())
```

Current presets are `settlements`, `trades`, `prices`, `dome`, `fills`, `combos`, `redemptions`, `redemption`, `deposits`, `blocks`, `wallets`, `markets`, `large_trades`, `global`, `oracle`, and `chainlink`.

Builder filters include wallets, tokens, market IDs, slugs, condition IDs, side, direction, status, size bounds, event types, initial snapshot count, reconnect `since`, Chainlink feeds and TWAP windows, combo and leg IDs, event IDs, module IDs, and action.

```python theme={null}
import time

fills = await (
    pn.ws.subscribe("fills")
    .wallets(["0x..."])
    .condition_ids(["0x..."])
    .since(int(time.time() * 1000) - 30_000)
    .send()
)
```

On reconnect, the SDK replays from the latest accepted timestamp with a small overlap and deduplicates that overlap. Replay is best effort within retained server history, not an unlimited delivery guarantee. Backfill through V3 if durable completeness matters.

The iterator queue is bounded. `on_overflow` makes local loss observable. Short-form rotation has a separate lifecycle: it closes and reconnects its dedicated socket at each market boundary. See [Python short-form](/sdks/python/short-form).

Read the [shared settlement guide](/sdks/websocket-streaming) for the complete delivery contract.
