A field guide from the maintainer of kalshi-ai-trading-bot — one of the most-starred open-source Kalshi bots on GitHub.
⚠️ Read this first. Nothing here is financial advice, and no bot in this guide is guaranteed to make money. I ran one of these strategies live and drew my account down ~86% before I understood what I'm about to teach you. This guide is about operating the software correctly — getting it connected, keeping it alive, and reading what it's telling you. It will not pick winners for you. Paper-trade first. Only ever risk money you are fully prepared to lose.
Want the rest of the operator's manual? This free playbook covers getting connected, the silence, and staying online. The paid companion — Build & Run an AI Kalshi Bot — covers AI spend, Kalshi API drift, the dashboard, and the paper-first protocol. → https://kalshi-community.vercel.app/guide
Most people who clone the repo hit the same five walls, in the same order:
The free field-by-field Kalshi API map (what the live responses actually contain, and why snapshot prices lie): https://kalshi-community.vercel.app/reference/kalshi-fields
None of these are exotic. They're the same questions in the issue tracker over and over. This guide is the answer key — the things I wish someone had handed me on day one.
The goal of day one is not to make money. It's to see a green health check and a paper trade land in the dashboard. That's it.
You need exactly two things before anything works:
.pem file it downloads to your machine). You need both. The .pem is the part everyone fumbles — see 1.3.git clone https://github.com/ryanfrigo/kalshi-ai-trading-bot.git
cd kalshi-ai-trading-bot
python setup_env.py # creates .venv, installs everything
cp env.template .env # then open .env and paste your keys
Use Python 3.12. Newer point releases (3.13/3.14) can fail to build some pinned dependencies. If
setup_env.pyerrors on a wheel build, that's almost always the cause — install 3.12 and point the venv at it.
This is the single most common support question, so slow down here.
Your Kalshi API_KEY goes in .env. But the private key is a file, not an env var. The bot expects to find that .pem file in the project root — the same folder as cli.py. People paste the contents of the key into .env, or drop the file in the wrong directory, and get a wall of HTTP 401s.
Checklist:
.pem file Kalshi gave you is sitting in the project root (next to cli.py).src/config/settings.py / .env for the key-path setting — don't rename it to something the bot isn't looking for)..env. .env holds the API key ID only.src/ or your home folder. Wrong directory = "file not found" = 401.python cli.py health
Green across the board means your keys, signing, and connectivity all work. Do not move on until this passes. Every downstream problem is harder to debug when you're not sure the foundation is solid.
python cli.py run --safe-compounder # no LLM needed — pure math, dry-run preview
# or
python cli.py run --paper # AI directional, paper mode
Then, in a second terminal:
python cli.py dashboard
If you see the dashboard populate, you've cleared the hardest part. Most people never get here cleanly — you just did.
Almost certainly not broken — it's being conservative, exactly as designed. This is the #2 source of confusion, and it's worth understanding deeply, because the instinct is to "fix" it by removing the very guardrails that are protecting you.
Every candidate market has to pass all of the filters before a single dollar moves. With the defaults, that means:
The Safe Compounder is even pickier: NO-side only, YES last ≤ 20¢, NO ask > 80¢, edge > 3¢, and it skips sports / entertainment / "mention" markets entirely. On a quiet day, nothing clears that bar. Zero trades is a valid, healthy output. A bot that trades constantly is usually a bot with its safeties off.
Run the diagnostics instead of guessing:
python cli.py health # connectivity still good?
python cli.py status # what does it think it's holding?
python cli.py scores # what did it score, and why did each market get rejected?
scores is the one that ends the anxiety: it shows you the markets it looked at and which filter each one failed. If you see it scoring markets and rejecting them on threshold, it's working — the market just didn't offer an edge worth taking.
It's actually broken only if: health fails, the logs show exceptions every cycle, or it stopped logging entirely (see the "silently paused" trap below).
There's a failure mode where a daily-limit or state file gets into a bad state and the bot quietly stops trading without crashing. If you've had activity and then nothing — not even rejections in the logs — check your daily AI-cost limit hasn't tripped and that the bot didn't pause itself. Restarting the cycle usually clears it.
Loosen one knob at a time, in src/config/settings.py, and watch the effect for a day before touching the next:
Never disable the drawdown circuit-breaker or the position cap to "see more action." That's the exact move that turns a slow week into a blown account.
A trading bot on your laptop dies when the laptop sleeps, when Wi-Fi drops, or when you close the lid. To run continuously you want it on a small always-on server. This is the walkthrough everyone asks for.
A basic DigitalOcean / Hetzner / Linode droplet (1 GB RAM is plenty) runs this fine.
# On the droplet:
git clone https://github.com/ryanfrigo/kalshi-ai-trading-bot.git
cd kalshi-ai-trading-bot
python setup_env.py
cp env.template .env # paste your keys
# copy your Kalshi .pem into the project root (scp it up — never paste it into a chat or commit it)
python cli.py health # confirm it works on the server before going further
The mistake is running python cli.py run ... over SSH and then closing the terminal — which kills the process. Two ways to detach it properly:
Option A — tmux (simplest):
tmux new -s bot
python cli.py run --safe-compounder --live --loop --interval 300
# detach with Ctrl-b then d — the bot keeps running
# reattach later with: tmux attach -t bot
Option B — systemd (survives reboots, restarts on crash): create a service unit that runs the same command with Restart=always and WorkingDirectory set to the project root. This is the "set it and forget it" option — the bot comes back automatically after a server reboot or a crash.
The
--loop --interval 300flags make it run a cycle every 5 minutes forever, instead of running once and exiting. Without--loop, your "24/7 bot" runs for one cycle and stops.
# stop the bot (Ctrl-c in the tmux session, or: systemctl stop your-bot)
python cli.py close-all --live # limit-sell every open position at best bid
python cli.py status # confirm
close-all queries Kalshi directly, so it works even if your local database is stale. Sells are limit-priced and may rest unfilled on thin books — check status after a minute.
Test it once on a book that isn't empty. We found ours reporting "No open positions" while the account held thirteen: it filtered positions on a field the API had already renamed, so the filter matched nothing and the command exited looking successful. Three more renamed-field bugs were hiding behind that first one. A kill switch that has only ever run on a flat account is untested — which is how you find out, at the worst moment, that you don't have one. Chapter 3.5 of the full guide walks through this class of silent failure and how to audit for it.
This free playbook covers getting connected, understanding the silence, and staying online — the three walls everyone hits. The complete Build & Run an AI Kalshi Bot guide also covers:
*_dollars price fields, volume_fp, ticker collisions) and how to pin a release and recover in minutes.Get the full guide → https://kalshi-community.vercel.app/guide
Built something with the toolkit, or stuck on a wall this guide didn't cover? Open a thread in Discussions. If this saved you an afternoon, a ⭐ on the repo helps other operators find it.
The free playbook gets you connected and keeps you online. The full guide covers AI spend, API drift, the dashboard, the paper-first protocol, edge mirages, and pricing markets that resolve on a published number.
See the full guide →Not financial advice. Nothing here is guaranteed to make money. Only ever risk money you are fully prepared to lose.