Skip to content

betting_combat.providers.polymarket.stream

stream.py — Polymarket’s sockets, each a reconnecting loop that yields typed messages.

IntlMarketStream intl CLOB market socket (public): ``Book`` snapshots, ``PriceChange``
(a level's new size, with the best bid/ask), ``LastTrade``, ``Resolved``
SportsStream intl sports socket (public): ``SportsState`` per game; UFC kept by
``league`` (UFC live coverage is unverified until a card is recorded)
UsMarketStream US markets socket (signed with the account key): ``Book`` (market data),
``Bbo`` (lite), ``UsTrade``; unverified until Sam's key exists
UsPrivateStream US private socket (signed): our orders, positions and balance as they
change (``UsOrderUpdate`` and raw frames); unverified until Sam's key exists
Reconnected the connection was rebuilt: re-snapshot every book

Keepalives: intl market ‘PING’ every 10 s; sports answers the server’s ‘ping’ with ‘pong’ within 10 s; US answers heartbeat frames.

Classes

IntlMarketStream

Bases: _Socket

The intl CLOB market socket for a set of tokens.

LastTrade

PriceChange

One intl level’s new size (side BUY = a bid level, SELL = an ask level).

Reconnected

Resolved

SportsStream

Bases: _Socket

The intl sports socket (every sport; league keeps ours).

UsAccountFrame

A position or balance update (or an execution), as served.

UsMarketStream

Bases: _Socket

The US markets socket for a set of slugs (signed handshake).

UsOrderUpdate

UsPrivateStream

Bases: _Socket

The US private socket: our orders, positions and balance (signed handshake).

UsTrade