Fix types to allow fractional order quantities - #6
Open
AshishMBakshi wants to merge 1 commit into
Open
Conversation
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The order API supports fractional quantities for markets whose
minimumTradeQtyis below one, and order responses can contain fractionalquantity,cumQuantity, andleavesQuantityvalues. The current TypedDicts declare all five order quantity fields asint, so static type checkers reject valid create/modify requests and incorrectly describe fractional responses.This changes those annotations to
int | float. Keepingintin the union preserves the natural whole-contract call shape while accurately accepting the decimal JSON numbers supported by the API.Example currently rejected by mypy/pyright:
Affected fields:
Order.quantityOrder.cumQuantityOrder.leavesQuantityCreateOrderParams.quantityModifyOrderParams.quantityIf maintainers prefer a single numeric alias, the same change could use a
Quantity = int | floatalias.Decimalis not appropriate for response typing unless the SDK JSON decoder is also configured to returnDecimal.Note
Low Risk
Type-only annotation changes with no runtime behavior; low risk aside from slightly broader static typing for quantity fields.
Overview
Updates order-related TypedDict annotations so quantity fields match the API’s support for fractional sizes (e.g. when a market’s minimum trade size is below one).
quantity,cumQuantity, andleavesQuantityonOrder, plusquantityonCreateOrderParamsandModifyOrderParams, are now typed asint | floatinstead ofint. Whole-number quantities remain valid; static checkers no longer reject decimal literals in create/modify payloads or mis-type fractional values in responses.Reviewed by Cursor Bugbot for commit 7af0e3b. Bugbot is set up for automated code reviews on this repo. Configure here.