Skip to content

Models: WS payloads use raw str for _fp / _dollars fields (OrderGroup, Ticker) #258

Description

@TexasCoding

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).

  1. 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.
  2. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingwsWebSocket-related

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions