You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Multiple type safety and naming fixes in the Python client: (1) renames type param to order_type in create_order/build_order to avoid shadowing the Python builtin, (2) renames OrderBook.dt field to OrderBook.datetime in models.py and removes the 'dt': 'datetime' mapping from _SNAKE_TO_CAMEL, (3) adds _convert_params_to_camel() helper and applies it to 5 fetch methods (fetchMarkets, fetchMarketsPaginated, fetchEvents, fetchMarket, fetchEvent) so snake_case kwargs are converted to camelCase for the sidecar wire format, (4) adds concrete return types (MatchResult, PriceComparison, etc.) to 8 router methods that previously returned List[Any], (5) types watch_* callback parameters with Callable and return types with Dict[str, Any], (6) fixes list[str] to Optional[List[str]] on watch_address.
sdks/python/pmxt/models.py -- OrderBook.dt renamed to OrderBook.datetime
Findings
Breaking change: type renamed to order_type. All callers using exchange.create_order(type="limit") must update to exchange.create_order(order_type="limit"). This is the right move to avoid shadowing Python's type builtin, but it's a breaking change.
Breaking change: OrderBook.dt renamed to OrderBook.datetime. Any code accessing orderbook.dt will break. However, 'dt': 'datetime' is removed from _SNAKE_TO_CAMEL, which means _auto_convert will now try to map the datetime field from the camelCase key datetime (which is identity). This is correct because the sidecar sends "datetime" as the JSON key. The old mapping was dt -> datetime in the mapping table so that the snake_case field dt would look up the camelCase key datetime in the raw dict. Now that the field IS named datetime, the identity mapping works.
Merge conflict with PR 598. PR 598 makes side, type, amount keyword-only with no defaults. PR 600 renames type to order_type but keeps the defaults ("buy", "market", 0). The intended end state should be keyword-only order_type with no defaults. These PRs must be merged carefully.
_convert_params_to_camel only converts top-level keys. This is documented in the docstring and consistent with the sidecar's expectations. Nested filter objects (e.g., filter={"text": "..."}) pass through as-is, which is correct because nested keys are already camelCase in the filter schema.
New type imports (MatchResult, EventMatchResult, PriceComparison, ArbitrageOpportunity) from models.py. Verified these types exist in the Python models.py already. Import is correct.
watch_address types param changed from list[str] = None to Optional[List[str]] = None. This is a Python 3.8 compatibility fix (bare list[str] requires 3.9+). Good fix.
PMXT Pipeline Check
Field propagation: N/A -- no new unified fields
OpenAPI sync: N/A -- SDK-only changes
Type safety: OK -- replaces Any with concrete types throughout
Semver Impact
major -- type to order_type rename and dt to datetime rename are both breaking changes to the public API
Risk
Merge conflict with PR 598 is certain (both touch create_order/build_order signatures). The _convert_params_to_camel helper is only applied to 5 methods -- other methods that accept params dicts (e.g., fetch_order_book, fetch_trades, fetch_ohlcv) still pass params as-is. Verify those methods don't need the same treatment, or document why they're excluded. No tests added for the camelCase conversion.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #563
Fixes #449
Fixes #452
Fixes #456
Fixes #496