-
Notifications
You must be signed in to change notification settings - Fork 162
Update clob_types.py #184
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Update clob_types.py #184
Conversation
| size: Optional[str] = None | ||
|
|
||
| # Note: Removed redundant __dict__ and json properties. | ||
| # Use asdict(self) and dumps(asdict(self)) externally for serialization. |
There was a problem hiding this comment.
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.
| GTC = "GTC" # Good Till Cancelled | ||
| FOK = "FOK" # Fill or Kill | ||
| GTD = "GTD" # Good Till Date (Expiration) | ||
| FAK = "FAK" # Fill and Kill |
There was a problem hiding this comment.
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.
| # --- ASSET & CONFIGURATION MODELS --- | ||
|
|
||
| class AssetType(Enum): | ||
| """Defines the type of asset used in the exchange.""" |
There was a problem hiding this comment.
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.
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.
enumerateclasses withEnumforOrderTypeand newAssetType.TickSizeLiteraland option structs (CreateOrderOptions,PartialCreateOrderOptions).BaseOrderArgs; split intoOrderArgs(limit) andMarketOrderArgs(market) withorder_typedefaulting toFOK.expirationtoOrderArgs.ApiCreds,RequestArgs,BookParams).TradeParams,OpenOrderParams,DropNotificationParams,BalanceAllowanceParams) to useOptionaltypes.OrderSummaryandOrderBookSummary; remove custom__dict__/jsonproperties in favor ofasdict/dumps.RoundConfig, enhanceContractConfigdocs, and general type/documentation cleanup.Written by Cursor Bugbot for commit 8c51e2b. This will update automatically on new commits. Configure here.