Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 5 additions & 15 deletions sdks/python/pmxt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,26 +143,16 @@ def logs(self, n: int = 50) -> List[str]:
server = _ServerNamespace(_default_manager)


# Deprecated flat aliases. Prefer ``pmxt.server.stop()`` / ``pmxt.server.restart()``.
# Flat aliases for the namespaced server commands. Kept as permanent,
# fully-supported shorthand — ``pmxt.server.stop()`` and ``pmxt.stop_server()``
# are equivalent and both are first-class API.
def stop_server() -> None:
"""Deprecated: use ``pmxt.server.stop()`` instead."""
import warnings
warnings.warn(
"pmxt.stop_server() is deprecated; use pmxt.server.stop() instead.",
DeprecationWarning,
stacklevel=2,
)
"""Stop the local PMXT sidecar server."""
_default_manager.stop()


def restart_server() -> None:
"""Deprecated: use ``pmxt.server.restart()`` instead."""
import warnings
warnings.warn(
"pmxt.restart_server() is deprecated; use pmxt.server.restart() instead.",
DeprecationWarning,
stacklevel=2,
)
"""Restart the local PMXT sidecar server."""
_default_manager.restart()

__version__ = "2.17.1"
Expand Down
3 changes: 3 additions & 0 deletions sdks/python/pmxt/_exchanges.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ def __init__(
api_secret: Optional[str] = None,
passphrase: Optional[str] = None,
private_key: Optional[str] = None,
wallet_address: Optional[str] = None,
base_url: Optional[str] = None,
auto_start_server: Optional[bool] = None,
pmxt_api_key: Optional[str] = None,
Expand All @@ -93,6 +94,7 @@ def __init__(
api_secret: API secret for authentication (optional)
passphrase: Passphrase for authentication (optional)
private_key: Private key for authentication (optional)
wallet_address: Wallet address for delegated signing (optional)
base_url: Base URL of the PMXT sidecar server
auto_start_server: Automatically start server if not running (default: True)
pmxt_api_key: Hosted PMXT API key (optional; enables hosted mode)
Expand All @@ -101,6 +103,7 @@ def __init__(
exchange_name="limitless",
api_key=api_key,
private_key=private_key,
wallet_address=wallet_address,
base_url=base_url,
auto_start_server=auto_start_server,
pmxt_api_key=pmxt_api_key,
Expand Down
29 changes: 20 additions & 9 deletions sdks/python/pmxt/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
MissingWalletAddress,
NotSupported,
PmxtError,
ValidationError,
from_server_error,
)
from ._hosted_routing import (
Expand Down Expand Up @@ -330,9 +331,9 @@ def __init__(
base_url: Optional[str] = None,
auto_start_server: Optional[bool] = None,
proxy_address: Optional[str] = None,
signature_type: Optional[str] = None,
pmxt_api_key: Optional[str] = None,
signature_type: Optional[Union[str, int]] = None,
wallet_address: Optional[str] = None,
pmxt_api_key: Optional[str] = None,
signer: Optional[Any] = None,
) -> None:
"""
Expand All @@ -352,6 +353,7 @@ def __init__(
Pass an explicit bool to override.
proxy_address: Proxy/smart wallet address (optional).
signature_type: Signature type for venues that need it (optional).
wallet_address: Wallet address for venues that support delegated signing (optional).
pmxt_api_key: Hosted pmxt API key. Distinct from ``api_key``,
which targets the venue. If supplied (or via ``PMXT_API_KEY``
env) and no explicit ``base_url`` is set, the SDK auto-routes
Expand Down Expand Up @@ -552,7 +554,14 @@ def _get_auth_headers(self) -> Dict[str, str]:

def _get_credentials_dict(self) -> Optional[Dict[str, Any]]:
"""Build credentials dictionary for API requests."""
if not self.api_key and not self.private_key and not self.api_token:
if (
not self.api_key
and not self.private_key
and not self.api_token
and not self.proxy_address
and self.signature_type is None
and not self.wallet_address
):
return None

creds = {}
Expand All @@ -566,6 +575,8 @@ def _get_credentials_dict(self) -> Optional[Dict[str, Any]]:
creds["funderAddress"] = self.proxy_address
if self.signature_type is not None:
creds["signatureType"] = self.signature_type
if self.wallet_address:
creds["walletAddress"] = self.wallet_address
return creds if creds else None

# ------------------------------------------------------------------
Expand Down Expand Up @@ -3038,17 +3049,17 @@ def create_order(
# Resolve outcome shorthand
if outcome is not None:
if market_id is not None or outcome_id is not None:
raise ValueError(
raise ValidationError(
"Cannot specify both 'outcome' and 'market_id'/'outcome_id'. Use one or the other."
)
if not outcome.market_id:
raise ValueError(
raise ValidationError(
"outcome.market_id is not set. Ensure the outcome comes from a fetched market."
)
market_id = outcome.market_id
outcome_id = outcome.outcome_id
elif market_id is None or outcome_id is None:
raise ValueError(
raise ValidationError(
"Either provide 'outcome' or both 'market_id' and 'outcome_id'."
)

Expand Down Expand Up @@ -3181,17 +3192,17 @@ def build_order(
# Resolve outcome shorthand
if outcome is not None:
if market_id is not None or outcome_id is not None:
raise ValueError(
raise ValidationError(
"Cannot specify both 'outcome' and 'market_id'/'outcome_id'. Use one or the other."
)
if not outcome.market_id:
raise ValueError(
raise ValidationError(
"outcome.market_id is not set. Ensure the outcome comes from a fetched market."
)
market_id = outcome.market_id
outcome_id = outcome.outcome_id
elif market_id is None or outcome_id is None:
raise ValueError(
raise ValidationError(
"Either provide 'outcome' or both 'market_id' and 'outcome_id'."
)

Expand Down
3 changes: 3 additions & 0 deletions sdks/python/pmxt/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,9 @@ class Trade:
side: Literal["buy", "sell", "unknown"]
"""Trade side"""

outcome_id: Optional[str] = None
"""The outcome this trade belongs to"""


@dataclass
class UserTrade(Trade):
Expand Down
6 changes: 3 additions & 3 deletions sdks/python/pmxt/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,15 +123,15 @@ def __init__(
self,
pmxt_api_key: Optional[str] = None,
base_url: Optional[str] = None,
auto_start_server: bool = False,
auto_start_server: Optional[bool] = None,
) -> None:
"""
Initialize the Router.

Args:
pmxt_api_key: PMXT API key (required for hosted mode).
base_url: Override the base URL (defaults to hosted API).
auto_start_server: Start local sidecar (default: False).
auto_start_server: Start local sidecar. Defaults to True for local mode and False for hosted mode.
"""
super().__init__(
exchange_name="router",
Expand Down Expand Up @@ -198,7 +198,7 @@ def fetch_market_matches(
if include_prices:
params["includePrices"] = True

raw = self._call_method("fetchMatches", params)
raw = self._call_method("fetchMarketMatches", params)
if not raw:
return []
return [_parse_match_result(m) for m in raw]
Expand Down
6 changes: 3 additions & 3 deletions sdks/typescript/pmxt/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,8 @@ export interface ExchangeOptions {
/** Optional Polymarket Proxy/Smart Wallet address */
proxyAddress?: string;

/** Optional signature type (0=EOA, 1=Proxy) */
signatureType?: number;
/** Optional signature type (0=EOA, 1=Proxy, or venue-specific string such as 'gnosis-safe') */
signatureType?: string | number;

/**
* EVM wallet address used for hosted reads/writes. Required for hosted
Expand Down Expand Up @@ -320,7 +320,7 @@ export abstract class Exchange {
protected apiKey?: string;
protected privateKey?: string;
protected proxyAddress?: string;
protected signatureType?: number;
protected signatureType?: string | number;
protected api: DefaultApi;
protected config: Configuration;
protected serverManager: ServerManager;
Expand Down
3 changes: 3 additions & 0 deletions sdks/typescript/pmxt/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,9 @@ export interface Trade {

/** Trade side */
side: "buy" | "sell" | "unknown";

/** The outcome this trade belongs to */
outcomeId?: string;
}

/**
Expand Down
Loading