Skip to content

fix(kalshi): OHLCV normalizer + docs outcomeId param#1429

Merged
realfishsam merged 2 commits into
mainfrom
fix/kalshi-ohlcv-normalizer
Jul 1, 2026
Merged

fix(kalshi): OHLCV normalizer + docs outcomeId param#1429
realfishsam merged 2 commits into
mainfrom
fix/kalshi-ohlcv-normalizer

Conversation

@realfishsam

Copy link
Copy Markdown
Contributor

Two related fixes surfaced while building a Kalshi UI against api.pmxt.dev.

1. Docs: wrong query param name for fetchOHLCV

docs/api-reference/fetch-ohlcv.mdx and docs/llms-full.txt told callers to use ?id=..., but the server (and openapi.json) require ?outcomeId=.... The server responded with "Invalid ID for OHLCV: ID cannot be empty".

2. Kalshi OHLCV normalizer returned close: 0

Reproducer against live api.pmxt.dev:

  • Underlying Kalshi API returns price.close_dollars: "0.9700" etc.
  • PMXT returned rows with open:0, high:0, low:0, close:0.

Cause: the Kalshi raw candle shape uses nested price.{open,high,low,close}_dollars strings, but the normalizer was reading flat raw.open / raw.close fields that don't exist.

What changed

  • core/src/exchanges/kalshi/fetcher.ts — widened KalshiRawCandlestick to include *_dollars strings and volume_fp.
  • core/src/exchanges/kalshi/normalizer.ts — prefer price.*_dollars as-is, fall back to legacy cents via fromKalshiCents, use volume_fp.
  • core/test/normalizers/kalshi-ohlcv-normalization.test.ts — 3 new tests: new API dollars, legacy cents fallback, yes_ask/yes_bid dollar averaging.

Verification

  • npx tsc --project core/tsconfig.json --noEmit — clean
  • npm test --workspace=pmxt-core -- --runInBand — 45 suites / 798 tests passing

The server (and docs/api-reference/openapi.json) require ?outcomeId=,
not ?id=. Callers following the old curl example hit
'Invalid ID for OHLCV: ID cannot be empty'.
…alizer

Kalshi's candlestick API returns nested price data as
{ open_dollars, high_dollars, low_dollars, close_dollars, mean_dollars }
strings (e.g. close_dollars: "0.9700"), not the flat
{ open, high, low, close } cent integers the normalizer assumed. As a
result, every candle came out with open/high/low/close = 0.

The normalizer now prefers the *_dollars string fields (parsed via
Number), falls back to legacy cent integers via fromKalshiCents, and
reads volume from volume_fp when present. Adds regression tests
pinning close_dollars="0.9700" -> close===0.97.
@realfishsam realfishsam merged commit 6fe0bd8 into main Jul 1, 2026
11 of 12 checks passed
@realfishsam realfishsam deleted the fix/kalshi-ohlcv-normalizer branch July 1, 2026 14:59
@mintlify

mintlify Bot commented Jul 1, 2026

Copy link
Copy Markdown

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated (UTC)
PMXT 🔴 Failed Jul 1, 2026, 3:06 PM

💡 Tip: Enable Workflows to automatically generate PRs for you.

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.

1 participant