Summary
Two WS payload classes still expose dollar/count fields as raw strings, defeating the SDK contract that every _dollars field is DollarDecimal and every _fp field is FixedPointCount (the #225 + #230 coercion contract).
OrderGroupPayload.contracts_limit: str | None (validation_alias contracts_limit_fp) — should be FixedPointCount. The REST mirror kalshi/models/order_groups.py:OrderGroup.contracts_limit already uses FixedPointCount.
TickerPayload.dollar_volume: str, TickerPayload.dollar_open_interest: str — should be DollarDecimal. These are dollar-denominated quantities pushed on every ticker update (one of the highest-volume channels).
Downstream code has to remember to wrap them in Decimal(...) and risks Decimal("") InvalidOperation if the server ever emits an empty string.
Location
kalshi/ws/models/order_group.py:10-14
kalshi/ws/models/ticker.py:46-47
Evidence
# order_group.py
contracts_limit: str | None = Field(
default=None,
validation_alias=AliasChoices("contracts_limit_fp", "contracts_limit"),
)
# ticker.py
dollar_volume: str
dollar_open_interest: str
Recommended fix
- Retype
OrderGroupPayload.contracts_limit to FixedPointCount | None.
- Retype
TickerPayload.dollar_volume and dollar_open_interest to DollarDecimal. Wire keys already match the field names so no alias change is needed.
Add regression tests confirming validation now produces Decimal.
Severity & category
medium / consistency, ws
Summary
Two WS payload classes still expose dollar/count fields as raw strings, defeating the SDK contract that every
_dollarsfield isDollarDecimaland every_fpfield isFixedPointCount(the #225 + #230 coercion contract).OrderGroupPayload.contracts_limit: str | None(validation_aliascontracts_limit_fp) — should beFixedPointCount. The REST mirrorkalshi/models/order_groups.py:OrderGroup.contracts_limitalready usesFixedPointCount.TickerPayload.dollar_volume: str,TickerPayload.dollar_open_interest: str— should beDollarDecimal. These are dollar-denominated quantities pushed on every ticker update (one of the highest-volume channels).Downstream code has to remember to wrap them in
Decimal(...)and risksDecimal("") InvalidOperationif the server ever emits an empty string.Location
kalshi/ws/models/order_group.py:10-14kalshi/ws/models/ticker.py:46-47Evidence
Recommended fix
OrderGroupPayload.contracts_limittoFixedPointCount | None.TickerPayload.dollar_volumeanddollar_open_interesttoDollarDecimal. Wire keys already match the field names so no alias change is needed.Add regression tests confirming validation now produces Decimal.
Severity & category
medium / consistency, ws