Polymarket
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
None
then will source the POLYMARKET_PK environment variable. - signature_type (int , default 0 *(*EOA )) – The Polymarket signature type.
- funder (str , optional) – The wallet address (public key) on the Polygon network used for funding USDC.
If
None
then will source the POLYMARKET_FUNDER environment variable. - api_key (str , optional) – The Polymarket API public key.
If
None
then will source the POLYMARKET_API_KEY environment variable. - api_secret (str , optional) – The Polymarket API public key.
If
None
then will source the POLYMARKET_API_SECRET environment variable. - passphrase (str , optional) – The Polymarket API passphrase.
If
None
then 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_delay_secs (PositiveInt , default 5) – The delay (seconds) prior to main websocket connection to allow 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.
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_delay_secs : Annotated[int, msgspec.Meta(gt=0)]
update_instruments_interval_mins : Annotated[int, msgspec.Meta(gt=0)] | None
compute_effective_deltas : 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 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
None
then will source the POLYMARKET_PK environment variable. - signature_type (int , default 0 *(*EOA )) – The Polymarket signature type.
- funder (str , optional) – The wallet address (public key) on the Polygon network used for funding USDC.
If
None
then will source the POLYMARKET_FUNDER environment variable. - api_key (str , optional) – The Polymarket API public key.
If
None
then will source the POLYMARKET_API_KEY environment variable. - api_secret (str , optional) – The Polymarket API public key.
If
None
then will source the POLYMARKET_API_SECRET environment variables. - passphrase (str , optional) – The Polymarket API passphrase.
If
None
then 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 (PositiveFloat , optional) – The delay (seconds) 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).
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 : Annotated[float, msgspec.Meta(gt=0.0)] | None
generate_order_history_from_trades : 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
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 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.