Skip to content

Response drift: kalshi — response_price_units field present but never checked by normalizer #919

@realfishsam

Description

@realfishsam

Exchange

kalshi

Severity

MEDIUM

What Our Normalizer Expects

core/src/exchanges/kalshi/normalizer.ts unconditionally parses all *_dollars price fields as dollar-denominated floats (e.g. parseFloat(raw.last_price_dollars)). The normalizer never reads the response_price_units field.

// normalizer.ts ~line 51
price: parseFloat(raw.last_price_dollars ?? raw.yes_ask_dollars ?? ...),

What The Live API Returns

The live /markets and /markets/{ticker} endpoints include a response_price_units field not present in the local type definitions:

markets[].response_price_units: str     ← NEW, not read by normalizer
markets[].last_price_dollars: str       ← read, assumed to be dollars
markets[].yes_ask_dollars: str          ← read, assumed to be dollars
markets[].yes_bid_dollars: str          ← read, assumed to be dollars

Endpoint tested: GET https://api.elections.kalshi.com/trade-api/v2/markets?limit=1

Impact

MEDIUM: response_price_units signals the denomination of the accompanying price fields. If Kalshi ever serves a response where this field is not "dollars" (e.g. for certain market types or future API changes), the normalizer will parse cent-scale values as dollar-scale values, silently producing prices 100x off. No current crash, but a latent parsing correctness risk.

Suggested Fix

Read response_price_units and apply a conditional divisor:

const isInCents = raw.response_price_units === 'cent';
const scale = isInCents ? 100 : 1;
price: parseFloat(raw.last_price_dollars ?? '0') / scale,

Also add response_price_units?: string to the KalshiRawMarket type.


Found by automated response shape drift audit

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions