Trading bot for Kalshi with a web dashboard to control it, manage triggers, and monitor activity. Uses SQLite for persistence (no separate database server).
-
Create a virtualenv and install dependencies
python3 -m venv .venv source .venv/bin/activate pip install -r requirements.txt -
Configure Kalshi API
- Copy
.env.exampleto.env - Get your API Key ID and private key from Kalshi account profile
- Set
KALSHI_API_KEY_IDandKALSHI_PRIVATE_KEY_PATH(orKALSHI_PRIVATE_KEY) - Use
https://demo-api.kalshi.co/trade-api/v2for testing, orhttps://api.elections.kalshi.com/trade-api/v2for production
- Copy
-
Run the dashboard
python app.py
Open http://127.0.0.1:5050 in your browser.
| File | Purpose |
|---|---|
app.py |
Flask entrypoint: serves dashboard and API, manages engine thread |
routes.py |
REST API: bot control, trigger CRUD, logs, portfolio, markets |
bot_engine.py |
Background loop: evaluates triggers, places orders via Kalshi |
kalshi_client.py |
Builds KalshiClient from .env credentials |
db.py |
SQLite schema and connection helpers |
static/index.html |
Dashboard UI (vanilla HTML/JS/CSS) |
test_connection.py |
Quick script to verify Kalshi API connectivity |
| Method | Path | Description |
|---|---|---|
GET |
/api/status |
Bot running state |
POST |
/api/bot/start |
Start the bot engine |
POST |
/api/bot/stop |
Stop the bot engine |
GET |
/api/triggers |
List all triggers |
POST |
/api/triggers |
Create a trigger |
PATCH |
/api/triggers/<id> |
Update a trigger |
DELETE |
/api/triggers/<id> |
Delete a trigger |
GET |
/api/logs |
Activity log (optional ?limit= and ?level=) |
GET |
/api/portfolio |
Kalshi balance and positions |
GET |
/api/markets |
Browse Kalshi markets |
- price_above / price_below: fires when a market's price crosses a threshold (in cents). Config:
market_tickerand/orseries_ticker,threshold_cents,side(yes/no), optionalcontracts(default 1). Use series_ticker (e.g.KXETH-1H) to trade the current contract in that series (e.g. hourly ETH).
Triggers auto-disable after firing (one-shot). Re-enable from the dashboard.