Skip to content

About

Kalshi trading bot for prediction markets — browse event contracts and watch the order book in real time, run market making and momentum/reversion strategies with paper trading, risk limits and position sizing. Educational toolkit — not financial advice. Unofficial community project, not affiliated with Kalshi.

Topics

Resources

Stars

54 stars

Watchers

0 watching

Forks

Latest commit

 

History

3 Commits

Folders and files

Repository files navigation

kalshi-trading-bot

Kalshi trading bot for prediction markets — browse event contracts and watch the order book in real time, run market making and momentum/reversion strategies with paper trading, risk limits and position sizing. Educational toolkit — not financial advice. Unofficial community project, not affiliated with Kalshi.

🎯 Kalshi Market Bot

Kalshi trading bot for prediction markets — event contracts, live order book, strategies and paper trading in your terminal.

Python Textual License: MIT Kalshi Platform

Browse event contracts · watch the book · run mispricing & momentum strategies · track positions.


📖 Overview

Kalshi Market Bot is a Kalshi trading bot for prediction markets — a keyboard-driven terminal dashboard for Kalshi, the CFTC-regulated US exchange for event contracts. It bundles a markets browser, a real-time order book viewer, a pluggable strategy engine and a position/order tracker into one pane, with market making and momentum/reversion strategies and full risk limits, stop conditions, and position sizing controls.

Kalshi contracts settle to $1 (YES) or $0 (NO) on real-world events: Fed rate decisions, BTC price levels, elections, weather. Pricing them is half art, half probability — the bot combines a Kalshi API client with signed requests (RSA) and a WebSocket market data feed to help you find mispriced markets, act on signals, and manage risk. A paper trading mode with virtual balance and strategy backtesting and performance tracking let you iterate safely. Built with Python, Textual, httpx and websockets as an educational toolkit — not financial advice.

⚠️ Paper-trade by default. The bot ships with a --demo mode that simulates fills against a bundled market dataset. Live order placement requires your own Kalshi API keys and is gated behind explicit configuration.


✨ Features

Area What you get
🔍 Markets browser Filter by category, volume, time-to-close, last-price band.
📖 Order book Live YES/NO bids/asks, spread, mid, imbalance.
🧠 Strategy engine Mispricing (vs. fair-value model), momentum, mean-reversion.
📊 Positions Open YES/NO exposure, avg cost, uPnL, settlement countdown.
🧾 Order log Fills, cancels, strategy signals — a local paper trail.
🎛️ Dashboard Top movers, biggest spreads, soonest-to-close, strategy queue.
⌨️ Keyboard-first Vim bindings, / filter, b book, s signal, o order.
🌑 Theming Multiple palettes.

🖥️ Screenshots

 ╔══════════════════════════════════════════════════════════════════════════════════════════╗
 ║ 🎯 Kalshi Market Bot          [1]Dash [2]Markets [3]Book [4]Strategy [5]Positions [6]Log ║
 ╠══════════════════════════════════════════════════════════════════════════════════════════╣
 ║ Account: paper · $50,000   Open exposure: $4,280   Day P&L: +$312.40   Signals: 3        ║
 ║ ────────────────────────────────────────────────────────────────────────────────────── ║
 ║  Ticker                Market                         Last   Yes$   Vol      Close      ║
 ║  KXBTC-26JUL31-T68000  BTC above $68k on Jul 31       0.62   0.62   1.24M    12d 04h    ║
 ║  KXFED-26SEP16-CUT     Fed cuts Sep meeting           0.71   0.71   3.80M    59d        ║
 ║  KXETH-26JUL31-T3500   ETH above $3.5k on Jul 31      0.18   0.18   0.62M    12d 04h    ║
 ║  KXWTH-26AUG31-NYC90   NYC hits 90°F in Aug           0.84   0.84   0.21M    43d        ║
 ║                                                                                         ║
 ║  STRATEGY SIGNALS                                BOOK: KXBTC-26JUL31-T68000              ║
 ║  ▲ KXFED-26SEP16  MOMENTUM-UP   conf 0.78        YES  bid 0.60  ask 0.63  spread 3.0¢   ║
 ║  ▼ KXETH-26JUL31  REVERSION     conf 0.66        NO   bid 0.37  ask 0.40  spread 3.0¢   ║
 ║  ◆ KXBTC-26JUL31  MISPRICE      conf 0.71        imbalance: 58% YES                    ║
 ║                                                                                         ║
 ║  q Quit  / Filter  b Book  s Signal  o Order  t Theme  ? Help                           ║
 ╚══════════════════════════════════════════════════════════════════════════════════════════╝

🚀 Quick start

git clone https://github.com/lalouannabel0072/kalshi-trading-bot.git
cd kalshi-trading-bot
pip install -r requirements.txt

python main.py --demo     # paper-trade a bundled dataset, no keys
python main.py            # live mode (requires API keys in config)

One-click launchers (no system Python required — they unpack a bundled standalone interpreter on first run):

run.bat        :: Windows
chmod +x run.sh && ./run.sh    # Linux / macOS

⚙️ Live mode keys

# ~/.kalshi-bot/config.toml
[auth]
# Use DEMO keys first (Kalshi demo environment), promote to prod deliberately.
api_key_id     = "your-id"
api_key_secret = "your-secret"
environment    = "demo"     # demo | prod

Keys are read only from the config file (mode 0600). Never commit them.


⌨️ Keybindings

Key Action
1–6 Dash · Markets · Book · Strategy · Positions · Log
/ Filter markets
Enter Open order book for the selected market
b Book (same as Enter)
s Run the strategy engine across the watchlist
o Compose a paper order
t Cycle theme
q Quit

🧠 Strategy engine

Built-in strategies (selectable, composable):

  • Mispricing — compares market price to a configurable fair-value model and signals when the gap exceeds a threshold.
  • Momentum — rate-of-change on the mid-price over a window.
  • Mean-reversion — z-score of price vs. its rolling mean.

Each signal carries a confidence 0..1 and a suggested side (YES/NO). The bot records every signal in the local log; in live mode you wire a strategy to an order template.


🗂️ Project layout

kalshi-market-bot/
├── main.py                # Entry point (unpacks bundled runtime on first launch)
├── kalshi_market_bot/     # Host package
│   ├── __main__.py        # `python -m kalshi_market_bot` entry
│   ├── cli.py             # argparse + launch
│   ├── config.py          # Config loader (TOML)
│   ├── core/              # models, strategy engine, mock data
│   └── tui/               # Textual app: screens, widgets, styles
├── syslib/                # Runtime support library
├── requirements.txt
├── run.bat / run.sh       # One-click launchers
└── release/               # Pre-compiled binaries (planned)

🔒 Security & responsible use

  • Paper-trade by default. --demo never touches your account.
  • Keys local only. Read from a mode-0600 config; never logged.
  • Risk controls. Max exposure, per-market cap, daily loss limit.

❓ FAQ

Is Kalshi available in my region?

Kalshi is a US CFTC-regulated exchange and is available to US residents. Check kalshi.com for current availability — this bot does not bypass any access restrictions.

Does it place real orders?

Only in live mode with your own API keys. By default it runs in paper/demo mode and logs signals and simulated fills. Start with --demo.

Is this affiliated with Kalshi?

No. Independent, unofficial community project. Kalshi is a third-party service.


⚠️ Disclaimer

This is an unofficial community project, not affiliated with, endorsed by, or sponsored by Kalshi Inc. Not financial advice. Trading event contracts involves risk of loss; no strategy in this repository is guaranteed to make money.


📄 License

MIT — see LICENSE.

Built for traders who price probabilities.

About

Kalshi trading bot for prediction markets — browse event contracts and watch the order book in real time, run market making and momentum/reversion strategies with paper trading, risk limits and position sizing. Educational toolkit — not financial advice. Unofficial community project, not affiliated with Kalshi.

Topics

Resources

Stars

54 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages