Skip to content

fix(perps)!: bulk orderbooks endpoint + required MarginMarket.funding_invalid_premium_handling (#540) - #541

Merged
TexasCoding merged 1 commit into
mainfrom
fix/540-perps-orderbooks-drift
Oct 13, 2026
Merged

TexasCoding merged 1 commit into
mainfrom
fix/540-perps-orderbooks-drift

Conversation

@TexasCoding

Copy link
Copy Markdown
Owner

Closes #540

Nightly strict spec-drift found two perps drifts after the upstream perps OpenAPI re-pin:

  1. New endpoint GET /margin/markets/orderbooks → markets.bulk_orderbooks(*, tickers) on sync and async perps clients. tickers is required (1–100), serialized comma-joined (style: form, explode: false); returns list[MarginOrderbook]. Public GET (no auth), retried per existing GET policy. Missing/empty per-item ticker raises KalshiError.
  2. MarginMarket.funding_invalid_premium_handling — spec-required Literal["dampen", "exclude"]. Breaking for code that constructs MarginMarket without it (live list/get responses are unaffected). Migration note added to docs/migration.md; next release is a major bump.

Specs: specs/perps_openapi.yaml re-pinned; core OpenAPI 3.34.0 unchanged; scripts/generate.py produced no _generated/ diff. Optional MarginMarket.market_id remains additive-optional drift (warning only, not a gate failure).

Blast radius (GitNexus unavailable — manual)

  • MarginMarket: consumed by PerpsMarketsResource.list/get (+ async), contract map entry, tests/perps/test_markets.py, tests/integration/test_perps_markets.py, docs.
  • New GetMarginMarketOrderbooksResponse, _orderbook_from_item, _bulk_orderbooks_params, bulk_orderbooks: only called by the new methods. _parse_orderbook reused unchanged; _join_tickers reused from kalshi.resources._base.
  • Endpoint registered in tests/_contract_support.py METHOD_ENDPOINT_MAP and PERPS_CONTRACT_MAP.

Gate (local)

  • uv run ruff check . — pass
  • uv run mypy kalshi/ — pass (160 files)
  • uv run pytest tests/ --ignore=tests/integration -q — 4693 passed
  • uv run pytest tests/test_contracts.py -q -W error::UserWarning (nightly strict) — 850 passed

@TexasCoding
TexasCoding merged commit d7e6750 into main Oct 13, 2026
6 checks passed
@TexasCoding
TexasCoding deleted the fix/540-perps-orderbooks-drift branch October 13, 2026 15:08
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.

Nightly spec-drift: strict contract tests failing (since 2026-10-13)

1 participant