Skip to content

Dbentley142/bot_admin

Repository files navigation

Kalshi Trading Bot

Trading bot for Kalshi with a web dashboard to control it, manage triggers, and monitor activity. Uses SQLite for persistence (no separate database server).

Setup

  1. Create a virtualenv and install dependencies

    python3 -m venv .venv
    source .venv/bin/activate
    pip install -r requirements.txt
  2. Configure Kalshi API

    • Copy .env.example to .env
    • Get your API Key ID and private key from Kalshi account profile
    • Set KALSHI_API_KEY_ID and KALSHI_PRIVATE_KEY_PATH (or KALSHI_PRIVATE_KEY)
    • Use https://demo-api.kalshi.co/trade-api/v2 for testing, or https://api.elections.kalshi.com/trade-api/v2 for production
  3. Run the dashboard

    python app.py

    Open http://127.0.0.1:5050 in your browser.

Project layout

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

API endpoints

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

Trigger types

  • price_above / price_below: fires when a market's price crosses a threshold (in cents). Config: market_ticker and/or series_ticker, threshold_cents, side (yes/no), optional contracts (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.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors