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
32 changes: 32 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,38 @@

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

## 22.16.0 — 2026-11-24

Reconciles nightly spec drift (#588). Additive only. No breaking changes.

### Added

- Perps **`SubaccountTypeLiteral`** gains `"swaps"` (a cross-margined swaps
wallet whose subaccount number is its swaps code). Shared by REST models
(`MarginPosition`, `MarginSubaccountBalance`, `MarginRiskPosition`,
`MarginFundingHistoryEntry`) and perps WS payloads (orderbook delta, fill,
user orders). Without this, REST responses carrying `subaccount_type`
`"swaps"` fail validation.

### Docs

- Historical fills (`fills` / `fills_all`, sync and async): `ticker` accepts
a comma-separated list of up to 100 market tickers.
- Weather point create: a new window must start at least 6 hours from now
(15 minutes on demo); title, rules, and `max_window_days` limits go by
the location's IANA zone; 429 includes a per-account daily creation limit.
- Concert cancellation create: the show must start more than 7 days from
now; an existing market is returned only while that is still true (else
409). Cover is what the listing first shows from creation to scheduled
start; a move within six hours of the scheduled start is not a
postponement. 429 includes a per-account daily limit.
- Flight disruption 429 is a per-account or global daily creation limit.
- Klear `ObligationEntry.maintenance_margin_centicents` is the maintenance
margin change settled this cycle (sum of detail deltas, positive =
released), not the requirement. Detail delta is previous minus after.
Obligation history: at most one obligation per asset class per cycle,
none when nothing settles.

## 22.15.0 — 2026-11-19

Adds on-request flight disruption markets (#586) against OpenAPI v3.37.0
Expand Down
12 changes: 7 additions & 5 deletions docs/perps.md
Original file line number Diff line number Diff line change
Expand Up @@ -231,12 +231,13 @@ perps.portfolio.cancel_cross_exit_trigger("BTC-PERP", trig.id)
- **Subaccounts** (since the v3.21.0 spec sync) — `MarginPosition` (the
`portfolio.positions()` rows) carries a **required** `subaccount` (`int`)
identifying which subaccount holds the position. `subaccount_type`
(`"cross"` / `"isolated"` / `"auto_rebalance"` / `"managed_isolated"`, or
`None` when the key is absent) is optional on `MarginPosition`,
(`"cross"` / `"isolated"` / `"auto_rebalance"` / `"managed_isolated"` /
`"swaps"`, or `None` when the key is absent) is optional on `MarginPosition`,
`MarginSubaccountBalance`, `MarginRiskPosition`, and
`MarginFundingHistoryEntry`. `managed_isolated` uses the same subaccount
number as the market's isolated subaccount. The spec marks it required; the
SDK keeps it optional so older payloads still parse.
number as the market's isolated subaccount. `swaps` is a cross-margined
swaps wallet whose subaccount number is its swaps code. The spec marks it
required; the SDK keeps it optional so older payloads still parse.
- **Portfolio hedging** (since the v3.23.0 spec sync) — `MarginPosition` and
`MarginRiskPosition` carry a **required** `is_portfolio` (`bool`), `True` when
the position is hedged within a portfolio so its margin is computed at the
Expand Down Expand Up @@ -371,7 +372,8 @@ Credentials can also come from the environment via `KlearClient.from_env()` (rea

`klear.margin.active_obligations()` returns all currently-active settlement
obligations. `klear.margin.obligation_history()` / `obligation_history_all()`
page historical obligations; optional `settlement_start_ts` /
page historical obligations; each cycle produces at most one obligation per
asset class, and none when nothing settles. Optional `settlement_start_ts` /
`settlement_end_ts` (RFC3339 `datetime` or `str`) bound settlement time.
`klear.margin.settlement_balance_history()` /
`settlement_balance_history_all()` page settlement-buffer history; optional
Expand Down
21 changes: 16 additions & 5 deletions docs/resources/markets.md
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,15 @@ print(resp.market_ticker, resp.created, resp.latitude, resp.longitude)
unset optional fields are omitted from the wire body. The same request
always returns the same market; `created` is false when it already existed.
Coordinates are rounded to three decimal places; requests that agree to
three decimals share a market. Optional `end_date` (the day after `date`)
opens a window that crosses midnight, at most 24 hours, where availability
returns `max_window_days == 2`.
three decimals share a market. A new market's window must start at least
6 hours from now (15 minutes on demo). `timezone` only says which span of
time `date` and the hours mean; the market's title and rules are written in
the location's IANA zone, and `max_window_days` limits go by that zone too.
Optional `end_date` (the day after `date`) opens a window that crosses
midnight in `timezone`, at most 24 hours. Whether a window across midnight
is offered does not go by `end_date`: where `max_window_days` is 1, a
request with `end_date` is accepted when the window lies within one date at
the location.

## Concert cancellation markets

Expand Down Expand Up @@ -211,8 +217,13 @@ Take `jambase_event_id` and `scheduled_date` from `list_concerts` or
`search_concerts`. A cover missing from `avail.covers` cannot be created.
`enabled` means concerts are listed; it does not promise that a create will
succeed — where listing is on before markets are offered, create returns 409.
The same request always returns the same market; `created` is false when it
already existed. Pass the returned `market_ticker` to `POST /communications/rfqs`.
A new market's show must start more than 7 days from now. An existing market
is returned only while the show is more than 7 days away too; inside that,
create returns 409. Further out, `created` is false when a market for the
same request already existed. Cover is what the listing first shows from
creation to the show's scheduled start: a new start time on the scheduled
date, or within six hours of the scheduled start, is not a postponement.
Pass the returned `market_ticker` to `POST /communications/rfqs`.
`list_concerts` is paged by the server (`page` / `total_pages`); there is no
SDK paginator.

Expand Down
2 changes: 1 addition & 1 deletion kalshi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -553,4 +553,4 @@
"Withdrawal",
]

__version__ = "22.15.0"
__version__ = "22.16.0"
7 changes: 6 additions & 1 deletion kalshi/models/markets.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,12 @@ class GetWeatherPointAvailabilityResponse(BaseModel):


ConcertCoverLiteral = Literal["postponed", "cancelled", "either"]
"""What a concert cancellation market pays on. Spec: ConcertCover enum."""
"""What a concert cancellation market pays on. Spec: ConcertCover enum.

Pays on what the listing first shows from creation to the show's scheduled
start. A new start time on the scheduled date, or within six hours of the
scheduled start, is not a postponement.
"""


class CreateConcertCancellationMarketRequest(BaseModel):
Expand Down
20 changes: 14 additions & 6 deletions kalshi/perps/klear/models/margin.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,10 +176,14 @@ class SettlementDetail(BaseModel):


class MaintenanceMarginDetail(BaseModel):
"""Spec ``MaintenanceMarginDetail`` — maintenance-margin requirement + delta.

``subtrader_id`` may be an empty string when not populated.
``margin_group_id`` is set when the subtrader is part of a subtrader group.
"""Spec ``MaintenanceMarginDetail`` — per-subtrader requirement after settlement.

``maintenance_margin_centicents`` is the requirement after this settlement
(0 when the subtrader goes flat). ``maintenance_margin_delta_centicents``
is the previous settlement's requirement minus this one (positive means
margin released to the clearing member). ``subtrader_id`` may be an empty
string when not populated. ``margin_group_id`` is set when the subtrader
is part of a subtrader group.
"""

id: str
Expand Down Expand Up @@ -270,6 +274,8 @@ class ObligationEntry(BaseModel):
amount_centicents: int
amount_fp: DollarDecimal | None = None
fees_centicents: int
# Change settled this cycle (sum of detail deltas), not the requirement.
# Positive = released to the clearing member.
maintenance_margin_centicents: int
pnl_centicents: int
pnl_fp: DollarDecimal | None = None
Expand All @@ -294,8 +300,10 @@ class ObligationEntry(BaseModel):
class GetObligationHistoryResponse(BaseModel):
"""Spec ``GetObligationHistoryResponse`` — cursor-paginated obligation page.

``cursor`` is an RFC3339 date-time string; absent on the last page. The
resource consumes this via the generic ``Page[ObligationEntry]`` envelope.
Each settlement cycle produces at most one obligation per asset class, and
none when nothing settles. ``cursor`` is an RFC3339 date-time string;
absent on the last page. The resource consumes this via the generic
``Page[ObligationEntry]`` envelope.
"""

obligations: NullableList[ObligationEntry]
Expand Down
9 changes: 6 additions & 3 deletions kalshi/perps/models/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,17 @@ class ExchangeInstance(StrEnum):
MARGINED = "margined"


SubaccountTypeLiteral = Literal["cross", "isolated", "auto_rebalance", "managed_isolated"]
SubaccountTypeLiteral = Literal[
"cross", "isolated", "auto_rebalance", "managed_isolated", "swaps"
]
"""Spec ``SubaccountType`` — how a subaccount is margined.

``cross`` for the primary account and numbered subaccounts, ``isolated`` for
a market's isolated subaccount, ``auto_rebalance`` for an auto-rebalanced
isolated position (shares its market's isolated subaccount number), and
isolated position (shares its market's isolated subaccount number),
``managed_isolated`` for a managed isolated position (subaccount number is
the same as the market's isolated subaccount number).
the same as the market's isolated subaccount number), and ``swaps`` for a
cross-margined swaps wallet (subaccount number is its swaps code).
"""


Expand Down
16 changes: 16 additions & 0 deletions kalshi/resources/historical.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,10 @@ def fills(
subaccount: int | None = None,
extra_headers: dict[str, str] | None = None,
) -> Page[Fill]:
"""List historical fills (``GET /historical/fills``).

``ticker`` accepts a comma-separated list of up to 100 market tickers.
"""
self._require_auth()
params = _historical_fills_or_orders_params(
limit=limit,
Expand All @@ -253,6 +257,10 @@ def fills_all(
max_pages: int | None = None,
extra_headers: dict[str, str] | None = None,
) -> Iterator[Fill]:
"""Auto-paginate historical fills.

``ticker`` accepts a comma-separated list of up to 100 market tickers.
"""
self._require_auth()
_validate_max_pages(max_pages)
params = _historical_fills_or_orders_params(
Expand Down Expand Up @@ -540,6 +548,10 @@ async def fills(
subaccount: int | None = None,
extra_headers: dict[str, str] | None = None,
) -> Page[Fill]:
"""List historical fills (``GET /historical/fills``, async).

``ticker`` accepts a comma-separated list of up to 100 market tickers.
"""
self._require_auth()
params = _historical_fills_or_orders_params(
limit=limit,
Expand All @@ -564,6 +576,10 @@ def fills_all(
max_pages: int | None = None,
extra_headers: dict[str, str] | None = None,
) -> AsyncIterator[Fill]:
"""Auto-paginate historical fills (async). Use ``async for``.

``ticker`` accepts a comma-separated list of up to 100 market tickers.
"""
self._require_auth()
_validate_max_pages(max_pages)
params = _historical_fills_or_orders_params(
Expand Down
13 changes: 9 additions & 4 deletions kalshi/resources/markets.py
Original file line number Diff line number Diff line change
Expand Up @@ -667,8 +667,11 @@ def create_weather_point_market(

Returns the on-request weather market for a location, time window and
threshold, creating it if it does not exist. ``created`` is false when
a market for the same request already existed. Optional ``end_date``
(YYYY-MM-DD) is omitted when unset.
a market for the same request already existed. A new window must start
at least 6 hours from now (15 minutes on demo). ``timezone`` only
names the span of time; title, rules, and ``max_window_days`` limits
go by the location's IANA zone. Optional ``end_date`` (YYYY-MM-DD) is
omitted when unset.
"""
self._require_auth()
body = _build_create_weather_point_market_body(
Expand Down Expand Up @@ -723,8 +726,10 @@ def create_concert_cancellation_market(
"""``POST /concert_cancellation_markets``. Not retried.

Returns the on-request concert cancellation market for a show, date and
cover, creating it if it does not exist. ``created`` is false when a
market for the same request already existed.
cover, creating it if it does not exist. The show must start more than
7 days from now (an existing market is returned only while that is
still true; otherwise 409). ``created`` is false when a market for the
same request already existed.
"""
self._require_auth()
body = _build_create_concert_cancellation_market_body(
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "kalshi-sdk"
version = "22.15.0"
version = "22.16.0"
description = "A professional Python SDK for the Kalshi prediction markets and Perps (margin) APIs"
readme = "README.md"
license = { text = "MIT" }
Expand Down
Loading
Loading