betting_combat.providers.polymarket.client
client.py — Polymarket’s two venues over REST.
PolymarketIntl read-only (trading from the US is barred by the ToS): Gamma (events), the CLOB (books, price history), the data API (trades)PolymarketUS the US exchange: public market data on the gateway (events, books, BBO, settlement, history); with the account's Ed25519 key (``UsSigner``) orders (create, batch ≤ 20, modify, cancel, cancel all, close a position, preview), open orders, positions, activities and balancesUsSigner the US key: ``X-PM-Access-Key`` / ``-Timestamp`` (ms) / ``-Signature``, Ed25519 over timestamp + METHOD + pathRules from the survey (docs/BASE_TABLES.md): intl lists one event per fight (series 38),
its startTime the card’s start; US lists only the moneyline in its event lists, so the
full set of markets comes from event(slug); the intl 1-minute history before the last 15
days comes from the legacy CLOB route only; US has no public trade tape.
Classes
PolymarketIntl
Bases: Provider
Polymarket intl, read-only.
archive
archive(start: dt.datetime, end: dt.datetime) -> list[IntlEvent]Every closed event tagged UFC that ended in start .. end: the archive the
per-fight series misses (2024-04 on: a card’s fights as one event’s markets, then a
fight’s props as their own event), with no teams and mostly no game id.
books
books(tokens: list[str]) -> list[Book]The CLOB books of up to 100 tokens a call.
event
event(event_id: str) -> IntlEventOne fight with every market.
events
events(closed: bool | None = False) -> list[IntlEvent]The UFC fights (one event each): open by default, closed=True the history (from
2025-10 per fight; sporadic winner-only events 2021-23), None both.
history
history(token: str, start: dt.datetime, end: dt.datetime) -> list[PricePoint]One token’s 1-minute price points (the legacy CLOB route: old fights too), asked
INTL_HISTORY_SPAN at a time: a longer range comes back empty (found 2026-11-10:
every market read over more than ~15 days had none).
live_volume
live_volume(event_id: str) -> dict[str, Any]Taker volume per condition of one fight, as served.
market_types
market_types() -> list[str]The sports market types Gamma knows (ufc_round_of_finish, …).
trades
trades(conditions: list[str]) -> list[IntlTrade]Every trade of up to 20 conditions a call, all history (cursor paged).
PolymarketSettings
Bases: BaseSettings
POLYMARKET_US_KEY_ID / POLYMARKET_US_SECRET (from Sam’s developer portal).
signer
signer() -> UsSigner | NonePolymarketUS
Bases: Provider
Polymarket US: public market data (no key) and, with the key, orders.
activities
activities() -> list[dict[str, Any]]Trades, resolutions and balance changes, as served.
balances
balances() -> list[UsBalance]bbo
bbo(slug: str) -> Bbobook
book(slug: str) -> Bookcancel_all
cancel_all(slugs: list[str] | None = None) -> list[str]Every open order, or those on slugs.
cancel_order
cancel_order(order_id: str, slug: str) -> dict[str, Any]cancel_orders
cancel_orders(orders: list[tuple[str, str]]) -> list[str]Up to 20 (order id, slug) in one call; the ids echoed (watch the socket for the truth).
close_position
close_position(slug: str) -> dict[str, Any]Sell every contract held on slug (an order the exchange builds).
closed_events
closed_events(start: dt.datetime, end: dt.datetime) -> list[UsEvent]create_order
create_order(slug: str, intent: Intent, quantity: float, price: float, tif: Tif = 'TIME_IN_FORCE_IMMEDIATE_OR_CANCEL', post_only: bool = False) -> strSend one limit order, once; the exchange’s order id.
create_orders
create_orders(orders: list[dict[str, Any]]) -> list[str]Up to 20 orders (order_body) in one call; outcomes arrive on the private socket.
event
event(slug: str) -> UsEventOne fight with every market and its live state.
events
events(active: bool = True, closed: bool = False) -> list[UsEvent]The UFC fights listed (each with its moneyline only: event has the rest).
history
history(slug: str, start: dt.datetime, end: dt.datetime) -> tuple[list[PricePoint], list[tuple[dt.datetime, dt.datetime, str]]]One market’s 1-minute long / short quote points (2026-08 onward at least), and the
spans that failed (start, end, why): custom ranges take Unix seconds; a range is asked
US_HISTORY_SPAN at a time (the same points as asking day by day: checked 2026-11-11
on 7 days, 10,081 points both ways), and one failed span loses only itself.
modify_order
modify_order(order_id: str, slug: str, price: float | None = None, quantity: float | None = None, tif: Tif | None = None) -> dict[str, Any]open_orders
open_orders() -> list[UsOrder]order
order(order_id: str) -> UsOrderorder_body
order_body(slug: str, intent: str, quantity: float, price: float, tif: str = 'TIME_IN_FORCE_IMMEDIATE_OR_CANCEL', post_only: bool = False) -> dict[str, Any]One documented CreateOrderRequest (a limit order; long and short each priced in
their own side’s terms).
positions
positions() -> list[UsPosition]Every position (paged by cursor).
preview_order
preview_order(body: dict[str, Any]) -> dict[str, Any]The exchange’s check of an order before sending it (expected fills), as served.
settlement
settlement(slug: str) -> float | NoneWhat one long paid (0 or 1), None while unsettled.
UsSigner
The US account’s key: Ed25519 over timestamp + METHOD + path (no query).
headers
headers(method: str, path: str) -> dict[str, str]