feat!: spec sync 3.21.0 → 3.22.0 (v5.0.0) — drop V1 order API, add RFQ quote endpoints#459
Conversation
…Q quote endpoints
Upstream OpenAPI 3.22.0 removed the V1 order-write endpoints; the SDK drops the
V1 order methods and their dedicated models in favor of the V2
`/portfolio/events/orders` family (available since 3.18.0). Also reconciles the
remaining additive drift and adds the three new RFQ-scoped quote endpoints.
Removed (breaking):
- orders.{create,cancel,batch_create,batch_cancel,amend,decrease} (sync + async)
- V1 order models: CreateOrderRequest, AmendOrderRequest, AmendOrderResponse,
DecreaseOrderRequest, BatchCreate*/BatchCancel* request/response models,
BatchCancelOrdersRequestOrder, and the ActionLiteral alias
- event_ticker/market_ticker filters on GET /communications/quotes
Added:
- communications.quotes.{accept_for_rfq,confirm_for_rfq,delete_for_rfq}
- cancel_v2 market_ticker query param; BatchCancelOrdersV2RequestOrder.market_ticker
- SubaccountBalance.exchange_index
- perps SCM: MarketSettlementEstimate, SettlementEstimate.positions,
GetSettlementEstimateResponse.prev_settlement_prices
Contract drift suite, mypy (strict), and ruff all pass; 4086 tests green.
Closes #454
Closes #458
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Code Review — feat!: spec sync 3.21.0 → 3.22.0 (v5.0.0)OverviewThis is a well-executed breaking-change release. The core operation — removing the V1 order-write surface now that Kalshi dropped it from the spec — is done surgically: every V1 method, model, import, test, contract entry, and EXCLUSION is cleaned up without touching adjacent code. The three new RFQ-scoped quote endpoints follow existing conventions exactly. Migration guide and CHANGELOG are comprehensive. Test suite passes (4097/0). Issues / Concerns1. The @respx.mock
def test_cancel_v2_auto_route_sends_market_ticker(self, orders: OrdersResource) -> None:
route = respx.delete(
"https://test.kalshi.com/trade-api/v2/portfolio/events/orders/ord-1"
).mock(return_value=httpx.Response(200, json={...}))
orders.cancel_v2("ord-1", exchange_index=-1, market_ticker="MKT-A")
assert route.calls[0].request.url.params["market_ticker"] == "MKT-A"2. Both 3. subaccount_number: int
exchange_index: int # required, no default
balance: DollarDecimalDeclaring this without a default means any API response that omits Positives worth calling out
VerdictApprove with one suggested fix: the |
Summary
Syncs the upstream OpenAPI spec 3.21.0 → 3.22.0 and ships SDK v5.0.0.
Resolves both open spec-drift issues (the nightly strict-contract failure and the
drift report).
The headline change is breaking: Kalshi removed the V1 order-write
endpoints from the spec, so the SDK removes the V1 order methods and their
dedicated models. Order writes now go exclusively through the V2
/portfolio/events/ordersfamily (the*_v2methods, which have existed since3.18.0). The remaining drift is additive and reconciled in place, plus the three
new RFQ-scoped quote endpoints are implemented.
This was triaged with the maintainer, who chose "match the spec exactly
(breaking)" over a deprecation shim, and "add the new RFQ endpoints now."
Removed (breaking)
client.orders(sync + async):create,cancel,batch_create,batch_cancel,amend,decrease. The underlyingendpoints (
POST/DELETE /portfolio/orders,/portfolio/orders/batched,/portfolio/orders/{id}/amend|decrease) were removed from the spec in 3.22.0.CreateOrderRequest,AmendOrderRequest,AmendOrderResponse,DecreaseOrderRequest,BatchCreate*/BatchCancel*request/response models,BatchCancelOrdersRequestOrder, and theActionLiteralalias.event_ticker/market_tickeronGET /communications/quotes(removed upstream).Added
client.communications.quotes(sync + async):accept_for_rfq,confirm_for_rfq,delete_for_rfq— backingPUT/DELETE /communications/rfqs/{rfq_id}/quotes/{quote_id}[/accept|/confirm].cancel_v2market_tickerquery param +BatchCancelOrdersV2RequestOrder.market_ticker(required when
exchange_index == -1; the model now accepts-1to auto-route).SubaccountBalance.exchange_index.MarketSettlementEstimate,SettlementEstimate.positions,GetSettlementEstimateResponse.prev_settlement_prices.Migration
V1 → V2 mapping is documented in
docs/migration.md(newv4 → v5.0.0section)and
CHANGELOG.md. Reads (get/list/queue_positions/fills) are unchanged.Verification
uv run pytest tests/→ 4097 passed, 311 skipped, 0 faileduv run mypy kalshi/→ clean (strict, 157 files)uv run ruff check .→ cleanTestRequestParamDrift/TestRequestBodyDrift/TestSpecDrift/TestPerpsScmSpecDrift) green against the re-vendored spec.guards) and the
exchange_index=-1auto-route path.Docs were swept for the V2-only order API; an adversarial multi-agent review pass
caught and fixed several example bugs (missing required
self_trade_prevention_type,an invalid STP value, stale operation counts).
Closes #454
Closes #458
🤖 Generated with Claude Code