Skip to content

Fix types to allow fractional order quantities - #6

Open
AshishMBakshi wants to merge 1 commit into
Polymarket:mainfrom
AshishMBakshi:patch-1
Open

Fix types to allow fractional order quantities#6
AshishMBakshi wants to merge 1 commit into
Polymarket:mainfrom
AshishMBakshi:patch-1

Conversation

@AshishMBakshi

@AshishMBakshi AshishMBakshi commented Aug 2, 2026

Copy link
Copy Markdown

The order API supports fractional quantities for markets whose minimumTradeQty is below one, and order responses can contain fractional quantity, cumQuantity, and leavesQuantity values. The current TypedDicts declare all five order quantity fields as int, so static type checkers reject valid create/modify requests and incorrectly describe fractional responses.

This changes those annotations to int | float. Keeping int in 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:

from polymarket_us.types.orders import CreateOrderParams

params: CreateOrderParams = {
    "marketSlug": "example-market",
    "intent": "ORDER_INTENT_BUY_LONG",
    "quantity": 0.84,
}

Affected fields:

  • Order.quantity
  • Order.cumQuantity
  • Order.leavesQuantity
  • CreateOrderParams.quantity
  • ModifyOrderParams.quantity

If maintainers prefer a single numeric alias, the same change could use a Quantity = int | float alias. Decimal is not appropriate for response typing unless the SDK JSON decoder is also configured to return Decimal.


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, and leavesQuantity on Order, plus quantity on CreateOrderParams and ModifyOrderParams, are now typed as int | float instead of int. 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.

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