[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-76277":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":15,"subscribersCount":15,"size":15,"stars1d":15,"stars7d":15,"stars30d":16,"stars90d":15,"forks30d":15,"starsTrendScore":15,"compositeScore":17,"rankGlobal":10,"rankLanguage":10,"license":10,"archived":18,"fork":18,"defaultBranch":19,"hasWiki":20,"hasPages":18,"topics":21,"createdAt":10,"pushedAt":10,"updatedAt":28,"readmeContent":29,"aiSummary":30,"trendingCount":15,"starSnapshotCount":15,"syncStatus":31,"lastSyncTime":32,"discoverSource":33},76277,"kalshi-trading-bot","Siva-Chidambaram12\u002Fkalshi-trading-bot","Siva-Chidambaram12","🏗 AI trading system for Kalshi prediction markets. kalshi trading bot kalshi trading bot kalshi botFeatures Grok-4 integration, multi-agent decision making, portfolio optimization, and real-time market analysis. Educational\u002Fresearch purposes only kalshi trading bot kalshi bot","",null,"TypeScript",144,1279,103,0,52,51.52,false,"main",true,[22,23,24,25,26,27],"bot","kalshi","kalshi-bot","kalshi-trading","prediction-market","trading","2026-06-11 04:06:42","\u003Cdiv align=\"center\">\n\n# Kalshi AI Trading Bot\n\n### Beast-Mode, multi-model AI that trades Kalshi prediction markets while you sleep.\n\n*Five elite LLMs. One ruthless trading engine. Zero emotional decisions.*\n\n[![TypeScript](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FTypeScript-5.6-3178C6?logo=typescript&logoColor=white)](https:\u002F\u002Fwww.typescriptlang.org\u002F)\n[![Node.js](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FNode.js-22.5%2B-339933?logo=node.js&logoColor=white)](https:\u002F\u002Fnodejs.org\u002F)\n[![Kalshi](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FKalshi-API-00C48C)](https:\u002F\u002Fkalshi.com\u002F)\n[![OpenRouter](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FOpenRouter-Multi--LLM-FF6B6B)](https:\u002F\u002Fopenrouter.ai\u002F)\n[![License](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FLicense-MIT-blue.svg)](#license)\n[![Paper Trading](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FPaper%20Trading-Built--in-brightgreen)](#safety-first)\n[![Tests](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002Ftests-vitest-6E9F18?logo=vitest&logoColor=white)](#tests)\n\n```\n   ╔══════════════════════════════════════════════════════════╗\n   ║   Claude 4.5  ·  GPT-5.4  ·  Gemini 3.1  ·  Grok  ·  DS  ║\n   ║           → Ensemble Consensus → Kelly Sizing →          ║\n   ║             Risk-Managed Execution → Profit              ║\n   ╚══════════════════════════════════════════════════════════╝\n```\n\n\u003C\u002Fdiv>\n\n---\n\n## Why This Bot Is Different\n\nMost \"AI trading bots\" are a single LLM prompted to gamble. **This one is a trading firm in a terminal.**\n\nIt runs **five specialized AI agents** in parallel — a forecaster, a news analyst, a bull researcher, a bear researcher, and a risk manager — then lets them **debate**, aggregates their probabilities with **confidence-weighted consensus**, and only pulls the trigger when disagreement is low and the edge is real. Every decision is logged, every model's calibration is tracked, and every dollar is sized with the **Kelly Criterion** inside hard position and daily-loss limits.\n\n> If that sounds like overkill for a prediction market bot — that's the point.\n\n---\n\n## Feature Highlights\n\n| Category | What You Get |\n|---|---|\n| **Multi-Model Ensemble** | Claude Sonnet 4.5 · GPT-5.4 · Gemini 3.1 Pro · DeepSeek V3.2 · Grok 4.1 — all orchestrated via OpenRouter with per-model health tracking and automatic failover |\n| **Agent Debate** | Bull vs. Bear researchers argue the thesis; a Risk Manager has veto power. Disagreement above threshold automatically *penalizes confidence*. |\n| **Kelly Sizing** | Fractional Kelly (default 25%) position sizing with hard caps on single-position, daily loss, and total open positions |\n| **Safe Compounder** | NO-side edge compounding strategy for asymmetric, high-probability trades — runs in dry-run by default |\n| **Market Making** | Optional spread-capture mode with inventory risk limits and automatic order refresh |\n| **Quick-Flip Scalping** | Short-horizon opportunistic strategy for high-liquidity markets |\n| **Category Scoring** | Continuously learns which market categories (sports, economics, politics, etc.) your bot is actually good at — and leans in |\n| **News & Sentiment** | RSS aggregation from Reuters, NYT, BBC + LLM-scored sentiment & relevance feeding every decision |\n| **Real-Time Data** | WebSocket streaming from Kalshi keeps market prices fresh without hammering the REST API |\n| **Hard Cost Guardrails** | Daily AI spend cap (default **$10\u002Fday**) enforced at the router level — the bot literally *refuses* to call an LLM when the budget is out |\n| **Paper Trading First** | Full simulation mode with its own tracker and dashboard so you can battle-test strategies risk-free |\n| **Rich CLI** | `run`, `dashboard`, `status`, `scores`, `history`, `safe-compounder`, `health` — everything you need, nothing you don't |\n| **Type-Safe Core** | Strict TypeScript + Zod validation + Vitest tests on the parts that actually matter (ensemble, portfolio optimization, JSON repair, DB, category scoring) |\n\n---\n\n## The Agent Architecture\n\n```\n                     ┌────────────────────────────────┐\n                     │     KALSHI MARKET + NEWS       │\n                     │  (REST + WebSocket + RSS)      │\n                     └──────────────┬─────────────────┘\n                                    │\n                   ┌────────────────┼────────────────┐\n                   ▼                ▼                ▼\n            ┌────────────┐  ┌────────────┐  ┌────────────┐\n            │ Forecaster │  │News Analyst│  │Risk Manager│\n            │  (0.30 w)  │  │  (0.20 w)  │  │  (0.15 w)  │\n            └─────┬──────┘  └─────┬──────┘  └─────┬──────┘\n                  │   ┌───────────┼───────────┐   │\n                  │   ▼           │           ▼   │\n                  │ ┌──────────┐  │  ┌──────────┐ │\n                  │ │   Bull   │◄─┼─►│   Bear   │ │\n                  │ │Researcher│  │  │Researcher│ │\n                  │ │ (0.20 w) │  │  │ (0.15 w) │ │\n                  │ └────┬─────┘  │  └────┬─────┘ │\n                  │      └─── DEBATE ─────┘       │\n                  └───────────────┬───────────────┘\n                                  ▼\n                    ┌──────────────────────────┐\n                    │   ENSEMBLE CONSENSUS     │\n                    │  weighted · calibrated   │\n                    │   disagreement-penalized │\n                    └────────────┬─────────────┘\n                                 ▼\n              ┌──────────────────────────────────────┐\n              │  Kelly Sizing  →  Position Limits    │\n              │  Stop-Loss     →  Daily Loss Cap     │\n              └────────────────────┬─────────────────┘\n                                   ▼\n                          ┌────────────────┐\n                          │  Paper or Live │\n                          │   Execution    │\n                          └────────────────┘\n```\n\nEvery iteration: **ingest → analyze → decide → execute → track → evaluate.** Every model call is metered. Every trade is logged to SQLite. Every position has a dynamic exit.\n\n---\n\n## Quick Start\n\n### 1. Requirements\n\n- **Node.js 22.5+** (uses native `--experimental-sqlite`)\n- A **Kalshi API key** + RSA private key\n- An **OpenRouter API key** (one key, five models)\n\n### 2. Install\n\n```bash\ngit clone https:\u002F\u002Fgithub.com\u002FSiva-Chidambaram12\u002Fkalshi-trading-bot.git\ncd kalshi-trading-bot\nnpm install\n```\n\n### 3. Configure\n\nCopy `env.template` → `.env` and fill in:\n\n```ini\nKALSHI_API_KEY=your_kalshi_api_key_here\nKALSHI_PRIVATE_KEY_PATH=.\u002Fkalshi_private_key.pem\nOPENROUTER_API_KEY=your_openrouter_api_key_here\n\nLIVE_TRADING_ENABLED=false     # START HERE. Paper first, always.\nDAILY_AI_COST_LIMIT=10         # hard cap in USD\nLOG_LEVEL=info\n```\n\n### 4. Verify\n\n```bash\nnpm run dev -- health\n```\n\nYou'll see your Kalshi balance, API key status, and daily budget. If anything is red, fix it before moving on.\n\n### 5. Launch Beast Mode (paper)\n\n```bash\nnpm run dev -- run --iterations 10\n```\n\nWatch the five agents do their thing. When you're ready for real money:\n\n```bash\nnpm run dev -- run --live --daily-limit 5\n```\n\n> **Heads up:** `--live` places real orders with real money. Review the safety section below first.\n\n---\n\n## CLI Reference\n\n```\nkalshi-bot \u003Ccommand> [options]\n\n  run                     Run the Beast Mode trading loop\n    --live                Enable live trading (default: paper)\n    --daily-limit \u003Cn>     Daily AI cost limit USD (default: 10)\n    --iterations \u003Cn>      Max iterations (default: infinite)\n\n  dashboard               Print paper trading dashboard\n  status                  Print current portfolio + open positions\n  scores                  Print learned category performance scores\n  history [--limit n]     Print recent closed trades with PnL\n  safe-compounder         Run NO-side edge compounder (dry-run by default)\n    --live                Place real orders\n  health                  Print health diagnostics\n  help                    Show the full menu\n```\n\n---\n\n## Safety First\n\nThis bot can lose you money. It's designed to minimize that — but no model is perfect. The project ships with **layers of defense**:\n\n- **Paper trading by default.** `LIVE_TRADING_ENABLED=false` is the default. `--live` is opt-in, per invocation.\n- **Hard daily AI spend cap.** The `ModelRouter` physically cannot exceed `DAILY_AI_COST_LIMIT`. When it's out, the bot skips trading rather than flying blind.\n- **Position & loss limits.** Max 3% of balance per position, max 10% daily loss, max 10 open positions — all configurable in `src\u002Fconfig\u002Fsettings.ts`.\n- **Ensemble consensus requirement.** At least 3 models must agree before a trade is considered, and high disagreement penalizes confidence automatically.\n- **Minimum confidence threshold** (default `0.45`) prevents coin-flip trades from ever hitting the wire.\n- **Minimum volume & max-expiry filters** keep the bot out of illiquid or stale markets.\n- **Stop-loss & dynamic exits** on every position, with a max-hold-time sanity timer.\n- **Full audit trail.** Every decision, every model output, every trade — all persisted in SQLite (`trading.db`) and JSONL logs.\n\n> **The project is provided as-is for educational and research purposes. Trade at your own risk. Past paper-trading performance is not indicative of anything.**\n\n---\n\n## Tech Stack\n\n- **Runtime:** Node.js 22.5+ with native SQLite\n- **Language:** TypeScript 5.6 (strict)\n- **LLM Gateway:** [OpenRouter](https:\u002F\u002Fopenrouter.ai\u002F) — one key, five frontier models\n- **Exchange:** [Kalshi](https:\u002F\u002Fkalshi.com\u002F) REST + WebSocket\n- **Validation:** [Zod](https:\u002F\u002Fzod.dev\u002F)\n- **Logging:** [Pino](https:\u002F\u002Fgetpino.io\u002F) (+ pretty in dev)\n- **Testing:** [Vitest](https:\u002F\u002Fvitest.dev\u002F)\n- **News:** `rss-parser` against Reuters, NYT, BBC (configurable)\n\n---\n\n## Project Layout\n\n```\nsrc\u002F\n├── agents\u002F          Five specialized AI agents + ensemble runner + debate\n├── clients\u002F         KalshiClient, KalshiWS, OpenRouterClient, ModelRouter\n├── config\u002F          All tunables, with typed Settings and validation\n├── data\u002F            News aggregation + sentiment analysis\n├── events\u002F          In-process event bus\n├── jobs\u002F            ingest · decide · trade · track · evaluate · execute\n├── paper\u002F           Paper-trading tracker + terminal dashboard\n├── strategies\u002F      Safe Compounder · Market Making · Quick-Flip · Portfolio\n│                    · Category Scorer · Portfolio Enforcer · Unified System\n├── utils\u002F           DB · logger · Kelly · limits · stop-loss · JSON repair\n├── beastModeBot.ts  Main orchestration loop\n└── cli.ts           Command-line interface\n\ntests\u002F               Vitest suites for the critical paths\n```\n\n---\n\n## Tests\n\n```bash\nnpm test            # run all suites\nnpm run test:watch  # TDD mode\nnpm run typecheck   # strict TS, no emit\nnpm run lint        # eslint\n```\n\n---\n\n## Roadmap\n\n- [ ] Cross-market arbitrage (structural wiring already in place)\n- [ ] Options-style strategies on composite markets\n- [ ] Fully algorithmic VWAP \u002F TWAP execution\n- [ ] Web dashboard (the terminal one is lovely, but...)\n- [ ] Post-hoc calibration re-weighting of ensemble models\n- [ ] Public benchmark + anonymized paper-trading leaderboard\n\nPRs welcome.\n\n---\n\n## Contributing\n\n1. Fork it.\n2. `npm install && npm test` — make sure the suite is green on your machine.\n3. Open an issue first for anything non-trivial so we can align.\n4. Write tests for new strategies and agents. The ensemble and portfolio code has real test coverage; let's keep it that way.\n\n---\n\n## FAQ\n\n**Is this guaranteed to make money?**\nNo. Nothing is. It's a disciplined, multi-model framework that executes a strategy you configure. Markets change. Models drift. Trade small, review logs, start in paper.\n\n**Why OpenRouter instead of direct provider keys?**\nOne key, five frontier models, built-in failover. The `ModelRouter` tracks per-model health and gracefully demotes flaky models until they recover.\n\n**Can I run just one model?**\nYes. Disable the ensemble in `src\u002Fconfig\u002Fsettings.ts` (`ensemble.enabled = false`) and the bot falls back to `primaryModel` with automatic fallback to `fallbackModel`.\n\n**How much does it cost to run?**\nYou control it. The default cap is **$10\u002Fday** in LLM spend. At that rate the bot will happily analyze dozens to hundreds of markets per day depending on depth.\n\n**Does it support live trading out of the box?**\nYes — but `LIVE_TRADING_ENABLED=false` by default, and you must explicitly pass `--live` every time. This is intentional.\n\n---\n\n## License\n\nMIT — do what you want, just don't blame us for the drawdowns.\n\n---\n\n\u003Cdiv align=\"center\">\n\n**Built for traders who think like engineers, and engineers who trade like traders.**\n\n*Paper-trade first. Size with Kelly. Listen to the ensemble. Ship.*\n\n\u003C\u002Fdiv>\n","该项目是一个针对Kalshi预测市场的AI交易系统。它集成了Grok-4，支持多智能体决策、投资组合优化和实时市场分析等功能。该系统使用五种先进的语言模型（包括Claude 4.5, GPT-5.4等）进行并行处理，并通过信心加权共识机制来聚合这些模型的预测结果，确保只有在高置信度情况下才会执行交易。此外，还采用了凯利准则进行仓位管理以控制风险。适合用于教育研究目的以及希望利用AI技术提升预测市场交易效率的用户。",2,"2026-05-19 02:31:37","CREATED_QUERY"]