An AI-powered autonomous trading bot for Kalshi prediction markets. The bot scans live sports markets every 2 hours, uses Claude AI to analyze probabilities, and executes $10 trades when confidence is high.
┌─────────────────────────────────────────────┐
│ Railway.com (Node.js) │
│ │
│ Cron (2hr) → Fetch Markets → Filter Rules │
│ ↓ │
│ Claude AI Analysis │
│ ↓ │
│ Execute Trade on Kalshi │
│ ↓ │
│ SQLite (trade history) │
│ ↓ │
│ Express API → HTML Dashboard │
└─────────────────────────────────────────────┘
| Rule | Value |
|---|---|
| Category | Sports ONLY |
| Market type | Live events only (resolves within 5 hours) |
| Bet size | $10 per trade |
| Min probability | 70% implied |
| Min payout | 1.5x return |
| Daily loss limit | $50 (bot stops trading if hit) |
| AI confidence threshold | 70% minimum |
| NEVER deposits/withdrawals | Hardcoded restriction |
git clone <your-repo-url>
cd kalshi-bot
npm installcp .env.example .envEdit .env with your credentials:
KALSHI_API_KEY=your_key # From kalshi.com/account/api
KALSHI_API_SECRET=your_secret # Base64-encoded secret
KALSHI_ENV=demo # Use 'demo' first, 'prod' for real money
ANTHROPIC_API_KEY=sk-ant-... # From console.anthropic.com
node server/index.jsOpen http://localhost:3000 to see the dashboard.
Click "Run now" on the dashboard, or:
curl -X POST http://localhost:3000/api/triggergit init
git add .
git commit -m "Initial commit"
git remote add origin <your-github-repo>
git push -u origin main- Go to railway.app
- Click "New Project" → "Deploy from GitHub repo"
- Select your repository
- Railway auto-detects Node.js and deploys
In Railway dashboard → your service → Variables tab, add:
KALSHI_API_KEY=your_key
KALSHI_API_SECRET=your_secret
KALSHI_ENV=demo
ANTHROPIC_API_KEY=sk-ant-...
PORT=3000
MAX_BET_AMOUNT=10
MAX_DAILY_LOSS=50
MIN_PROBABILITY=0.70
MIN_PAYOUT_MULTIPLIER=1.5
MAX_RESOLVE_HOURS=5
CRON_SCHEDULE=0 */2 * * *
In Railway → your service → Volumes tab:
- Add a volume mounted at
/app/data - Set env var:
DB_PATH=/app/data/trades.db
This keeps your trade history across deploys.
| Endpoint | Method | Description |
|---|---|---|
/api/status |
GET | Bot status, portfolio summary |
/api/trades |
GET | All trade history |
/api/trades/open |
GET | Currently open trades |
/api/pnl |
GET | Daily P&L breakdown |
/api/runs |
GET | Bot run history |
/api/balance |
GET | Kalshi account balance |
/api/trigger |
POST | Manually trigger trading cycle |
/api/check-trades |
POST | Check & resolve open trades |
/api/health |
GET | Health check |
- Fetch: Pulls all active sports markets from Kalshi API
- Filter: Keeps only markets where:
- Resolves within 5 hours (live events)
- Either YES or NO side has ≥70% implied probability
- Payout is ≥1.5x the bet
- AI Analysis: Sends top 5 (by volume) to Claude, which evaluates:
- Is the implied probability reasonable?
- Any red flags or information asymmetry?
- Confidence score 0-100
- Execute: Places $10 trades for markets where AI confidence ≥70%
- Monitor: Checks open trades every 30 minutes for resolution
- Start with
KALSHI_ENV=demoto paper trade first - Real money risk: When set to
prod, this bot places real trades - No guarantee of profit: Prediction markets are speculative
- API costs: Each cycle uses
5 Claude API calls ($0.05) - Do NOT increase bet sizes until you've tested extensively
- Monitor the dashboard — don't just set and forget
kalshi-bot/
├── server/
│ ├── index.js # Express server + cron + routes
│ ├── kalshi.js # Kalshi API wrapper
│ ├── brain.js # Claude AI decision engine
│ ├── trader.js # Main trading loop orchestrator
│ └── database.js # SQLite setup + queries
├── client/
│ └── dist/
│ └── index.html # Dashboard (static, no build step)
├── .env.example # Environment template
├── .gitignore
├── package.json
├── railway.toml # Railway config
├── Procfile
└── README.md
For educational and personal use only. Trade at your own risk.