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
| Kwarg | Type | Default | Notes |
|---|---|---|---|
demo | bool | False | Demo API (demo-api.kalshi.co) vs. production. |
api_key_id | str \| None | None | Key id from the Kalshi portal. Falls back to secrets.get("kalshi.api_key_id"). |
private_key_pem | bytes \| None | None | Inline PEM bytes. Falls back to secrets.get("kalshi.api_private_key_pem"). |
http_client | HttpClient \| None | Rate-limited default | Conservative 10 writes/sec default. |
base_url | str \| None | Auto | Override when routing through a proxy. |
budget_usd | float | 0.0 | Optional 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).