Multi-agent AI ensemble for Kalshi prediction markets. Five specialized LLM agents debate every market, reach consensus with Kelly-sized positions, and execute in paper or live mode — with full SQLite audit trail.
Most "AI trading bots" are a single prompt and a prayer. This one runs a structured pipeline:
- Ingest — Kalshi markets, news, and context
- Debate — five agents analyze in parallel, then synthesize
- Consensus — weighted ensemble with disagreement penalty
- Size — Kelly criterion with hard risk limits
- Execute — paper or live via Kalshi REST + WebSocket
- Track & evaluate — SQLite audit, dashboard, agent scorecards
You're not betting on one model's hunch — you're betting on a committee that must agree.
| Agent | Weight | Role |
|---|---|---|
| Forecaster | 30% | Base probability estimate |
| News Analyst | 20% | Event and headline impact |
| Bull Researcher | 20% | Upside case |
| Bear Researcher | 15% | Downside case |
| Risk Manager | 15% | Position sizing veto |
Consensus rules: minimum 3 models, disagreement penalty applied, min confidence 0.45.
If the ensemble is disabled, falls back to primaryModel + fallbackModel via ModelRouter.
- Paper trading — full pipeline without risking capital
- Live trading — gated by
LIVE_TRADING_ENABLED - Daily AI cost cap —
DAILY_AI_COST_LIMITprevents runaway LLM bills - Model health routing — unhealthy models auto-demoted
- Multiple strategies — Safe Compounder, Market Making, Quick-Flip, category scorer
- SQLite audit — every decision logged to
trading.db - CLI dashboard — status, scores, history at a glance
- Node.js 22.5+ (native SQLite support)
- Kalshi API credentials
- OpenRouter API key
git clone https://github.com/openfi-dao/kalshi-trading-bot.git
cd kalshi-trading-bot
npm install
cp env.template .envKALSHI_API_KEY=your_key
KALSHI_PRIVATE_KEY_PATH=./kalshi.pem
OPENROUTER_API_KEY=sk-or-...
# Safety defaults
LIVE_TRADING_ENABLED=false
DAILY_AI_COST_LIMIT=10
LOG_LEVEL=infonpm run bot
# or
npm run devkalshi-bot run [--live] [--daily-limit n] [--iterations n]
kalshi-bot dashboard
kalshi-bot status
kalshi-bot scores
kalshi-bot history [--limit n]
kalshi-bot safe-compounder [--live]
kalshi-bot healthflowchart LR
Ingest[Market Ingest] --> Agents[5-Agent Parallel Analysis]
Agents --> Debate[Debate Round]
Debate --> Consensus[Weighted Consensus]
Consensus --> Kelly[Kelly Sizing]
Kelly --> Limits[Risk Limits]
Limits --> Execute[Paper / Live]
Execute --> Track[SQLite Audit]
Track --> Eval[Agent Evaluation]
Configured in src/config/settings.ts:
| Limit | Default |
|---|---|
| Max per position | ~3% of bankroll |
| Max daily loss | ~10% |
| Max open positions | Configurable |
| Stop-loss | Per-strategy |
| Max hold time | Per-strategy |
src/
├── cli.ts # Command-line interface
├── beastModeBot.ts # Main orchestrator
├── agents/ # Ensemble + debate logic
├── clients/
│ ├── KalshiClient.ts # REST API
│ ├── KalshiWS.ts # WebSocket
│ └── ModelRouter.ts # LLM routing + failover
├── jobs/
│ ├── ingest.ts
│ ├── decide.ts
│ ├── trade.ts
│ ├── track.ts
│ └── evaluate.ts
├── strategies/ # Safe-compounder, MM, quick-flip
├── paper/ # Paper tracker + dashboard
└── utils/database.ts # SQLite layer
trading.db # Audit log (created at runtime)
| Strategy | Description |
|---|---|
| Safe Compounder | NO-side focused compounding |
| Market Making | Two-sided quoting |
| Quick-Flip | Short-hold directional |
| Category Scorer | Sector-weighted selection |
Run with: kalshi-bot safe-compounder [--live]
npm test # Vitest: ensemble, Kelly, DB, JSON repair
npm run typecheck
npm run lint
npm run buildModelRouterdemotes unhealthy LLM providers automaticallyensemble.enabled=false→ single primary + fallback model- All decisions persisted — replay and debug from
trading.db
- Start in paper mode. LLM outputs are probabilistic, not oracle predictions.
- Set a daily AI cost limit before enabling live trading.
- Kalshi markets involve real money and regulatory constraints — know your jurisdiction.
- Authors not liable for trading or API costs.
Issues and PRs welcome — especially agent prompt improvements, backtesting hooks, and safer default limits.