Polymarket
Polymarket decentralized prediction market integration adapter.
This subpackage provides instrument providers, data and execution client configurations, factories, constants, and credential helpers for connecting to and interacting with the Polymarket Central Limit Order Book (CLOB) API.
For convenience, the most commonly used symbols are re-exported at the subpackage’s
top level, so downstream code can simply import from nautilus_trader.adapters.polymarket.
class PolymarketDataClientConfig
Bases: LiveDataClientConfig
Configuration for PolymarketDataClient instances.
- Parameters:
- venue (Venue , default POLYMARKET_VENUE) – The venue for the client.
 - private_key (str , optional) – The private key for the wallet on the Polygon network.
If 
Nonethen will source the POLYMARKET_PK environment variable. - signature_type (int , default 0 *(*EOA )) – The Polymarket signature type:
- 0: EOA (Externally Owned Account)
 - 1: Email/Magic Wallet Proxy
 - 2: Browser Wallet Proxy
 
 - funder (str , optional) – The wallet address (public key) on the Polygon network used for funding USDC.
If 
Nonethen will source the POLYMARKET_FUNDER environment variable. - api_key (str , optional) – The Polymarket API key.
If 
Nonethen will source the POLYMARKET_API_KEY environment variable. - api_secret (str , optional) – The Polymarket API secret.
If 
Nonethen will source the POLYMARKET_API_SECRET environment variable. - passphrase (str , optional) – The Polymarket API passphrase.
If 
Nonethen will source the POLYMARKET_PASSPHRASE environment variable. - base_url_http (str , optional) – The HTTP client custom endpoint override.
 - base_url_ws (str , optional) – The WebSocket client custom endpoint override.
 - ws_connection_initial_delay_secs (PositiveFloat , default 5) – The delay (seconds) prior to the first websocket connection to allow initial subscriptions to arrive.
 - ws_connection_delay_secs (PositiveFloat , default 0.1) – The delay (seconds) prior to making a new websocket connection to allow non-initial subscriptions to arrive.
 - update_instruments_interval_mins (PositiveInt or None , default 60) – The interval (minutes) between updating Polymarket instruments.
 - compute_effective_deltas (bool , default False) – If True, computes effective deltas by comparing old and new order book states, reducing snapshot size. This takes ~1 millisecond, so is not recommended for latency-sensitive strategies.
 - drop_quotes_missing_side (bool , default True) – If True, drops QuoteTick messages when bid or ask prices are missing (can occur near market resolution). If False, uses boundary prices (0.001/0.999) with zero volume for missing sides.
 
 
api_key : str | None
api_secret : str | None
base_url_http : str | None
base_url_ws : str | None
compute_effective_deltas : bool
drop_quotes_missing_side : bool
funder : str | None
passphrase : str | None
private_key : str | None
signature_type : int
update_instruments_interval_mins : Annotated[int, msgspec.Meta(gt=0)] | None
venue : Venue
ws_connection_delay_secs : Annotated[float, msgspec.Meta(gt=0.0)]
ws_connection_initial_delay_secs : Annotated[float, msgspec.Meta(gt=0.0)]
dict() → dict[str, Any]
Return a dictionary representation of the configuration.
- Return type: dict[str, Any]
 
classmethod fully_qualified_name() → str
Return the fully qualified name for the NautilusConfig class.
- Return type: str
 
handle_revised_bars : bool
property id : str
Return the hashed identifier for the configuration.
- Return type: str
 
instrument_provider : InstrumentProviderConfig
json() → bytes
Return serialized JSON encoded bytes.
- Return type: bytes
 
json_primitives() → dict[str, Any]
Return a dictionary representation of the configuration with JSON primitive types as values.
- Return type: dict[str, Any]
 
classmethod json_schema() → dict[str, Any]
Generate a JSON schema for this configuration class.
- Return type: dict[str, Any]
 
classmethod parse(raw: bytes | str) → Any
Return a decoded object of the given cls.
- Parameters:
- cls (type) – The type to decode to.
 - raw (bytes or str) – The raw bytes or JSON string to decode.
 
 - Return type: Any
 
routing : RoutingConfig
validate() → bool
Return whether the configuration can be represented as valid JSON.
- Return type: bool
 
class PolymarketDataLoader
Bases: object
Provides a data loader for historical Polymarket market data.
This loader fetches data from:
- Polymarket Gamma API (market information)
 - Polymarket CLOB API (price/trade history)
 - DomeAPI (orderbook history, available from October 14th, 2025)
 
- Parameters:
- instrument (BinaryOption) – The binary option instrument to load data for.
 - token_id (str , optional) – The Polymarket token ID for this instrument.
 - http_client (nautilus_pyo3.HttpClient , optional) – The HTTP client to use for requests. If not provided, a new client will be created.
 
 
async static fetch_market_details(condition_id: str, http_client: HttpClient | None = None) → dict
Fetch detailed market information from Polymarket CLOB API.
- Parameters:
- condition_id (str) – The market condition ID.
 - http_client (nautilus_pyo3.HttpClient , optional) – The HTTP client to use for requests. If not provided, a new client will be created.
 
 - Returns: Detailed market information.
 - Return type: dict
 
async static fetch_markets(active: bool = True, closed: bool = False, archived: bool = False, limit: int = 100, http_client: HttpClient | None = None) → list[dict]
Fetch markets from Polymarket Gamma API.
- Parameters:
- active (bool , default True) – Filter for active markets.
 - closed (bool , default False) – Include closed markets.
 - archived (bool , default False) – Include archived markets.
 - limit (int , default 100) – Maximum number of markets to return.
 - http_client (nautilus_pyo3.HttpClient , optional) – The HTTP client to use for requests. If not provided, a new client will be created.
 
 - Returns: List of market data dictionaries.
 - Return type: list[dict]
 
async fetch_orderbook_history(token_id: str, start_time_ms: int, end_time_ms: int, limit: int = 500) → list[dict]
Fetch orderbook history from DomeAPI.
- Parameters:
- token_id (str) – The Polymarket asset/token identifier.
 - start_time_ms (int) – Unix timestamp in milliseconds for query window start.
 - end_time_ms (int) – Unix timestamp in milliseconds for query window end.
 - limit (int , default 500) – Number of snapshots per request (max 500).
 
 - Returns: List of orderbook snapshot dictionaries.
 - Return type: list[dict]
 
async fetch_price_history(token_id: str, start_time_ms: int, end_time_ms: int, fidelity: int = 1) → list[dict]
Fetch price history from Polymarket CLOB API.
- Parameters:
- token_id (str) – The market/token identifier.
 - start_time_ms (int) – Unix timestamp in milliseconds for range start.
 - end_time_ms (int) – Unix timestamp in milliseconds for range end.
 - fidelity (int , default 1) – Data resolution in minutes.
 
 - Returns: List of price history points with ‘t’ (timestamp) and ‘p’ (price).
 - Return type: list[dict]
 
async static find_market_by_slug(slug: str, http_client: HttpClient | None = None) → dict
Find a specific market by slug.
- Parameters:
- slug (str) – The market slug to search for.
 - http_client (nautilus_pyo3.HttpClient , optional) – The HTTP client to use for requests. If not provided, a new client will be created.
 
 - Returns: Market data dictionary.
 - Return type: dict
 - Raises: ValueError – If market with the given slug is not found.
 
async classmethod from_market_slug(slug: str, token_index: int = 0, http_client: HttpClient | None = None) → PolymarketDataLoader
Create a loader by fetching market data from Polymarket APIs.
- Parameters:
- slug (str) – The market slug to search for.
 - token_index (int , default 0) – The index of the token to use (0 for first outcome, 1 for second).
 - http_client (nautilus_pyo3.HttpClient , optional) – The HTTP client to use for requests. If not provided, a new client will be created.
 
 - Return type: PolymarketDataLoader
 - Raises:
- ValueError – If market with slug is not found or has no tokens.
 - RuntimeError – If HTTP requests fail.
 
 
property instrument : BinaryOption
Return the instrument for this loader.
async load_orderbook_snapshots(start: Timestamp, end: Timestamp, limit: int = 500) → list[OrderBookDeltas]
Load orderbook snapshots for the loader’s instrument.
This is a convenience method that fetches and parses orderbook history using the loader’s stored token_id.
- Parameters:
- start (pd.Timestamp) – Start time for query window.
 - end (pd.Timestamp) – End time for query window.
 - limit (int , default 500) – Number of snapshots per request (max 500).
 
 - Returns: Parsed orderbook deltas ready for backtesting.
 - Return type: list[OrderBookDeltas]
 - Raises: ValueError – If token_id was not provided during initialization.
 
async load_trades(start: Timestamp, end: Timestamp, fidelity: int = 1) → list[TradeTick]
Load synthetic trade ticks from price history for the loader’s instrument.
This is a convenience method that fetches and parses price history using the loader’s stored token_id.
- Parameters:
- start (pd.Timestamp) – Start time for range.
 - end (pd.Timestamp) – End time for range.
 - fidelity (int , default 1) – Data resolution in minutes.
 
 - Returns: Parsed trade ticks ready for backtesting.
 - Return type: list[TradeTick]
 - Raises: ValueError – If token_id was not provided during initialization.
 
parse_orderbook_snapshots(snapshots: list[dict]) → list[OrderBookDeltas]
Parse orderbook snapshots into OrderBookDeltas.
- Parameters: snapshots (list *[*dict ]) – Raw orderbook snapshots from DomeAPI.
 - Returns: List of OrderBookDeltas for backtesting.
 - Return type: list[OrderBookDeltas]
 
parse_price_history(history: list[dict]) → list[TradeTick]
Parse price history into TradeTicks.
- Parameters: history (list *[*dict ]) – Raw price history from CLOB API.
 - Returns: List of synthetic TradeTicks for backtesting.
 - Return type: list[TradeTick]
 
property token_id : str | None
Return the token ID for this loader.
class PolymarketExecClientConfig
Bases: LiveExecClientConfig
Configuration for PolymarketExecutionClient instances.
- Parameters:
- venue (Venue , default POLYMARKET_VENUE) – The venue for the client.
 - private_key (str , optional) – The private key for the wallet on the Polygon network.
If 
Nonethen will source the POLYMARKET_PK environment variable. - signature_type (int , default 0 *(*EOA )) – The Polymarket signature type:
- 0: EOA (Externally Owned Account)
 - 1: Email/Magic Wallet Proxy
 - 2: Browser Wallet Proxy
 
 - funder (str , optional) – The wallet address (public key) on the Polygon network used for funding USDC.
If 
Nonethen will source the POLYMARKET_FUNDER environment variable. - api_key (str , optional) – The Polymarket API key.
If 
Nonethen will source the POLYMARKET_API_KEY environment variable. - api_secret (str , optional) – The Polymarket API secret.
If 
Nonethen will source the POLYMARKET_API_SECRET environment variable. - passphrase (str , optional) – The Polymarket API passphrase.
If 
Nonethen will source the POLYMARKET_PASSPHRASE environment variable. - base_url_http (str , optional) – The HTTP client custom endpoint override.
 - base_url_ws (str , optional) – The WebSocket client custom endpoint override.
 - max_retries (PositiveInt , optional) – The maximum number of times a submit or cancel order request will be retried.
 - retry_delay_initial_ms (PositiveInt , optional) – The initial delay (milliseconds) between retries. Short delays with frequent retries may result in account bans.
 - retry_delay_max_ms (PositiveInt , optional) – The maximum delay (milliseconds) between retries.
 - generate_order_history_from_trades (bool , default False) – If True, uses trades history to generate reports for orders which are no longer active. The Polymarket API only returns active orders and trades. This feature is experimental and is not currently recommended (leave set to False).
 - log_raw_ws_messages (bool , default False) – If raw websocket messages should be logged with INFO level. Note: there will be a performance penalty parsing the JSON without an efficient msgspec decoder.
 - ack_timeout_secs (PositiveFloat , default 5.0) – The timeout (seconds) to wait for order/trade acknowledgment from cache.
 
 
ack_timeout_secs : Annotated[float, msgspec.Meta(gt=0.0)]
api_key : str | None
api_secret : str | None
base_url_http : str | None
base_url_ws : str | None
funder : str | None
generate_order_history_from_trades : bool
log_raw_ws_messages : bool
max_retries : Annotated[int, msgspec.Meta(gt=0)] | None
passphrase : str | None
private_key : str | None
retry_delay_initial_ms : Annotated[int, msgspec.Meta(gt=0)] | None
retry_delay_max_ms : Annotated[int, msgspec.Meta(gt=0)] | None
signature_type : int
venue : Venue
dict() → dict[str, Any]
Return a dictionary representation of the configuration.
- Return type: dict[str, Any]
 
classmethod fully_qualified_name() → str
Return the fully qualified name for the NautilusConfig class.
- Return type: str
 
property id : str
Return the hashed identifier for the configuration.
- Return type: str
 
instrument_provider : InstrumentProviderConfig
json() → bytes
Return serialized JSON encoded bytes.
- Return type: bytes
 
json_primitives() → dict[str, Any]
Return a dictionary representation of the configuration with JSON primitive types as values.
- Return type: dict[str, Any]
 
classmethod json_schema() → dict[str, Any]
Generate a JSON schema for this configuration class.
- Return type: dict[str, Any]
 
classmethod parse(raw: bytes | str) → Any
Return a decoded object of the given cls.
- Parameters:
- cls (type) – The type to decode to.
 - raw (bytes or str) – The raw bytes or JSON string to decode.
 
 - Return type: Any
 
routing : RoutingConfig
validate() → bool
Return whether the configuration can be represented as valid JSON.
- Return type: bool
 
class PolymarketInstrumentProvider
Bases: InstrumentProvider
Provides Nautilus instrument definitions from Polymarket.
- Parameters:
- client (ClobClient) – The Polymarket CLOB HTTP client.
 - clock (LiveClock) – The clock instance.
 - config (InstrumentProviderConfig , optional) – The instrument provider configuration, by default None.
 
 
add(instrument: Instrument) → None
Add the given instrument to the provider.
- Parameters: instrument (Instrument) – The instrument to add.
 
add_bulk(instruments: list[Instrument]) → None
Add the given instruments bulk to the provider.
- Parameters: instruments (list [Instrument ]) – The instruments to add.
 
add_currency(currency: Currency) → None
Add the given currency to the provider.
- Parameters: currency (Currency) – The currency to add.
 
property count : int
Return the count of instruments held by the provider.
- Return type: int
 
currencies() → dict[str, Currency]
Return all currencies held by the instrument provider.
- Return type: dict[str, Currency]
 
currency(code: str) → Currency | None
Return the currency with the given code (if found).
- Parameters: code (str) – The currency code.
 - Return type:
Currency or 
None - Raises: ValueError – If code is not a valid string.
 
find(instrument_id: InstrumentId) → Instrument | None
Return the instrument for the given instrument ID (if found).
- Parameters: instrument_id (InstrumentId) – The ID for the instrument
 - Return type:
Instrument or 
None 
get_all() → dict[InstrumentId, Instrument]
Return all loaded instruments as a map keyed by instrument ID.
If no instruments loaded, will return an empty dict.
- Return type: dict[InstrumentId, Instrument]
 
async initialize(reload: bool = False) → None
Initialize the instrument provider.
- Parameters: reload (bool , default False) – If True, then will always reload instruments. If False, then will immediately return if already loaded.
 
list_all() → list[Instrument]
Return all loaded instruments.
- Return type: list[Instrument]
 
load(instrument_id: InstrumentId, filters: dict | None = None) → None
Load the instrument for the given ID into the provider, optionally applying the given filters.
- Parameters:
- instrument_id (InstrumentId) – The instrument ID to load.
 - filters (frozendict *[*str , Any ] or dict *[*str , Any ] , optional) – The venue specific instrument loading filters to apply.
 
 
load_all(filters: dict | None = None) → None
Load the latest instruments into the provider, optionally applying the given filters.
- Parameters: filters (frozendict *[*str , Any ] or dict *[*str , Any ] , optional) – The venue specific instrument loading filters to apply.
 
async load_all_async(filters: dict | None = None) → None
Load the latest instruments into the provider asynchronously, optionally applying the given filters.
async load_async(instrument_id: InstrumentId, filters: dict | None = None) → None
Load the instrument for the given ID into the provider asynchronously, optionally applying the given filters.
- Parameters:
- instrument_id (InstrumentId) – The instrument ID to load.
 - filters (frozendict *[*str , Any ] or dict *[*str , Any ] , optional) – The venue specific instrument loading filters to apply.
 
 - Raises: ValueError – If instrument_id.venue is not equal to self.venue.
 
load_ids(instrument_ids: list[InstrumentId], filters: dict | None = None) → None
Load the instruments for the given IDs into the provider, optionally applying the given filters.
- Parameters:
- instrument_ids (list [InstrumentId ]) – The instrument IDs to load.
 - filters (frozendict *[*str , Any ] or dict *[*str , Any ] , optional) – The venue specific instrument loading filters to apply.
 
 
async load_ids_async(instrument_ids: list[InstrumentId], filters: dict | None = None) → None
Load the instruments for the given IDs into the provider, optionally applying the given filters.
- Parameters:
- instrument_ids (list [InstrumentId ]) – The instrument IDs to load.
 - filters (frozendict *[*str , Any ] or dict *[*str , Any ] , optional) – The venue specific instrument loading filters to apply.
 
 - Raises: ValueError – If any instrument_id.venue is not equal to self.venue.
 
class PolymarketLiveDataClientFactory
Bases: LiveDataClientFactory
Provides a Polymarket live data client factory.
static create(loop: AbstractEventLoop, name: str, config: PolymarketDataClientConfig, msgbus: MessageBus, cache: Cache, clock: LiveClock) → PolymarketDataClient
Create a new Polymarket data client.
- Parameters:
- loop (asyncio.AbstractEventLoop) – The event loop for the client.
 - name (str) – The custom client ID.
 - config (PolymarketDataClientConfig) – The client configuration.
 - msgbus (MessageBus) – The message bus for the client.
 - cache (Cache) – The cache for the client.
 - clock (LiveClock) – The clock for the instrument provider.
 
 - Return type: PolymarketDataClient
 
class PolymarketLiveExecClientFactory
Bases: LiveExecClientFactory
Provides a Polymarket live execution client factory.
static create(loop: AbstractEventLoop, name: str, config: PolymarketExecClientConfig, msgbus: MessageBus, cache: Cache, clock: LiveClock) → PolymarketExecutionClient
Create a new Polymarket execution client.
- Parameters:
- loop (asyncio.AbstractEventLoop) – The event loop for the client.
 - name (str) – The custom client ID.
 - config (PolymarketExecClientConfig) – The client configuration.
 - msgbus (MessageBus) – The message bus for the client.
 - cache (Cache) – The cache for the client.
 - clock (LiveClock) – The clock for the instrument provider.
 
 - Return type: PolymarketExecutionClient
 
get_polymarket_http_client(api_key: str | None = None, api_secret: str | None = None, passphrase: str | None = None, base_url: str | None = None, chain_id: int = 137, signature_type: int = 0, private_key: str | None = None, funder: str | None = None) → ClobClient
Cache and return a Polymarket CLOB client.
If a cached client with matching parameters already exists, the cached client will be returned.
- Parameters:
- api_key (str , optional) – The API key for the client.
 - api_secret (str , optional) – The API secret for the client.
 - passphrase (str , optional) – The passphrase for the client.
 - base_url (str , optional) – The base URL for the API endpoints.
 - chain_id (int , default POLYGON) – The chain ID for the client.
 - signature_type (int , default 0 *(*EOA )) – The Polymarket signature type.
 - private_key (str , optional) – The private key for the wallet on the Polygon network.
 - funder (str , optional) – The wallet address (public key) on the Polygon network used for funding USDC.
 
 - Return type: ClobClient
 
get_polymarket_instrument_id(condition_id: str, token_id: str | int) → InstrumentId
get_polymarket_instrument_provider(client: ClobClient, clock: LiveClock, config: InstrumentProviderConfig) → PolymarketInstrumentProvider
Cache and return a Polymarket instrument provider.
If a cached provider already exists, then that provider will be returned.
- Parameters:
- client (py_clob_client.client.ClobClient) – The client for the instrument provider.
 - clock (LiveClock) – The clock for the instrument provider.
 - config (InstrumentProviderConfig) – The configuration for the instrument provider.
 
 - Return type: PolymarketInstrumentProvider
 
Config
class PolymarketDataClientConfig
Bases: LiveDataClientConfig
Configuration for PolymarketDataClient instances.
- Parameters:
- venue (Venue , default POLYMARKET_VENUE) – The venue for the client.
 - private_key (str , optional) – The private key for the wallet on the Polygon network.
If 
Nonethen will source the POLYMARKET_PK environment variable. - signature_type (int , default 0 *(*EOA )) – The Polymarket signature type:
- 0: EOA (Externally Owned Account)
 - 1: Email/Magic Wallet Proxy
 - 2: Browser Wallet Proxy
 
 - funder (str , optional) – The wallet address (public key) on the Polygon network used for funding USDC.
If 
Nonethen will source the POLYMARKET_FUNDER environment variable. - api_key (str , optional) – The Polymarket API key.
If 
Nonethen will source the POLYMARKET_API_KEY environment variable. - api_secret (str , optional) – The Polymarket API secret.
If 
Nonethen will source the POLYMARKET_API_SECRET environment variable. - passphrase (str , optional) – The Polymarket API passphrase.
If 
Nonethen will source the POLYMARKET_PASSPHRASE environment variable. - base_url_http (str , optional) – The HTTP client custom endpoint override.
 - base_url_ws (str , optional) – The WebSocket client custom endpoint override.
 - ws_connection_initial_delay_secs (PositiveFloat , default 5) – The delay (seconds) prior to the first websocket connection to allow initial subscriptions to arrive.
 - ws_connection_delay_secs (PositiveFloat , default 0.1) – The delay (seconds) prior to making a new websocket connection to allow non-initial subscriptions to arrive.
 - update_instruments_interval_mins (PositiveInt or None , default 60) – The interval (minutes) between updating Polymarket instruments.
 - compute_effective_deltas (bool , default False) – If True, computes effective deltas by comparing old and new order book states, reducing snapshot size. This takes ~1 millisecond, so is not recommended for latency-sensitive strategies.
 - drop_quotes_missing_side (bool , default True) – If True, drops QuoteTick messages when bid or ask prices are missing (can occur near market resolution). If False, uses boundary prices (0.001/0.999) with zero volume for missing sides.
 
 
venue : Venue
private_key : str | None
signature_type : int
funder : str | None
api_key : str | None
api_secret : str | None
passphrase : str | None
base_url_http : str | None
base_url_ws : str | None
ws_connection_initial_delay_secs : Annotated[float, msgspec.Meta(gt=0.0)]
ws_connection_delay_secs : Annotated[float, msgspec.Meta(gt=0.0)]
update_instruments_interval_mins : Annotated[int, msgspec.Meta(gt=0)] | None
compute_effective_deltas : bool
drop_quotes_missing_side : bool
dict() → dict[str, Any]
Return a dictionary representation of the configuration.
- Return type: dict[str, Any]
 
classmethod fully_qualified_name() → str
Return the fully qualified name for the NautilusConfig class.
- Return type: str
 
handle_revised_bars : bool
property id : str
Return the hashed identifier for the configuration.
- Return type: str
 
instrument_provider : InstrumentProviderConfig
json() → bytes
Return serialized JSON encoded bytes.
- Return type: bytes
 
json_primitives() → dict[str, Any]
Return a dictionary representation of the configuration with JSON primitive types as values.
- Return type: dict[str, Any]
 
classmethod json_schema() → dict[str, Any]
Generate a JSON schema for this configuration class.
- Return type: dict[str, Any]
 
classmethod parse(raw: bytes | str) → Any
Return a decoded object of the given cls.
- Parameters:
- cls (type) – The type to decode to.
 - raw (bytes or str) – The raw bytes or JSON string to decode.
 
 - Return type: Any
 
routing : RoutingConfig
validate() → bool
Return whether the configuration can be represented as valid JSON.
- Return type: bool
 
class PolymarketExecClientConfig
Bases: LiveExecClientConfig
Configuration for PolymarketExecutionClient instances.
- Parameters:
- venue (Venue , default POLYMARKET_VENUE) – The venue for the client.
 - private_key (str , optional) – The private key for the wallet on the Polygon network.
If 
Nonethen will source the POLYMARKET_PK environment variable. - signature_type (int , default 0 *(*EOA )) – The Polymarket signature type:
- 0: EOA (Externally Owned Account)
 - 1: Email/Magic Wallet Proxy
 - 2: Browser Wallet Proxy
 
 - funder (str , optional) – The wallet address (public key) on the Polygon network used for funding USDC.
If 
Nonethen will source the POLYMARKET_FUNDER environment variable. - api_key (str , optional) – The Polymarket API key.
If 
Nonethen will source the POLYMARKET_API_KEY environment variable. - api_secret (str , optional) – The Polymarket API secret.
If 
Nonethen will source the POLYMARKET_API_SECRET environment variable. - passphrase (str , optional) – The Polymarket API passphrase.
If 
Nonethen will source the POLYMARKET_PASSPHRASE environment variable. - base_url_http (str , optional) – The HTTP client custom endpoint override.
 - base_url_ws (str , optional) – The WebSocket client custom endpoint override.
 - max_retries (PositiveInt , optional) – The maximum number of times a submit or cancel order request will be retried.
 - retry_delay_initial_ms (PositiveInt , optional) – The initial delay (milliseconds) between retries. Short delays with frequent retries may result in account bans.
 - retry_delay_max_ms (PositiveInt , optional) – The maximum delay (milliseconds) between retries.
 - generate_order_history_from_trades (bool , default False) – If True, uses trades history to generate reports for orders which are no longer active. The Polymarket API only returns active orders and trades. This feature is experimental and is not currently recommended (leave set to False).
 - log_raw_ws_messages (bool , default False) – If raw websocket messages should be logged with INFO level. Note: there will be a performance penalty parsing the JSON without an efficient msgspec decoder.
 - ack_timeout_secs (PositiveFloat , default 5.0) – The timeout (seconds) to wait for order/trade acknowledgment from cache.
 
 
venue : Venue
private_key : str | None
signature_type : int
funder : str | None
api_key : str | None
api_secret : str | None
passphrase : str | None
base_url_http : str | None
base_url_ws : str | None
max_retries : Annotated[int, msgspec.Meta(gt=0)] | None
retry_delay_initial_ms : Annotated[int, msgspec.Meta(gt=0)] | None
retry_delay_max_ms : Annotated[int, msgspec.Meta(gt=0)] | None
generate_order_history_from_trades : bool
log_raw_ws_messages : bool
ack_timeout_secs : Annotated[float, msgspec.Meta(gt=0.0)]
dict() → dict[str, Any]
Return a dictionary representation of the configuration.
- Return type: dict[str, Any]
 
classmethod fully_qualified_name() → str
Return the fully qualified name for the NautilusConfig class.
- Return type: str
 
property id : str
Return the hashed identifier for the configuration.
- Return type: str
 
instrument_provider : InstrumentProviderConfig
json() → bytes
Return serialized JSON encoded bytes.
- Return type: bytes
 
json_primitives() → dict[str, Any]
Return a dictionary representation of the configuration with JSON primitive types as values.
- Return type: dict[str, Any]
 
classmethod json_schema() → dict[str, Any]
Generate a JSON schema for this configuration class.
- Return type: dict[str, Any]
 
classmethod parse(raw: bytes | str) → Any
Return a decoded object of the given cls.
- Parameters:
- cls (type) – The type to decode to.
 - raw (bytes or str) – The raw bytes or JSON string to decode.
 
 - Return type: Any
 
routing : RoutingConfig
validate() → bool
Return whether the configuration can be represented as valid JSON.
- Return type: bool
 
Factories
get_polymarket_http_client(api_key: str | None = None, api_secret: str | None = None, passphrase: str | None = None, base_url: str | None = None, chain_id: int = 137, signature_type: int = 0, private_key: str | None = None, funder: str | None = None) → ClobClient
Cache and return a Polymarket CLOB client.
If a cached client with matching parameters already exists, the cached client will be returned.
- Parameters:
- api_key (str , optional) – The API key for the client.
 - api_secret (str , optional) – The API secret for the client.
 - passphrase (str , optional) – The passphrase for the client.
 - base_url (str , optional) – The base URL for the API endpoints.
 - chain_id (int , default POLYGON) – The chain ID for the client.
 - signature_type (int , default 0 *(*EOA )) – The Polymarket signature type.
 - private_key (str , optional) – The private key for the wallet on the Polygon network.
 - funder (str , optional) – The wallet address (public key) on the Polygon network used for funding USDC.
 
 - Return type: ClobClient
 
get_polymarket_instrument_provider(client: ClobClient, clock: LiveClock, config: InstrumentProviderConfig) → PolymarketInstrumentProvider
Cache and return a Polymarket instrument provider.
If a cached provider already exists, then that provider will be returned.
- Parameters:
- client (py_clob_client.client.ClobClient) – The client for the instrument provider.
 - clock (LiveClock) – The clock for the instrument provider.
 - config (InstrumentProviderConfig) – The configuration for the instrument provider.
 
 - Return type: PolymarketInstrumentProvider
 
class PolymarketLiveDataClientFactory
Bases: LiveDataClientFactory
Provides a Polymarket live data client factory.
static create(loop: AbstractEventLoop, name: str, config: PolymarketDataClientConfig, msgbus: MessageBus, cache: Cache, clock: LiveClock) → PolymarketDataClient
Create a new Polymarket data client.
- Parameters:
- loop (asyncio.AbstractEventLoop) – The event loop for the client.
 - name (str) – The custom client ID.
 - config (PolymarketDataClientConfig) – The client configuration.
 - msgbus (MessageBus) – The message bus for the client.
 - cache (Cache) – The cache for the client.
 - clock (LiveClock) – The clock for the instrument provider.
 
 - Return type: PolymarketDataClient
 
class PolymarketLiveExecClientFactory
Bases: LiveExecClientFactory
Provides a Polymarket live execution client factory.
static create(loop: AbstractEventLoop, name: str, config: PolymarketExecClientConfig, msgbus: MessageBus, cache: Cache, clock: LiveClock) → PolymarketExecutionClient
Create a new Polymarket execution client.
- Parameters:
- loop (asyncio.AbstractEventLoop) – The event loop for the client.
 - name (str) – The custom client ID.
 - config (PolymarketExecClientConfig) – The client configuration.
 - msgbus (MessageBus) – The message bus for the client.
 - cache (Cache) – The cache for the client.
 - clock (LiveClock) – The clock for the instrument provider.
 
 - Return type: PolymarketExecutionClient
 
Enums
class PolymarketSignatureType
Bases: Enum
EOA = 0
POLY_PROXY = 1
POLY_GNOSIS_SAFE = 2
class PolymarketOrderSide
Bases: Enum
BUY = 'BUY'
SELL = 'SELL'
class PolymarketLiquiditySide
Bases: Enum
MAKER = 'MAKER'
TAKER = 'TAKER'
class PolymarketOrderType
Bases: Enum
FOK = 'FOK'
FAK = 'FAK'
GTC = 'GTC'
GTD = 'GTD'
class PolymarketEventType
Bases: Enum
PLACEMENT = 'PLACEMENT'
UPDATE = 'UPDATE'
CANCELLATION = 'CANCELLATION'
TRADE = 'TRADE'
class PolymarketOrderStatus
Bases: Enum
INVALID = 'INVALID'
LIVE = 'LIVE'
DELAYED = 'DELAYED'
MATCHED = 'MATCHED'
UNMATCHED = 'UNMATCHED'
CANCELED = 'CANCELED'
CANCELED_MARKET_RESOLVED = 'CANCELED_MARKET_RESOLVED'
class PolymarketTradeStatus
Bases: Enum
MATCHED = 'MATCHED'
MINED = 'MINED'
CONFIRMED = 'CONFIRMED'
RETRYING = 'RETRYING'
FAILED = 'FAILED'
Providers
class PolymarketInstrumentProvider
Bases: InstrumentProvider
Provides Nautilus instrument definitions from Polymarket.
- Parameters:
- client (ClobClient) – The Polymarket CLOB HTTP client.
 - clock (LiveClock) – The clock instance.
 - config (InstrumentProviderConfig , optional) – The instrument provider configuration, by default None.
 
 
async load_all_async(filters: dict | None = None) → None
Load the latest instruments into the provider asynchronously, optionally applying the given filters.
async load_ids_async(instrument_ids: list[InstrumentId], filters: dict | None = None) → None
Load the instruments for the given IDs into the provider, optionally applying the given filters.
- Parameters:
- instrument_ids (list [InstrumentId ]) – The instrument IDs to load.
 - filters (frozendict *[*str , Any ] or dict *[*str , Any ] , optional) – The venue specific instrument loading filters to apply.
 
 - Raises: ValueError – If any instrument_id.venue is not equal to self.venue.
 
async load_async(instrument_id: InstrumentId, filters: dict | None = None) → None
Load the instrument for the given ID into the provider asynchronously, optionally applying the given filters.
- Parameters:
- instrument_id (InstrumentId) – The instrument ID to load.
 - filters (frozendict *[*str , Any ] or dict *[*str , Any ] , optional) – The venue specific instrument loading filters to apply.
 
 - Raises: ValueError – If instrument_id.venue is not equal to self.venue.
 
add(instrument: Instrument) → None
Add the given instrument to the provider.
- Parameters: instrument (Instrument) – The instrument to add.
 
add_bulk(instruments: list[Instrument]) → None
Add the given instruments bulk to the provider.
- Parameters: instruments (list [Instrument ]) – The instruments to add.
 
add_currency(currency: Currency) → None
Add the given currency to the provider.
- Parameters: currency (Currency) – The currency to add.
 
property count : int
Return the count of instruments held by the provider.
- Return type: int
 
currencies() → dict[str, Currency]
Return all currencies held by the instrument provider.
- Return type: dict[str, Currency]
 
currency(code: str) → Currency | None
Return the currency with the given code (if found).
- Parameters: code (str) – The currency code.
 - Return type:
Currency or 
None - Raises: ValueError – If code is not a valid string.
 
find(instrument_id: InstrumentId) → Instrument | None
Return the instrument for the given instrument ID (if found).
- Parameters: instrument_id (InstrumentId) – The ID for the instrument
 - Return type:
Instrument or 
None 
get_all() → dict[InstrumentId, Instrument]
Return all loaded instruments as a map keyed by instrument ID.
If no instruments loaded, will return an empty dict.
- Return type: dict[InstrumentId, Instrument]
 
async initialize(reload: bool = False) → None
Initialize the instrument provider.
- Parameters: reload (bool , default False) – If True, then will always reload instruments. If False, then will immediately return if already loaded.
 
list_all() → list[Instrument]
Return all loaded instruments.
- Return type: list[Instrument]
 
load(instrument_id: InstrumentId, filters: dict | None = None) → None
Load the instrument for the given ID into the provider, optionally applying the given filters.
- Parameters:
- instrument_id (InstrumentId) – The instrument ID to load.
 - filters (frozendict *[*str , Any ] or dict *[*str , Any ] , optional) – The venue specific instrument loading filters to apply.
 
 
load_all(filters: dict | None = None) → None
Load the latest instruments into the provider, optionally applying the given filters.
- Parameters: filters (frozendict *[*str , Any ] or dict *[*str , Any ] , optional) – The venue specific instrument loading filters to apply.
 
load_ids(instrument_ids: list[InstrumentId], filters: dict | None = None) → None
Load the instruments for the given IDs into the provider, optionally applying the given filters.
- Parameters:
- instrument_ids (list [InstrumentId ]) – The instrument IDs to load.
 - filters (frozendict *[*str , Any ] or dict *[*str , Any ] , optional) – The venue specific instrument loading filters to apply.
 
 
Data
class PolymarketDataClient
Bases: LiveMarketDataClient
Provides a data client for Polymarket, a decentralized predication market.
- Parameters:
- loop (asyncio.AbstractEventLoop) – The event loop for the client.
 - http_client (py_clob_client.client.ClobClient) – The Polymarket HTTP client.
 - msgbus (MessageBus) – The message bus for the client.
 - cache (Cache) – The cache for the client.
 - clock (LiveClock) – The clock for the client.
 - instrument_provider (PolymarketInstrumentProvider) – The instrument provider.
 - config (PolymarketDataClientConfig) – The configuration for the client.
 - name (str , optional) – The custom client ID.
 
 
async cancel_pending_tasks(timeout_secs: float = 5.0) → None
Cancel all pending tasks and await their cancellation.
- Parameters: timeout_secs (float , default 5.0) – The timeout in seconds to wait for tasks to cancel.
 
connect() → None
Connect the client.
create_task(coro: ~collections.abc.Coroutine, log_msg: str | None = None, actions: ~collections.abc.Callable | None = None, success_msg: str | None = None, success_color: ~nautilus_trader.core.rust.common.LogColor = <LogColor.NORMAL: 0>) → Task | None
Run the given coroutine with error handling and optional callback actions when done.
- Parameters:
- coro (Coroutine) – The coroutine to run.
 - log_msg (str , optional) – The log message for the task.
 - actions (Callable , optional) – The actions callback to run when the coroutine is done.
 - success_msg (str , optional) – The log message to write on actions success.
 - success_color (LogColor, default 
NORMAL) – The log message color for actions success. 
 - Return type: asyncio.Task