fix(kalshi): OHLCV normalizer + docs outcomeId param#1429
Merged
Conversation
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.
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Workflows to automatically generate PRs for you. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two related fixes surfaced while building a Kalshi UI against
api.pmxt.dev.1. Docs: wrong query param name for
fetchOHLCVdocs/api-reference/fetch-ohlcv.mdxanddocs/llms-full.txttold callers to use?id=..., but the server (andopenapi.json) require?outcomeId=.... The server responded with"Invalid ID for OHLCV: ID cannot be empty".2. Kalshi OHLCV normalizer returned
close: 0Reproducer against live
api.pmxt.dev:price.close_dollars: "0.9700"etc.open:0, high:0, low:0, close:0.Cause: the Kalshi raw candle shape uses nested
price.{open,high,low,close}_dollarsstrings, but the normalizer was reading flatraw.open/raw.closefields that don't exist.What changed
core/src/exchanges/kalshi/fetcher.ts— widenedKalshiRawCandlestickto include*_dollarsstrings andvolume_fp.core/src/exchanges/kalshi/normalizer.ts— preferprice.*_dollarsas-is, fall back to legacy cents viafromKalshiCents, usevolume_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— cleannpm test --workspace=pmxt-core -- --runInBand— 45 suites / 798 tests passing