Skip to content

fix: read liquidity_dollars instead of deprecated liquidity in kalshi#588

Merged
realfishsam merged 1 commit into
mainfrom
fix/554-kalshi-liquidity
May 24, 2026
Merged

fix: read liquidity_dollars instead of deprecated liquidity in kalshi#588
realfishsam merged 1 commit into
mainfrom
fix/554-kalshi-liquidity

Conversation

@realfishsam
Copy link
Copy Markdown
Contributor

Fixes #554

@realfishsam
Copy link
Copy Markdown
Contributor Author

PR Review: PASS (NOT VERIFIED)

What This Does

Updates the Kalshi normalizer to prefer liquidity_dollars over the deprecated liquidity field for both per-market liquidity and the event-level liquidity aggregation function.

Blast Radius

  • Kalshi exchange: normalizer.ts -- two changes:
    1. normalizeRawMarket: liquidity line now reads liquidity_dollars first, falls back to liquidity
    2. eventLiquidity: aggregation function updated with same precedence
  • No SDK, OpenAPI, or other exchange changes

Findings

  1. Vendor spec confirms both fields are deprecated -- per core/specs/kalshi/Kalshi.yaml (line 6736-6740), liquidity_dollars is marked deprecated and "will always return '0.0000'". The old liquidity field (line 6734-6735) is also deprecated and "will always return 0". Both fields are deprecated and return zero values according to the spec.
  2. Type safety concern -- KalshiRawMarket in fetcher.ts (line 31) only defines liquidity?: number. There is no liquidity_dollars property. The field is accessed via the [key: string]: unknown index signature, which means there is no compile-time guarantee it exists or has the expected type. Adding liquidity_dollars?: string to the interface would be cleaner.
  3. parseFloat on potentially undefined -- in normalizeRawMarket, the expression parseFloat(String(market.liquidity_dollars || market.liquidity || '0')) will work but is convoluted. String(undefined) produces "undefined", which parseFloat returns NaN for, then || 0 catches it. It works but is fragile.
  4. eventLiquidity has a different pattern -- uses parseFloat(m.liquidity_dollars || m.open_interest || m.liquidity || '0') which passes potentially non-string values directly to parseFloat. Since m.open_interest and m.liquidity are typed as number | undefined, passing a number to parseFloat is fine (it gets stringified), but the mixing of types in the fallback chain is not clean.
  5. No tests added -- no test coverage for the liquidity field change.

PMXT Pipeline Check

  • Field propagation: N/A (liquidity is already in all layers)
  • OpenAPI sync: N/A
  • Type safety: ISSUE -- liquidity_dollars not in KalshiRawMarket interface

Semver Impact

patch -- internal field preference change; no public API impact unless liquidity values were previously non-zero and are now zero (or vice versa)

Risk

Both liquidity and liquidity_dollars are documented as deprecated and returning zero in the Kalshi vendor spec. This change may be moot if Kalshi has already zeroed both fields. Cannot verify without a live API call whether liquidity_dollars actually returns meaningful data despite the spec claiming it returns "0.0000".

@realfishsam realfishsam merged commit 84c840c into main May 24, 2026
11 of 12 checks passed
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.

Response drift: kalshi — market.liquidity field renamed to liquidity_dollars, liquidity always 0

1 participant