Skip to content

SDK drift: Python Order dataclass has invalid field ordering (required fields after optional) #966

@realfishsam

Description

@realfishsam

Drift

The Python Order dataclass places remaining: float and timestamp: int (required, no default) after filled_shares: Optional[float] = None (optional, has default). Python dataclasses raise a TypeError at class definition time if any non-default field follows a field with a default. This means the Order class as written is broken at import time.

The TypeScript Order interface has the same logical fields in valid order: all required fields appear before optional ones.

TypeScript SDK

File: sdks/typescript/pmxt/models.ts lines 279–321

interface Order {
    id: string;
    marketId: string;
    outcomeId: string;
    side: "buy" | "sell";
    type: "market" | "limit";
    amount: number;
    status: string;
    filled: number;
    filledShares?: number;   // optional — comes before remaining required fields? No:
    remaining: number;       // required
    timestamp: number;       // required
    price?: number;
    fee?: number;
    feeRateBps?: number;
}

(TypeScript interfaces do not enforce declaration order, so this does not cause a runtime error there.)

Python SDK

File: sdks/python/pmxt/models.py lines 440–460 (approximately)

@dataclass
class Order:
    id: str
    market_id: str
    outcome_id: str
    side: Literal["buy", "sell"]
    type: Literal["market", "limit"]
    amount: float
    status: str
    filled: float
    filled_shares: Optional[float] = None  # line ~449: has default
    remaining: float                        # line ~452: required — INVALID after default field
    timestamp: int                          # line ~455: required — INVALID after default field
    price: Optional[float] = None
    fee: Optional[float] = None
    fee_rate_bps: Optional[float] = None

Python raises TypeError: non-default argument 'remaining' follows default argument when this class is defined.

Expected

remaining and timestamp must be declared before filled_shares in the Python dataclass, so that all required (non-default) fields precede all optional (default) fields. This mirrors the logical structure of the TypeScript interface and is required for the class to be instantiable.

Impact

The Order dataclass cannot be instantiated (or even imported successfully) in Python. Any code path that returns an Order object — fetchOrder, fetchOpenOrders, fetchClosedOrders, fetchAllOrders, submitOrder — will raise a TypeError at runtime.


Found by automated SDK cross-language drift audit

Metadata

Metadata

Assignees

No one assigned

    Labels

    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