Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,8 @@ uv.lock
# Generated models (build artifact, not committed)
kalshi/_generated/models.py

# AsyncAPI spec (downloaded for future WebSocket support, not committed)
# Note: specs/openapi.yaml IS committed as a pinned snapshot for deterministic PR builds.
specs/asyncapi.yaml
# Note: specs/openapi.yaml AND specs/asyncapi.yaml are both committed as
# pinned snapshots for deterministic PR builds + correct drift detection.
.gitnexus

# MkDocs build output
Expand Down
75 changes: 75 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,81 @@

All notable changes to kalshi-sdk will be documented in this file.

## 2.1.0 — 2026-05-18

OpenAPI spec sync from v3.13.0 → v3.18.0. Adds the V2 event-market
orders family, deposits/withdrawals history, account endpoint-cost
introspection, and several optional query / body fields. Also fixes
a recurring false-alarm in the weekly spec-sync workflow.

### Added

- **V2 event-market orders** (`/portfolio/events/orders/*`). Legacy
`/portfolio/orders` will be deprecated no earlier than May 6, 2026.
- `orders.create_v2(request=CreateOrderV2Request(...))`
- `orders.cancel_v2(order_id, subaccount=..., exchange_index=...)`
- `orders.amend_v2(order_id, request=AmendOrderV2Request(...))`
- `orders.decrease_v2(order_id, request=DecreaseOrderV2Request(...))`
- `orders.batch_create_v2(request=BatchCreateOrdersV2Request(...))`
- `orders.batch_cancel_v2(request=BatchCancelOrdersV2Request(...))`
- `portfolio.deposits()` / `portfolio.deposits_all()` — deposit history.
- `portfolio.withdrawals()` / `portfolio.withdrawals_all()` — withdrawal history.
- `account.endpoint_costs()` — lists endpoints whose token cost differs from the default.
- Optional `exchange_index` on `CreateOrderRequest`, `AmendOrderRequest`,
`DecreaseOrderRequest`, `BatchCancelOrdersRequestOrder`, `CreateOrderGroupRequest`,
and as a query kwarg on `orders.cancel` / `order_groups.delete`.
- Optional `user_filter` on `communications.list_rfqs` / `list_all_rfqs`;
`user_filter` + `rfq_user_filter` on `communications.list_quotes` / `list_all_quotes`.
- Optional `incentive_description` on `incentive_programs.list` / `list_all`.
- Optional `post_only` on `CreateQuoteRequest`.
- `Balance.balance_dollars` (required, `DollarDecimal`) — the same value as
`balance` (cents) rendered as a fixed-point dollar string. Required in
the v3.18.0 spec for `GetBalanceResponse`.
- `Balance.balance_breakdown` (optional, `list[IndexedBalance]`) — splits
the balance across exchange shards when present.
- New `IndexedBalance` model (`exchange_index`, `balance`) exposed from
`kalshi` and `kalshi.models`.

### Changed

- ``Balance`` gained a required ``balance_dollars: DollarDecimal`` field
(added by spec v3.18.0). Callers who construct ``Balance`` from API
responses are unaffected — the server now guarantees the field. But
callers who build ``Balance(...)`` instances directly in their own
tests or mocks will hit ``ValidationError`` until they add it. This is
a soft breaking change at the model-construction surface; the field is
required because the spec marks it ``required``, not optional-in-practice.

```python
# before v2.1.0
Balance(balance=50000, portfolio_value=75000, updated_ts=ts)

# v2.1.0+
Balance(
balance=50000,
balance_dollars=Decimal("500.00"), # new required field
portfolio_value=75000,
updated_ts=ts,
)
```

### Migration note

- ``CreateOrderV2Request.client_order_id`` is **required**. V1's
``CreateOrderRequest`` made it optional, so callers migrating from
``orders.create()`` to ``orders.create_v2()`` must generate a unique
client-order-id per call (UUID4 is the common choice). The server uses
this field as the V2 idempotency key, so reusing a value will cause
the server to return the original order rather than placing a new one.

### Fixed

- `specs/asyncapi.yaml` is now committed as a pinned snapshot, matching the
long-standing intent on `specs/openapi.yaml`. The weekly spec-sync workflow
no longer reports a bogus "AsyncAPI 0 → 13 channels" delta every Monday
(the file was previously gitignored, so each cron diffed the fresh
download against a non-existent old file).

## 2.0.0 — 2026-05-17

Audit-driven hardening release. 30 audit-findings landed across five
Expand Down
48 changes: 47 additions & 1 deletion kalshi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,30 @@
RFQ,
AcceptQuoteRequest,
AccountApiLimits,
AccountEndpointCosts,
ActionLiteral,
AmendOrderRequest,
AmendOrderResponse,
AmendOrderV2Request,
AmendOrderV2Response,
Announcement,
ApiKey,
ApplySubaccountTransferRequest,
AssociatedEvent,
Balance,
BatchCancelOrdersRequest,
BatchCancelOrdersRequestOrder,
BatchCancelOrdersV2Request,
BatchCancelOrdersV2RequestOrder,
BatchCancelOrdersV2Response,
BatchCancelOrdersV2ResponseEntry,
BatchCreateOrdersRequest,
BatchCreateOrdersV2Request,
BatchCreateOrdersV2Response,
BatchCreateOrdersV2ResponseEntry,
BidAskDistribution,
BookSideLiteral,
CancelOrderV2Response,
Candlestick,
CreateApiKeyRequest,
CreateApiKeyResponse,
Expand All @@ -42,13 +54,19 @@
CreateOrderGroupRequest,
CreateOrderGroupResponse,
CreateOrderRequest,
CreateOrderV2Request,
CreateOrderV2Response,
CreateQuoteRequest,
CreateQuoteResponse,
CreateRFQRequest,
CreateRFQResponse,
CreateSubaccountResponse,
DailySchedule,
DecreaseOrderRequest,
DecreaseOrderV2Request,
DecreaseOrderV2Response,
Deposit,
EndpointTokenCost,
Event,
EventCandlesticks,
EventMetadata,
Expand Down Expand Up @@ -82,6 +100,7 @@
IncentiveProgram,
IncentiveProgramStatusLiteral,
IncentiveProgramTypeLiteral,
IndexedBalance,
LiveData,
LookupPoint,
LookupTickersForMarketInMultivariateEventCollectionRequest,
Expand All @@ -105,6 +124,8 @@
OrderQueuePosition,
OrderStatusLiteral,
Page,
PaymentStatusLiteral,
PaymentTypeLiteral,
PercentilePoint,
PlayByPlay,
PlayByPlayPeriod,
Expand Down Expand Up @@ -133,17 +154,22 @@
UpdateOrderGroupLimitRequest,
UpdateSubaccountNettingRequest,
UserDataTimestamp,
UserFilterLiteral,
WeeklySchedule,
Withdrawal,
)
from kalshi.types import NullableList

__all__ = [
"RFQ",
"AcceptQuoteRequest",
"AccountApiLimits",
"AccountEndpointCosts",
"ActionLiteral",
"AmendOrderRequest",
"AmendOrderResponse",
"AmendOrderV2Request",
"AmendOrderV2Response",
"Announcement",
"ApiKey",
"ApplySubaccountTransferRequest",
Expand All @@ -153,8 +179,17 @@
"Balance",
"BatchCancelOrdersRequest",
"BatchCancelOrdersRequestOrder",
"BatchCancelOrdersV2Request",
"BatchCancelOrdersV2RequestOrder",
"BatchCancelOrdersV2Response",
"BatchCancelOrdersV2ResponseEntry",
"BatchCreateOrdersRequest",
"BatchCreateOrdersV2Request",
"BatchCreateOrdersV2Response",
"BatchCreateOrdersV2ResponseEntry",
"BidAskDistribution",
"BookSideLiteral",
"CancelOrderV2Response",
"Candlestick",
"CreateApiKeyRequest",
"CreateApiKeyResponse",
Expand All @@ -163,13 +198,19 @@
"CreateOrderGroupRequest",
"CreateOrderGroupResponse",
"CreateOrderRequest",
"CreateOrderV2Request",
"CreateOrderV2Response",
"CreateQuoteRequest",
"CreateQuoteResponse",
"CreateRFQRequest",
"CreateRFQResponse",
"CreateSubaccountResponse",
"DailySchedule",
"DecreaseOrderRequest",
"DecreaseOrderV2Request",
"DecreaseOrderV2Response",
"Deposit",
"EndpointTokenCost",
"Event",
"EventCandlesticks",
"EventMetadata",
Expand Down Expand Up @@ -203,6 +244,7 @@
"IncentiveProgram",
"IncentiveProgramStatusLiteral",
"IncentiveProgramTypeLiteral",
"IndexedBalance",
"KalshiAuth",
"KalshiAuthError",
"KalshiBackpressureError",
Expand Down Expand Up @@ -241,6 +283,8 @@
"Orderbook",
"OrderbookLevel",
"Page",
"PaymentStatusLiteral",
"PaymentTypeLiteral",
"PercentilePoint",
"PlayByPlay",
"PlayByPlayPeriod",
Expand Down Expand Up @@ -269,7 +313,9 @@
"UpdateOrderGroupLimitRequest",
"UpdateSubaccountNettingRequest",
"UserDataTimestamp",
"UserFilterLiteral",
"WeeklySchedule",
"Withdrawal",
]

__version__ = "2.0.0"
__version__ = "2.1.0"
51 changes: 50 additions & 1 deletion kalshi/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
"""Kalshi SDK data models."""

from kalshi.models.account import AccountApiLimits, RateLimit
from kalshi.models.account import (
AccountApiLimits,
AccountEndpointCosts,
EndpointTokenCost,
RateLimit,
)
from kalshi.models.api_keys import (
ApiKey,
CreateApiKeyRequest,
Expand All @@ -24,6 +29,7 @@
GetRFQsResponse,
MveSelectedLeg,
Quote,
UserFilterLiteral,
)
from kalshi.models.events import (
Event,
Expand Down Expand Up @@ -94,11 +100,26 @@
ActionLiteral,
AmendOrderRequest,
AmendOrderResponse,
AmendOrderV2Request,
AmendOrderV2Response,
BatchCancelOrdersRequest,
BatchCancelOrdersRequestOrder,
BatchCancelOrdersV2Request,
BatchCancelOrdersV2RequestOrder,
BatchCancelOrdersV2Response,
BatchCancelOrdersV2ResponseEntry,
BatchCreateOrdersRequest,
BatchCreateOrdersV2Request,
BatchCreateOrdersV2Response,
BatchCreateOrdersV2ResponseEntry,
BookSideLiteral,
CancelOrderV2Response,
CreateOrderRequest,
CreateOrderV2Request,
CreateOrderV2Response,
DecreaseOrderRequest,
DecreaseOrderV2Request,
DecreaseOrderV2Response,
Fill,
Order,
OrderQueuePosition,
Expand All @@ -109,12 +130,17 @@
)
from kalshi.models.portfolio import (
Balance,
Deposit,
EventPosition,
IndexedBalance,
MarketPosition,
PaymentStatusLiteral,
PaymentTypeLiteral,
PositionsResponse,
Settlement,
SettlementStatusLiteral,
TotalRestingOrderValue,
Withdrawal,
)
from kalshi.models.search import (
GetFiltersBySportsResponse,
Expand Down Expand Up @@ -149,18 +175,30 @@
"RFQ",
"AcceptQuoteRequest",
"AccountApiLimits",
"AccountEndpointCosts",
"ActionLiteral",
"AmendOrderRequest",
"AmendOrderResponse",
"AmendOrderV2Request",
"AmendOrderV2Response",
"Announcement",
"ApiKey",
"ApplySubaccountTransferRequest",
"AssociatedEvent",
"Balance",
"BatchCancelOrdersRequest",
"BatchCancelOrdersRequestOrder",
"BatchCancelOrdersV2Request",
"BatchCancelOrdersV2RequestOrder",
"BatchCancelOrdersV2Response",
"BatchCancelOrdersV2ResponseEntry",
"BatchCreateOrdersRequest",
"BatchCreateOrdersV2Request",
"BatchCreateOrdersV2Response",
"BatchCreateOrdersV2ResponseEntry",
"BidAskDistribution",
"BookSideLiteral",
"CancelOrderV2Response",
"Candlestick",
"CreateApiKeyRequest",
"CreateApiKeyResponse",
Expand All @@ -169,13 +207,19 @@
"CreateOrderGroupRequest",
"CreateOrderGroupResponse",
"CreateOrderRequest",
"CreateOrderV2Request",
"CreateOrderV2Response",
"CreateQuoteRequest",
"CreateQuoteResponse",
"CreateRFQRequest",
"CreateRFQResponse",
"CreateSubaccountResponse",
"DailySchedule",
"DecreaseOrderRequest",
"DecreaseOrderV2Request",
"DecreaseOrderV2Response",
"Deposit",
"EndpointTokenCost",
"Event",
"EventCandlesticks",
"EventMetadata",
Expand Down Expand Up @@ -209,6 +253,7 @@
"IncentiveProgram",
"IncentiveProgramStatusLiteral",
"IncentiveProgramTypeLiteral",
"IndexedBalance",
"LiveData",
"LookupPoint",
"LookupTickersForMarketInMultivariateEventCollectionRequest",
Expand All @@ -232,6 +277,8 @@
"Orderbook",
"OrderbookLevel",
"Page",
"PaymentStatusLiteral",
"PaymentTypeLiteral",
"PercentilePoint",
"PlayByPlay",
"PlayByPlayPeriod",
Expand Down Expand Up @@ -260,5 +307,7 @@
"UpdateOrderGroupLimitRequest",
"UpdateSubaccountNettingRequest",
"UserDataTimestamp",
"UserFilterLiteral",
"WeeklySchedule",
"Withdrawal",
]
Loading
Loading