Run Your Kalshi Bot 24/7 With Hermes AI Agent — Cronjob Setup
Tools

Run Your Kalshi Bot 24/7 With Hermes AI Agent — Cronjob Setup

· EdgeOutcome Team· kalshi, trading-bot, hermes-agent
Last updated

You wrote a Kalshi trading bot. It works. It prints profitable signals to your terminal. But it only runs when you remember to start it — and that’s not a strategy.

The real edge in prediction market trading isn’t just the algorithm. It’s presence. Markets move every 5 minutes on Kalshi’s BTC/ETH contracts. If your bot isn’t watching when the crowd flips, you miss the trade.

This guide shows you how to deploy your Kalshi bot on a Linux server using Hermes AI Agent and cronjobs — so it runs every 10 minutes, 24/7, without you touching a keyboard.

Key Takeaway: Hermes AI Agent + cron is the cheapest way to run a Kalshi bot 24/7. One Hetzner VPS (~€5/month), zero babysitting, and your Python script runs on a schedule like clockwork.


Why Most Kalshi Bots Die Within a Week

Before we get to the setup, let’s talk about why 90% of self-hosted trading bots stop running:

  1. They run in laptop terminals — Your MacBook goes to sleep, the bot dies.
  2. No error recovery — One API timeout, and the script crashes silently.
  3. No scheduling — You forget to restart it after a reboot.
  4. No monitoring — You only find out it’s dead when you check P&L and nothing changed for 3 days.

The Hermes + cron setup solves all four. Let’s build it.


Prerequisites

You’ll need:

  • A Linux server with Python 3.9+ (Hetzner CX22 at ~€4.50/month is plenty, or any VPS)
  • Hermes AI Agent installed on that server (hermes-agent.nousresearch.com)
  • Your Kalshi bot script (Python, working locally)
  • Kalshi API key (RSA keypair, not just the demo key — you need the real one for live trading)
  • Basic terminal comfort (copy-paste level is enough)

Expert Insight: The CX22 (2 vCPU, 4 GB RAM) runs Hermes, n8n, and a Python Kalshi bot simultaneously at ~20% CPU. Don’t overpay for compute you won’t use.


Step 1: Get Your Bot Script Server-Ready

Your local script probably looks something like this:

# bot.py — simplified example
from kalshi import KalshiClient
import os

client = KalshiClient(
    key_id=os.environ["KALSHI_KEY_ID"],
    private_key=os.environ["KALSHI_PRIVATE_KEY"]
)

def check_signal():
    # Your logic here — fetch markets, compute conviction, decide
    events = client.get_events(series_ticker="KXBTCPERP")
    # ... analysis ...
    if conviction > 0.6:
        client.create_order(...)
        print(f"TRADE EXECUTED: {ticker} @ {price}")
    else:
        print("No signal this cycle.")

if __name__ == "__main__":
    check_signal()

What to change for 24/7 reliability:

1. Add a timeout wrapper. Kalshi’s API occasionally hangs. Wrap your main function:

import signal

def handler(signum, frame):
    raise TimeoutError("API call timed out")

signal.signal(signal.SIGALRM, handler)
signal.alarm(45)  # 45-second timeout
try:
    check_signal()
except TimeoutError:
    print("Cycle timed out — skipping")
finally:
    signal.alarm(0)  # reset

2. Log everything to a file. Cron emails are useless. Log to disk:

import logging
logging.basicConfig(
    filename="/var/log/kalshi-bot/bot.log",
    level=logging.INFO,
    format="%(asctime)s [%(levelname)s] %(message)s"
)

3. Environment variables, not hardcoded keys. Use a .env file or systemd environment:

# /etc/kalshi-bot/.env
KALSHI_KEY_ID=your_key_id
KALSHI_PRIVATE_KEY=your_private_key_base64

Step 2: Install Hermes AI Agent on Your Server

Skip this if Hermes is already running. Otherwise, SSH into your server and run:

curl -fsSL https://hermes-agent.nousresearch.com/install.sh | bash

Verify it works:

hermes --version
# Hermes Agent v2.x.x

Hermes gives you the cronjob system we’ll use. It also lets you trigger bot runs via Telegram if you want manual overrides — but that’s optional.


Step 3: Create the Cronjob in Hermes

This is where the magic happens. Hermes cronjobs are managed through config — no crontab -e guesswork.

Create a Hermes cron definition for your bot:

hermes cron create \
  --name "kalshi-bot-cycle" \
  --schedule "*/10 * * * *" \
  --command "cd /opt/kalshi-bot && python3 bot.py" \
  --log-file "/var/log/kalshi-bot/cron.log"

What this does:

  • --schedule "*/10 * * * *" — runs every 10 minutes (standard cron syntax)
  • --command — the exact command your server would run in a terminal
  • --log-file — captures stdout/stderr so you can debug later

Check it’s registered:

hermes cron list
# kalshi-bot-cycle  */10 * * * *  ACTIVE

That’s it. Your bot is now running every 10 minutes, indefinitely.

Why 10-minute intervals? Kalshi’s 15-minute BTC/ETH contracts update conviction data in real time, but meaningful crowd shifts happen across multiple 5-minute windows. Running every 10 minutes balances API rate limits with enough frequency to catch reversals. Test at 5 minutes if you’re trading higher volume.


Step 4: Add Monitoring (Don’t Skip This)

A bot that runs silently is a bot you’ll forget about. Set up three monitoring layers:

4a. Health-check endpoint (via Hermes webhook)

Add this to your bot script:

import requests

def ping_healthcheck():
    """Call at end of each cycle — pass/fail"""
    try:
        requests.post(
            "https://your-hermes-server/webhook/health",
            json={"bot": "kalshi", "status": "ok", "ts": datetime.now().isoformat()},
            timeout=5
        )
    except:
        pass  # never crash on healthcheck failure

4b. Telegram alerts for trades

Use Hermes’ built-in Telegram integration to ping you when a trade executes:

# Inside your trade execution block:
import subprocess
subprocess.run([
    "hermes", "notify",
    "--channel", "telegram",
    "--message", f"🔔 Kalshi Bot: {action} {ticker} {side} @ ${price}"
])

4c. Daily P&L summary (cronjob)

Create a second Hermes cron that runs once a day:

hermes cron create \
  --name "kalshi-daily-pnl" \
  --schedule "0 9 * * *" \
  --command "cd /opt/kalshi-bot && python3 daily_report.py" \

The report script parses your trade log and sends you a summary:

“Yesterday: 4 trades | +$37.50 | Win rate: 75% | KXBTCPERP signals: 12”


Step 5: Handle Kalshi API Rate Limits

Kalshi’s v2 API has a 100 requests per 10-minute window rate limit for most endpoints. If your bot hits this, orders get rejected silently.

Strategy that works:

  • Batch all get_events() calls into one request (use limit=100)
  • Cache event data for the 10-minute cycle — don’t re-fetch
  • Implement exponential backoff:
import time

def api_call_with_retry(func, max_retries=3):
    for attempt in range(max_retries):
        try:
            return func()
        except RateLimitError:
            wait = 2 ** attempt  # 1s, 2s, 4s
            time.sleep(wait)
    raise Exception("Rate limit exceeded after retries")

Kalshi’s rate limits are documented but the actual enforcement is sometimes stricter during high-volatility events (FOMC, CPI). Budget 20% headroom.


Step 6: What to Do When Things Break

Every bot breaks eventually. Here’s the recovery playbook:

Problem Symptom Fix
API key expired 401 Unauthorized in logs Kalshi keys rotate every 90 days. Regenerate in dashboard, update .env, hermes cron restart kalshi-bot-cycle
Server rebooted Bot silent for hours Hermes cronjobs survive reboots — check hermes cron status
Order rejected 400 Bad Request: insufficient margin Your account balance is too low. Add funds or reduce position size
Script crash Traceback in /var/log/kalshi-bot/cron.log Read the traceback. 80% of crashes are unhandled API errors — add try/except around the whole cycle
Memory leak Server OOM-kills the process Add import gc; gc.collect() at end of each cycle. If persistent, restart the bot via cron every 6 hours

Cost Breakdown

Running a Kalshi bot 24/7 costs less than you think:

Item Monthly Cost
Hetzner CX22 VPS (2 vCPU, 4 GB RAM) ~€4.50
Hermes AI Agent Free (open source)
Kalshi API access Free (with funded account)
Domain (optional, for webhooks) ~€1.00
Total ~€5.50/month

That’s one winning trade per month to break even on infrastructure. Everything beyond that is profit.


Alternative: n8n Workflow Instead of Cron

If you prefer a visual workflow builder over crontab syntax, Hermes integrates with n8n for the same functionality:

  1. Install n8n alongside Hermes (hermes setup n8n)
  2. Create a workflow with a Schedule Trigger node (every 10 min)
  3. Add an Execute Command node pointing to python3 bot.py
  4. Add a Telegram node for trade alerts

The result is identical — pick whichever interface you prefer. Cron is simpler for single-script bots; n8n wins when you’re chaining multiple steps (fetch API → transform → trade → notify).


Next Steps: From Scheduled Bot to Autonomous Agent

Once your cronjob bot is running smoothly for a week, the natural upgrade path is:

  1. Add multi-market scanning — watch all Kalshi perp markets simultaneously
  2. Dynamic interval adjustment — trade more frequently during high-volatility windows
  3. Paper-trade first — run the bot against Kalshi’s demo environment for 48 hours before live funds

We covered a full 7-day live trading test in our companion piece: 7 Days of Automated Kalshi Trading — Real P&L Data (coming soon — see if the numbers justify the effort).


Final Check: Is Your Bot Production-Ready?

Before you walk away and trust this thing with real money, verify:

  • Bot runs error-free for 10 consecutive cycles (tail -f /var/log/kalshi-bot/cron.log)
  • Telegram notifications arrive within 30 seconds of a trade
  • API rate limits are never exceeded (check Kalshi dashboard → API usage)
  • You have at least 2x margin buffer (if a position uses $50 margin, have $100 available)
  • The daily P&L report matches your Kalshi account balance

If all five check out: congratulations. Your Kalshi bot is now a 24/7 operation.

Looking to go deeper with the Kalshi API? Start with our Kalshi API v2 Guide — it covers the fields and endpoints the official docs gloss over.

All Kalshi tools in one place → — compare calculators, cheat sheets, and bot kits side by side.


EdgeOutcome may earn a commission if you sign up for Kalshi through links on this page. This does not affect our recommendations — we only write about tools we actually use.

EdgeOutcome
EdgeOutcome Team

Data-driven prediction market analysis. EdgeOutcome helps traders find real edges on Kalshi and Polymarket — not hype, just numbers. More about us →