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
4 changes: 4 additions & 0 deletions kalshi/_contract_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,10 @@ class ContractEntry:
sdk_model="kalshi.perps.models.markets.MarginMarket",
spec_schema="MarginMarket",
),
ContractEntry(
sdk_model="kalshi.perps.models.markets.MarginMarketSchedule",
spec_schema="MarginMarketSchedule",
),
ContractEntry(
sdk_model="kalshi.perps.models.markets.MarginMarketCandlestick",
spec_schema="MarginMarketCandlestick",
Expand Down
2 changes: 2 additions & 0 deletions kalshi/perps/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
BidAskDistributionHistorical,
MarginMarket,
MarginMarketCandlestick,
MarginMarketSchedule,
MarginMarketStatusLiteral,
MarginOrderbook,
MarginOrderbookLevel,
Expand Down Expand Up @@ -274,6 +275,7 @@
"MarginFundingRateEstimate",
"MarginMarket",
"MarginMarketCandlestick",
"MarginMarketSchedule",
"MarginMarketStatus",
"MarginMarketStatusLiteral",
"MarginOrder",
Expand Down
2 changes: 2 additions & 0 deletions kalshi/perps/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
BidAskDistributionHistorical,
MarginMarket,
MarginMarketCandlestick,
MarginMarketSchedule,
MarginMarketStatusLiteral,
MarginOrderbook,
MarginOrderbookLevel,
Expand Down Expand Up @@ -129,6 +130,7 @@
"MarginFundingRateEstimate",
"MarginMarket",
"MarginMarketCandlestick",
"MarginMarketSchedule",
"MarginMarketStatus",
"MarginMarketStatusLiteral",
"MarginOrder",
Expand Down
24 changes: 24 additions & 0 deletions kalshi/perps/models/markets.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,26 @@ class TickerPrice(BaseModel):
model_config = {"extra": "allow"}


class MarginMarketSchedule(BaseModel):
"""Spec ``MarginMarketSchedule`` — current market trading hours.

Nested under :class:`MarginMarket.schedule`. The whole object is
``nullable: true`` (null for 24/7 markets); when present, ``is_open`` is
always set and the next open/close timestamps are Unix epoch **seconds**
(``int64``), null while the corresponding phase is active
(``next_close_ts`` null while closed; ``next_open_ts`` null while open).
"""

is_open: bool
# Spec marks both timestamps required AND nullable — keys always present,
# values JSON null depending on open/closed phase. Modeled as required-key /
# nullable-value (no default) so required-drift stays aligned.
next_close_ts: int | None
next_open_ts: int | None

model_config = {"extra": "allow"}


class MarginMarket(BaseModel):
"""Spec ``MarginMarket`` — a margin market with trading stats.

Expand All @@ -61,6 +81,10 @@ class MarginMarket(BaseModel):
contract_size: DollarDecimal
tick_size: DollarDecimal
fractional_trading_enabled: bool
# Spec requires the key; value is null for markets that trade 24/7
# (``MarginMarketSchedule`` is ``nullable: true``). No default — missing
# key hard-fails so required-drift stays aligned.
schedule: MarginMarketSchedule | None

leverage_estimate: MultiplierDecimal | None = None
# Leverage (1 / margin_rate) keyed by notional position size in dollars
Expand Down
Loading