From Wave 5 architecture + WS audits — F-N-02, F-N-09, F-N-11, F-N-12, F-P-07. Severity: medium (silent-bug risk).
What's wrong
Several size/volume/count fields are annotated as `DollarDecimal` even though their wire alias is `_fp` (FixedPointCount) and the inline comments explicitly say "FixedPointCount":
- `kalshi/models/markets.py:83-111` — `Market.yes_bid_size`, `yes_ask_size`, `no_bid_size`, `no_ask_size`, `volume`, `volume_24h`, `open_interest`
- `kalshi/models/markets.py:220-227` — `Candlestick.volume`, `open_interest`
- `kalshi/models/orders.py:111` — `Fill.count` (while sibling `Order.count` at line 56 is correctly `FixedPointCount`)
`DollarDecimal` strongly implies a price — misleading.
Why it works today (and the latent bug)
`_to_decimal_dollars` (`kalshi/types.py:13-27`) and `_to_decimal_fp` (`:47-60`) are byte-identical implementations. If one parser ever diverges (a per-family scale factor, different precision rule), every mistyped size/volume/count silently breaks.
Related fix
`OrderbookDeltaPayload.side: str` at `kalshi/ws/models/orderbook_delta.py:48` — should be `Literal["yes", "no"]`. The orderbook manager dispatches on `side == "yes"` vs anything-else (`orderbook.py:72`); any future server bug emitting `"YES"` or `"both"` silently routes to the `no` side.
Fix
- Change the mistyped fields to `FixedPointCount`.
- Tighten `OrderbookDeltaPayload.side` to `Literal["yes", "no"]`.
- Consolidate `_to_decimal_dollars` and `_to_decimal_fp` to a single shared callable (and reference it from both `Annotated` aliases) — keeps the type distinction at the annotation layer, removes the copy-paste hazard. Add a comment noting the intentional same-implementation choice.
From Wave 5 architecture + WS audits — F-N-02, F-N-09, F-N-11, F-N-12, F-P-07. Severity: medium (silent-bug risk).
What's wrong
Several size/volume/count fields are annotated as `DollarDecimal` even though their wire alias is `_fp` (FixedPointCount) and the inline comments explicitly say "FixedPointCount":
`DollarDecimal` strongly implies a price — misleading.
Why it works today (and the latent bug)
`_to_decimal_dollars` (`kalshi/types.py:13-27`) and `_to_decimal_fp` (`:47-60`) are byte-identical implementations. If one parser ever diverges (a per-family scale factor, different precision rule), every mistyped size/volume/count silently breaks.
Related fix
`OrderbookDeltaPayload.side: str` at `kalshi/ws/models/orderbook_delta.py:48` — should be `Literal["yes", "no"]`. The orderbook manager dispatches on `side == "yes"` vs anything-else (`orderbook.py:72`); any future server bug emitting `"YES"` or `"both"` silently routes to the `no` side.
Fix