betting_combat.providers.kalshi.client
client.py — Kalshi’s trade API v2 (REST), one method per endpoint we use, every answer as
models rows. Reads need no auth; the account and orders are signed (KalshiSigner).
Kalshi.from_settings() the client on ``KALSHI_API_KEY_ID`` / ``KALSHI_PRIVATE_KEY``exchange status · schedule · series · series_list · limitscalendar milestones · milestone · targets · event · events · event_metadatamarkets markets · market · cutoffsmarket data book · books · trades · candles · candles_manylive live_data · live_oneaccount balance · api_keys · order · orders · fills · positions · settlements · queue_positions · subaccount_balances · historical_{orders,fills}trading create_order · create_orders · amend_order · decrease_order · cancel_order · cancel_orders · cancel_all · exit triggers (never retried: a resend is the executor's call)order groups create_group · groups · group · group_limit · trigger_group · reset_group · delete_group (a rolling 15 s contracts limit: the kill switch)rfq rfqs · create_rfq · delete_rfq · quotes · accept_quote (size beyond the book)Left out on purpose: API-key management, deposits and withdrawals, FCM, multivariate combos, weather, and transfers (account changes are Sam’s, never the system’s).
Basic tier: 20 reads a second, 10 writes; paced at 10 a second. Rules from the survey
(docs/BASE_TABLES.md): never date a fight from a ticker (Milestone.start_date); the
archive holds markets settled and trades made before cutoffs(); candles of a market on
the other side of the cutoff answer 404, and the other path is tried.
Classes
Kalshi
Bases: Provider
Kalshi’s REST API.
accept_quote
accept_quote(quote_id: str, side: Literal['yes', 'no']) -> dict[str, Any]Take a maker’s quote (the maker confirms within 30 s, 3 s on fast markets).
amend_order
amend_order(order_id: str, spec: OrderSpec) -> OrderAckChange an order’s price or total count (an expiry-only change keeps its place).
api_keys
api_keys() -> ApiKeysOur keys and the location attestation’s expiry (past it, no sports orders).
balance
balance() -> floatCash in dollars.
book
book(ticker: str, depth: int = 0) -> BookOne market’s book (depth 0 = every level).
books
books(tickers: list[str]) -> dict[str, Book]Many books in one call each 100 (a whole card).
cancel_all
cancel_all() -> dict[str, Any]Cancel every resting order, every shard.
cancel_exit_trigger
cancel_exit_trigger(ticker: str) -> dict[str, Any]cancel_order
cancel_order(order_id: str) -> OrderAckcancel_orders
cancel_orders(order_ids: list[str]) -> dict[str, Any]Cancel many orders in one call (2 tokens each); the answers as served.
candles
candles(ticker: str, series_ticker: str, start: dt.datetime, end: dt.datetime, minutes: Literal[1, 60, 1440] = 1, archived: bool) -> list[Candle]One market’s candles (active periods only), in windows of at most 5,000 periods (the server’s cap). Archived markets live under /historical; a 404 (or a 400 that is not the cap) on the first guess tries the other path. Empty: none.
candles_many
candles_many(tickers: list[str], start: dt.datetime, end: dt.datetime, minutes: Literal[1, 60, 1440] = 1) -> dict[str, list[Candle]]Many live-path markets’ candles in one call each 100 tickers (≤ 10,000 candles a call).
create_group
create_group(contracts_limit: float) -> OrderGroupA group whose orders are cancelled once contracts_limit contracts fill in 15 s.
create_order
create_order(spec: OrderSpec) -> OrderAckSend one order, once.
create_orders
create_orders(specs: list[OrderSpec]) -> list[OrderAck | ProviderError]Send many orders in one call (the batch costs the sum of its items); each answer in
order, an OrderAck or the item’s error.
create_rfq
create_rfq(ticker: str, contracts: float, rest_remainder: bool = False) -> strAsk makers to quote contracts on ticker; the RFQ’s id.
cutoffs
cutoffs() -> tuple[dt.datetime, dt.datetime](markets, trades): settled before the first, or traded before the second, is served only under /historical.
decrease_order
decrease_order(order_id: str, reduce_by: float | None = None, reduce_to: float | None = None) -> OrderAckdelete_group
delete_group(group_id: str) -> dict[str, Any]delete_rfq
delete_rfq(rfq_id: str) -> dict[str, Any]event
event(event_ticker: str) -> EventOne event: its card label is competition.
event_metadata
event_metadata(event_ticker: str) -> dict[str, Any]The event’s competition, settlement sources and market details, as served.
events
events(series_ticker: str, status: str | None = None, with_milestones: bool = False, updated_since: dt.datetime | None = None) -> list[Event]exit_triggers
exit_triggers(ticker: str) -> dict[str, Any]fills
fills(since: dt.datetime | None = None, ticker: str | None = None, order_id: str | None = None) -> list[Fill]from_settings
from_settings(settings: KalshiSettings | None = None, **kwargs: Any) -> Kalshigroup
group(group_id: str) -> OrderGroupgroup_limit
group_limit(group_id: str, contracts_limit: float) -> dict[str, Any]groups
groups() -> list[OrderGroup]historical_fills
historical_fills(ticker: str | None = None) -> list[Fill]historical_orders
historical_orders(ticker: str | None = None) -> list[Order]limits
limits() -> dict[str, Any]Our API tier and its read/write budgets, as served.
live_data
live_data(milestone_ids: list[str]) -> list[LiveData]The live feed’s state of each fight. Ids with no live record are left out silently.
live_one
live_one(milestone_id: str) -> LiveData | NoneOne fight’s live state; None before it has a live record (404).
market
market(ticker: str) -> Marketmarkets
markets(series_ticker: str | None = None, event_ticker: str | None = None, tickers: list[str] | None = None, status: str | None = None, created_since: dt.datetime | None = None, historical: bool = False) -> list[Market]Markets by series, event or tickers; historical reads the archive (settled before
the cutoff).
milestone
milestone(milestone_id: str) -> Milestonemilestones
milestones(min_start: dt.datetime | None = None, updated_since: dt.datetime | None = None, related_event_ticker: str | None = None) -> list[Milestone]The UFC fights (mma_match) starting at min_start or later, or updated since
updated_since (the cheap poll for link and time changes), or the one a series event
belongs to. 837 since 2025-03.
order
order(order_id: str) -> Orderorders
orders(ticker: str | None = None, since: dt.datetime | None = None) -> list[Order]positions
positions() -> list[Position]queue_positions
queue_positions(tickers: list[str]) -> list[QueuePosition]quotes
quotes(rfq_id: str | None = None) -> list[Quote]reset_group
reset_group(group_id: str) -> dict[str, Any]rfqs
rfqs() -> list[Rfq]schedule
schedule() -> dict[str, Any]The exchange’s trading hours and maintenance windows, as served.
series
series(ticker: str) -> Seriesseries_list
series_list(category: str | None = None) -> list[Series]set_exit_trigger
set_exit_trigger(ticker: str, take_profit: float | None = None, stop_loss: float | None = None, slippage_cents: int = 2) -> dict[str, Any]A take-profit / stop-loss on a position (YES prices), with the slippage allowed.
settlements
settlements(since: dt.datetime | None = None) -> list[Settlement]status
status() -> ExchangeStatussubaccount_balances
subaccount_balances() -> dict[int, float]Cash per subaccount (0 = primary), dollars.
targets
targets(ids: list[str]) -> list[Target]Structured targets (fighters) by id, 100 a call (ids repeated: more is a URL too long, 414).
trades
trades(ticker: str, start: dt.datetime | None = None, end: dt.datetime | None = None, historical: bool = False) -> list[Trade] | NoneOne market’s trades with start <= created < end, from the archive or the live
path. None when that path does not know the market (400/404 on the first page: ask the
other); complete back to the first UFC market (2025-05).
trigger_group
trigger_group(group_id: str) -> dict[str, Any]Cancel the group’s orders now (the manual kill switch).
KalshiSettings
Bases: BaseSettings
KALSHI_API_KEY_ID / KALSHI_PRIVATE_KEY (and KALSHI_BASE_URL).
signer
signer() -> KalshiSigner | NoneOrderSpec
One order to send: buy (or sell) outcome at price or better. The V2 book is
quoted in YES: buying YES bids price, buying NO asks YES at 1 - price; selling is the
other side. client_order_id makes a duplicate a 409.
body
body() -> dict[str, Any]