Skip to content

Conversation

@codecadede
Copy link

@codecadede codecadede commented Nov 25, 2025

Note

Refactors clob_types.py with Enum-based types, new Base/Limit/Market order args, Optional-typed query models, TickSize/options types, and removes redundant serialization helpers.

  • Types & Enums
    • Replace old enumerate classes with Enum for OrderType and new AssetType.
    • Add TickSize Literal and option structs (CreateOrderOptions, PartialCreateOrderOptions).
  • Order Models
    • Introduce BaseOrderArgs; split into OrderArgs (limit) and MarketOrderArgs (market) with order_type defaulting to FOK.
    • Consolidate common fields and clarify docstrings; add expiration to OrderArgs.
  • API/Query Models
    • Add/clarify dataclasses (ApiCreds, RequestArgs, BookParams).
    • Update filter params (TradeParams, OpenOrderParams, DropNotificationParams, BalanceAllowanceParams) to use Optional types.
  • Order Book Models
    • Simplify OrderSummary and OrderBookSummary; remove custom __dict__/json properties in favor of asdict/dumps.
  • Misc
    • Add RoundConfig, enhance ContractConfig docs, and general type/documentation cleanup.

Written by Cursor Bugbot for commit 8c51e2b. This will update automatically on new commits. Configure here.

@codecadede codecadede requested a review from a team as a code owner November 25, 2025 22:44
size: Optional[str] = None

# Note: Removed redundant __dict__ and json properties.
# Use asdict(self) and dumps(asdict(self)) externally for serialization.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Removed property still referenced in hash generation

The json property was removed from OrderBookSummary but is still referenced in utilities.py at line 32 in generate_orderbook_summary_hash. The function attempts to access orderbook.json which no longer exists, causing an AttributeError at runtime when generating orderbook hashes.

Fix in Cursor Fix in Web

GTC = "GTC" # Good Till Cancelled
FOK = "FOK" # Fill or Kill
GTD = "GTD" # Good Till Date (Expiration)
FAK = "FAK" # Fill and Kill
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Enum not JSON serializable in order submission

Changing from the old (incorrect) enumerate base to proper Enum breaks JSON serialization. The OrderType enum is passed directly to order_to_json in utilities.py and placed in a dictionary that gets JSON serialized by httpx. Python's standard json module cannot serialize Enum objects, causing a TypeError when posting orders. The enum value needs to be extracted using .value before serialization.

Fix in Cursor Fix in Web

# --- ASSET & CONFIGURATION MODELS ---

class AssetType(Enum):
"""Defines the type of asset used in the exchange."""
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Enum string conversion produces incorrect query parameter

Changing AssetType from enumerate to Enum breaks query parameter generation in helpers.py line 153. The code calls params.asset_type.__str__() which returns "AssetType.COLLATERAL" instead of just "COLLATERAL". This produces malformed API query parameters. The enum value should be accessed using .value instead of .__str__() for proper serialization.

Fix in Cursor Fix in Web

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant