Skip to content

SDK drift: Python hosted _hosted_build_order_request validates limit-order price presence and positivity; TypeScript _hostedBuildOrderBody does not #1287

Description

@realfishsam

Summary

Python's _hosted_build_order_request validates two price constraints that TypeScript's _hostedBuildOrderBody does not: (1) that price is provided for limit orders, and (2) that price > 0.

Python (sdks/python/pmxt/client.py, lines 747–750)

def _hosted_build_order_request(self, ..., price: Optional[float], ...):
    ...
    if order_type == "limit" and price is None:
        raise InvalidOrder("price is required for limit orders")
    if price is not None and price <= 0:
        raise InvalidOrder("price must be positive")

TypeScript (sdks/typescript/pmxt/client.ts, lines 2490–2519)

private _hostedBuildOrderBody(params): Record<string, unknown> {
    ...
    // No check: price required for limit orders
    // No check: price > 0
    if (!(Number(params.amount) > 0)) {
        throw new InvalidOrder("amount must be positive");  // only amount is validated
    }
    ...
    if (params.price !== undefined) body["price"] = params.price;
    ...
}

Impact

  • A TypeScript caller sending a limit order with price: undefined or price: 0 or price: -0.1 will not receive a local InvalidOrder — the malformed request is forwarded to the server, which may return a less informative error.
  • A Python caller with the same inputs gets an immediate, descriptive InvalidOrder before any network round-trip.
  • The asymmetry means price validation errors surface at different layers in the two SDKs, making cross-SDK documentation and error-handling examples inconsistent.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions