[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-76291":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":9,"language":10,"languages":9,"totalLinesOfCode":9,"stars":11,"forks":12,"watchers":13,"openIssues":14,"contributorsCount":14,"subscribersCount":14,"size":14,"stars1d":14,"stars7d":14,"stars30d":15,"stars90d":14,"forks30d":14,"starsTrendScore":14,"compositeScore":16,"rankGlobal":9,"rankLanguage":9,"license":9,"archived":17,"fork":17,"defaultBranch":18,"hasWiki":19,"hasPages":17,"topics":20,"createdAt":9,"pushedAt":9,"updatedAt":26,"readmeContent":27,"aiSummary":28,"trendingCount":14,"starSnapshotCount":14,"syncStatus":29,"lastSyncTime":30,"discoverSource":31},76291,"kalshi-trading-bot","sachmalan\u002Fkalshi-trading-bot","sachmalan","kalshi trading bot kalshi bot kalshi trading bot kalshi bot kalshi trading bot kalshi bot kalshi trading bot kalshi bot kalshi trading bot kalshi bot kalshi trading bot kalshi bot kalshi trading bot kalshi bot kalshi trading bot kalshi bot kalshi trading bot kalshi bot kalshi trading bot kalshi bot kalshi trading bot kalshi bot kalshi trading bot",null,"TypeScript",144,2438,100,0,53,10,false,"main",true,[21,22,23,5,24,25],"bot","kalshi","kalshi-trade","nodejs","trading","2026-06-12 02:03:41","\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\u002Fsachmalan\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 Trading Bot 是一个基于多模型AI的交易机器人，专为Kalshi预测市场设计。它利用五种专业的AI代理（包括预测者、新闻分析师、牛市研究员、熊市研究员和风险管理师）进行并行操作，并通过信心加权共识来整合这些代理的意见，以确保在低分歧和高确定性时执行交易。该机器人采用TypeScript编写，支持Node.js环境，集成了Kelly Criterion资金管理策略、自动健康监测与故障转移机制等高级功能。适合需要自动化且高度智能决策支持的高频交易场景，特别是在追求长期稳定收益的同时控制风险的情况下使用。",2,"2026-05-19 02:31:40","CREATED_QUERY"]