Kalshi Trader
Automated prediction market trading on Kalshi. Scans every 15 minutes, researches before every trade, reports daily via Telegram.
Setup (run once)
1. Install dependencies
CODEBLOCK0
2. Store Kalshi credentials
CODEBLOCK1
Get your API key at: kalshi.com → Settings → API → Create Key
3. Deploy the bot
CODEBLOCK2
4. Test connection
CODEBLOCK3
5. Set up cron jobs (via OpenClaw cron tool)
15-minute scan (silent unless trade placed or exited):
- - Schedule: INLINECODE0
- Message: see references/cron-prompt.md
Daily summary (9am your timezone):
- - Schedule:
0 9 * * * with your timezone - Message: "Run
python3 ~/kalshi_bot.py summary and send daily trading report with balance, open positions, recent trades, P&L, and fees paid."
Trading Rules
Entry criteria
Only place a trade if
EV IRR ≥ 50% (post-fee):
edge = fair_value - (market_price + entry_fee)
EV IRR = (edge / (market_price + entry_fee)) × (365 / days_to_close)
Minimum: EV IRR ≥ 0.50 (50%)
Position sizing — Half Kelly
CODEBLOCK5
Exit rule
Exit ONLY if current bid ≥ fair value estimate (net of exit fee).
- - Never use price-based stop losses — prediction markets resolve on facts, not on what other traders think
- If price drops, research whether the underlying facts changed
- Only exit early if: (a) price reached fair value, or (b) new evidence shows the outcome is unlikely
Research approach
Use
web_fetch as primary research tool (no quota limits). Known data sources:
- - Gas prices: INLINECODE4
- Trump actions: INLINECODE5
- Treasury yields: INLINECODE6
- Bitcoin/crypto: INLINECODE7
- Weather: INLINECODE8
- Congress bills: INLINECODE9
Only use web_search for open-ended research where the URL isn't known upfront.
Bot Commands
CODEBLOCK6
Reporting format (include in every update)
- - 💰 Cash balance
- 📦 Total position cost
- 📈 Current market value of positions
- 💹 Unrealized P&L
- 💸 Total Kalshi fees paid
- 🏦 Total portfolio value
API reference
See references/api.md for Kalshi authentication and endpoints.
Trade research workflow
See references/trade-research.md for finding and evaluating opportunities.
Kalshi 交易机器人
在Kalshi上进行自动化预测市场交易。每15分钟扫描一次,每次交易前进行研究,每日通过Telegram报告。
设置(仅需运行一次)
1. 安装依赖
bash
pip install cryptography requests --break-system-packages
2. 存储Kalshi凭证
bash
mkdir -p ~/.kalshi && chmod 700 ~/.kalshi
nano ~/.kalshi/private_key.pem # 粘贴 -----BEGIN RSA PRIVATE KEY----- 块
chmod 600 ~/.kalshi/private_key.pem
echo 你的API密钥ID > ~/.kalshi/key_id.txt
chmod 600 ~/.kalshi/key_id.txt
在以下位置获取你的API密钥:kalshi.com → 设置 → API → 创建密钥
3. 部署机器人
bash
cp scripts/kalshi
bot.py ~/kalshibot.py
chmod 600 ~/kalshi_bot.py
4. 测试连接
bash
python3 ~/kalshi_bot.py test
5. 设置定时任务(通过OpenClaw定时任务工具)
15分钟扫描(除非开仓或平仓,否则静默运行):
- - 调度:/15 *
- 消息:参见 references/cron-prompt.md
每日总结(你的时区上午9点):
- - 调度:0 9 * 加上你的时区
- 消息:运行 python3 ~/kalshi_bot.py summary 并发送包含余额、持仓、近期交易、盈亏和已付费用的每日交易报告。
交易规则
入场条件
仅当
EV IRR ≥ 50%(扣除费用后)时才进行交易:
edge = 公允价值 - (市场价格 + 入场费)
EV IRR = (edge / (市场价格 + 入场费)) × (365 / 距到期天数)
最低要求:EV IRR ≥ 0.50(50%)
仓位规模 — 半凯利公式
凯利比例 = (edge / 市场价格) × 0.5
最大仓位 = min(凯利比例 × 余额, 0.20 × 余额)
合约数量 = floor(最大仓位 / 市场价格)
退出规则
仅当当前买价 ≥ 公允价值估计(扣除退出费后)时退出。
- - 绝不使用基于价格的止损——预测市场基于事实而非其他交易者的想法来结算
- 如果价格下跌,研究底层事实是否发生变化
- 仅在以下情况下提前退出:(a)价格达到公允价值,或(b)新证据表明结果不太可能发生
研究方法
使用 web_fetch 作为主要研究工具(无配额限制)。已知数据来源:
- - 汽油价格:https://gasprices.aaa.com/
- 特朗普行动:https://www.whitehouse.gov/presidential-actions/
- 国债收益率:https://home.treasury.gov/resource-center/data-chart-center/interest-rates/
- 比特币/加密货币:https://api.coingecko.com/api/v3/simple/price?ids=bitcoin&vs_currencies=usd
- 天气:https://wttr.in/城市名?format=3
- 国会法案:https://www.congress.gov
仅在URL未知的开放式研究中使用 web_search。
机器人命令
bash
python3 ~/kalshi_bot.py # 扫描机会
python3 ~/kalshi_bot.py summary # 打印盈亏总结
python3 ~/kalshi_bot.py test # 验证API连接
报告格式(每次更新均包含)
- - 💰 现金余额
- 📦 总持仓成本
- 📈 持仓当前市值
- 💹 未实现盈亏
- 💸 已付Kalshi总费用
- 🏦 总投资组合价值
API参考
参见 references/api.md 了解Kalshi认证和端点。
交易研究工作流程
参见 references/trade-research.md 了解如何寻找和评估机会。