Kalshi

CFTC-regulated US event-contract exchange. Connect with one line.

Kalshi is the CFTC-regulated US event-contract exchange. Markets are binary (YES / NO) priced 1–99 cents per contract. Authentication is RSA-PSS on every request — your API key id plus a private-key PEM.

Connect

python
import horizon as hz

ex = hz.connect("kalshi",
    demo=True,                                   # demo API for testing
    api_key_id="01234567-89ab-cdef-0123-456789abcdef",
    private_key_pem=open("kalshi_private.pem", "rb").read(),
)
# Market id is the ticker; YES is default, suffix ":NO" for NO side.
ex.buy("INXD-23DEC29-T4500", qty=10, limit=0.55)
print(ex.positions())
ex.close()

Kwargs

KwargTypeDefaultNotes
demoboolFalseDemo API (demo-api.kalshi.co) vs. production.
api_key_idstr \| NoneNoneKey id from the Kalshi portal. Falls back to secrets.get("kalshi.api_key_id").
private_key_pembytes \| NoneNoneInline PEM bytes. Falls back to secrets.get("kalshi.api_private_key_pem").
http_clientHttpClient \| NoneRate-limited defaultConservative 10 writes/sec default.
base_urlstr \| NoneAutoOverride when routing through a proxy.
budget_usdfloat0.0Optional hard cap.

Install

bash
pip install horizon[prediction]
# or
pip install cryptography

Status

  • Order submit / cancel: shipped.
  • Balance, positions, open-orders polling: shipped.
  • WebSocket feed: horizon.data.live.kalshi_ws.
  • L2 order book reconstruction: follow-up.

Wire format, signature construction, ticker convention: Kalshi (professionals).