[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-80283":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":15,"stars90d":15,"forks30d":15,"starsTrendScore":15,"compositeScore":16,"rankGlobal":10,"rankLanguage":10,"license":10,"archived":17,"fork":17,"defaultBranch":18,"hasWiki":17,"hasPages":17,"topics":19,"createdAt":10,"pushedAt":10,"updatedAt":40,"readmeContent":41,"aiSummary":42,"trendingCount":15,"starSnapshotCount":15,"syncStatus":43,"lastSyncTime":44,"discoverSource":45},80283,"polymarket-kalshi-arbitrage-bot","Longbridges\u002Fpolymarket-kalshi-arbitrage-bot","Longbridges","polymarket trading bot, polymarket bot, polymarket kalshi trading bot, polymarket trading bot, polymarket bot, polymarket kalshi trading bot, polymarket trading bot, polymarket bot, polymarket kalshi trading bot, polymarket trading bot, polymarket bot, polymarket kalshi trading bot, polymarket trading bot, polymarket bot","https:\u002F\u002Fgithub.com\u002FLongbridges\u002Fpolymarket-kalshi-arbitrage-bot",null,"TypeScript",31,293,81,0,44.41,false,"main",[20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39],"arbitrage","arbitrage-bot","automated-trading","clob","cross-venue-arbitrage","crypto-prediction-markets","event-contracts","kalshi","kalshi-api","kalshi-trading","market-making","nodejs","polymarket","polymarket-arbitrage","polymarket-bot","polymarket-trading-bot","prediction-market","prediction-markets","trading-bot","typescript","2026-06-11 04:07:04","# Polymarket-Kalshi Arbitrage Bot\n\nProfessional TypeScript bot for monitoring short-duration prediction markets across **Polymarket** and **Kalshi**, detecting pricing gaps, and placing buy orders on Polymarket when configured arbitrage rules are satisfied.\n\nThe bot is designed for 15-minute markets where fast pricing updates, clear execution rules, and transparent runtime status matter. It continuously compares Kalshi YES pricing against Polymarket UP pricing, exposes a simple monitoring API, and can initialize an authenticated Polymarket order client for automated execution.\n\n\u003Cp>\n  \u003Ca href=\"https:\u002F\u002Fgithub.com\u002FLongbridges\u002Fpolymarket-kalshi-arbitrage-bot\">\n    \u003Cimg src=\"https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FRepository-GitHub-181717?style=for-the-badge&logo=github\" alt=\"GitHub repository\" \u002F>\n  \u003C\u002Fa>\n\u003C\u002Fp>\n\n> Important: Prediction market trading involves risk. This project provides configurable automation and monitoring logic; it does not guarantee profit or eliminate execution, liquidity, market, regulatory, or operational risk.\n\n## What This Bot Does\n\n- Monitors a paired Kalshi and Polymarket market on a configurable interval.\n- Pulls Polymarket UP\u002FDOWN token pricing from the Polymarket CLOB.\n- Pulls Kalshi YES\u002FNO pricing and market status from the Kalshi trade API.\n- Waits until a configurable start window has passed before evaluating trades.\n- Emits structured arbitrage signals through `\u002Fstatus`.\n- Places Polymarket buy orders using `@polymarket\u002Fclob-client` when valid trading credentials are configured.\n- Applies order cooldowns to reduce duplicate execution during repeated signals.\n- Runs as a lightweight Express service that can be deployed on a VPS, container, or cloud instance.\n\n## Strategy Overview\n\nThe current strategy focuses on buying the Polymarket UP token when Kalshi is pricing the equivalent outcome materially higher.\n\n### Rule 1: Spread-Based Entry\n\nAfter the configured start delay, the bot checks whether Kalshi YES is inside a target confidence band and whether Polymarket UP is meaningfully cheaper.\n\nDefault thresholds:\n\n- Kalshi YES must be between `93` and `96` cents.\n- Polymarket UP must be at least `10` cents cheaper than Kalshi YES.\n- The bot emits `buy_polymarket` when both conditions are true.\n\nExample:\n\n```text\nKalshi YES:      95 cents\nPolymarket UP:   82 cents\nSpread:          13 cents\nDecision:        BUY Polymarket UP\n```\n\nResulting signal:\n\n```json\n{\n  \"action\": \"buy_polymarket\",\n  \"reason\": \"Kalshi YES 95¢ in [93,96], Polymarket UP 82¢ (spread 13¢ >= 10¢).\",\n  \"kalshiYesCents\": 95,\n  \"polymarketUpCents\": 82,\n  \"spreadCents\": 13\n}\n```\n\n### Rule 2: Late Resolution Opportunity\n\nSome short-duration markets can close or settle on one venue while the other still has an active order book. If Kalshi is finished but Polymarket still has liquidity, the bot emits a late-entry signal.\n\nExample:\n\n```text\nKalshi status:       settled\nPolymarket book:     still has liquidity\nDecision:            BUY Polymarket UP\n```\n\nResulting signal:\n\n```json\n{\n  \"action\": \"buy_polymarket_late\",\n  \"reason\": \"Kalshi market finished (closed\u002Fsettled) while Polymarket still has orders.\",\n  \"kalshiStatus\": \"settled\"\n}\n```\n\n## Demo (video + still frame)\n\nMedia is stored under [`src\u002Fimg and video\u002F`](.\u002Fsrc\u002Fimg%20and%20video\u002F):\n\n- **Screen recording:** [`kalshi-trading-bot-reddit-video.mp4`](.\u002Fsrc\u002Fimg%20and%20video\u002Fkalshi-trading-bot-reddit-video.mp4)\n- **Still frame:** [`videoframe_12191.png`](.\u002Fsrc\u002Fimg%20and%20video\u002Fvideoframe_12191.png)\n\nRecording shows Kalshi’s **BTC Up or Down — 15 minutes** market with the green on-screen HUD (UP\u002FDOWN prices, timers, actions) and the **NightShark** log: trigger threshold (`> 70`), UP order placement, position confirmation retries, then stop-loss \u002F resolution monitoring.\n\n### Video\n\n\u003Cvideo\n  poster=\".\u002Fsrc\u002Fimg%20and%20video\u002Fvideoframe_12191.png\"\n  src=\".\u002Fsrc\u002Fimg%20and%20video\u002Fkalshi-trading-bot-reddit-video.mp4\"\n  controls\n  playsinline\n  preload=\"metadata\"\n  width=\"100%\">\n  Your browser cannot play this clip inline. Open the file directly:\n  \u003Ca href=\".\u002Fsrc\u002Fimg%20and%20video\u002Fkalshi-trading-bot-reddit-video.mp4\">kalshi-trading-bot-reddit-video.mp4\u003C\u002Fa>.\n\u003C\u002Fvideo>\n\n### Still frame (full resolution)\n\n\u003Cp align=\"center\">\n  \u003Cimg\n    src=\".\u002Fsrc\u002Fimg%20and%20video\u002Fvideoframe_12191.png\"\n    alt=\"Kalshi BTC 15m market: trading HUD with UP\u002FDOWN prices and NightShark log (trigger, order, position confirm, stop-loss)\"\n    width=\"100%\" \u002F>\n  \u003Cbr \u002F>\n  \u003Cem>Same session as the recording — Kalshi chart\u002Forder book with HUD and NightShark application log.\u003C\u002Fem>\n\u003C\u002Fp>\n\n## Architecture\n\n```text\nKalshi API              Polymarket CLOB\n    |                         |\n    |                         |\n    +------ price polling ----+\n              |\n              v\n      Arbitrage decision engine\n              |\n      +-------+--------+\n      |                |\n      v                v\n  \u002Fstatus API     Polymarket order client\n                   authenticated execution\n```\n\nCore modules:\n\n- `src\u002Findex.ts` starts the Express API, polling loop, and optional trading client.\n- `src\u002Fconfig.ts` loads and validates runtime configuration from `.env`.\n- `src\u002Fservices\u002Fkalshi.ts` fetches Kalshi market data.\n- `src\u002Fservices\u002Fpolymarket.ts` fetches Polymarket CLOB prices.\n- `src\u002Fservices\u002Farbitrage.ts` evaluates buy\u002Fno-buy decisions.\n- `src\u002Fservices\u002FpolymarketOrders.ts` places Polymarket orders when trading is enabled.\n\n## Tech Stack\n\n- **Node.js 18+**\n- **TypeScript**\n- **Express** for the HTTP monitoring\u002Fcontrol API\n- **Axios** for Kalshi and Polymarket HTTP requests\n- **@polymarket\u002Fclob-client** for Polymarket order placement\n- **ethers** for wallet\u002Fclient support\n- **dotenv** for environment-based configuration\n\n## Quick Start\n\nInstall dependencies:\n\n```bash\nnpm install\n```\n\nCreate a local environment file:\n\n```bash\ncp .env.example .env\n```\n\nEdit `.env` with your market pair and wallet settings, then run:\n\n```bash\nnpm run build\nnpm start\n```\n\nFor development with auto-reload:\n\n```bash\nnpm run dev\n```\n\nThe service starts polling automatically and exposes the API on `http:\u002F\u002Flocalhost:3000` by default.\n\n## Example `.env`\n\n```env\nPORT=3000\nPOLL_INTERVAL_MS=5000\n\nMARKET_START_TIME=2026-05-11T07:00:00.000Z\nSTART_DELAY_MINS=8\n\nKALSHI_API_BASE=https:\u002F\u002Fapi.elections.kalshi.com\u002Ftrade-api\u002Fv2\nKALSHI_TICKER=KXHIGHNY-24JAN01-T60\n\nPOLYMARKET_CLOB_BASE=https:\u002F\u002Fclob.polymarket.com\nPOLYMARKET_TOKEN_UP=1234567890123456789012345678901234567890\nPOLYMARKET_TOKEN_DOWN=9876543210987654321098765432109876543210\n\nKALSHI_MIN_CENTS=93\nKALSHI_MAX_CENTS=96\nMIN_SPREAD_CENTS=10\n\nPOLYMARKET_PRIVATE_KEY=0x\u003C64_HEX_CHARACTER_PRIVATE_KEY>\nPOLYMARKET_PROXY_WALLET_ADDRESS=0x\u003C40_HEX_CHARACTER_PROXY_WALLET>\nPOLYMARKET_CHAIN_ID=137\nPOLYMARKET_TRADE_USD=10\nPOLYMARKET_BUY_COOLDOWN_SECONDS=60\n```\n\nKeep private keys out of source control. Use a dedicated trading wallet with limited funds.\n\n## Configuration Reference\n\n| Variable | Description | Default \u002F Example |\n| --- | --- | --- |\n| `PORT` | HTTP server port. | `3000` |\n| `POLL_INTERVAL_MS` | Price polling interval in milliseconds. | `5000` |\n| `MARKET_START_TIME` | Market start time in ISO 8601 format. | `2026-05-11T07:00:00.000Z` |\n| `START_DELAY_MINS` | Minutes after market start before evaluating signals. | `8` |\n| `KALSHI_API_BASE` | Kalshi trade API base URL. | `https:\u002F\u002Fapi.elections.kalshi.com\u002Ftrade-api\u002Fv2` |\n| `KALSHI_TICKER` | Kalshi market ticker for the target market. | `KXHIGHNY-24JAN01-T60` |\n| `POLYMARKET_CLOB_BASE` | Polymarket CLOB API base URL. | `https:\u002F\u002Fclob.polymarket.com` |\n| `POLYMARKET_TOKEN_UP` | Polymarket UP\u002FYES token ID. | From the Polymarket market |\n| `POLYMARKET_TOKEN_DOWN` | Polymarket DOWN\u002FNO token ID. | From the Polymarket market |\n| `KALSHI_MIN_CENTS` | Lower Kalshi YES price bound for spread entries. | `93` |\n| `KALSHI_MAX_CENTS` | Upper Kalshi YES price bound for spread entries. | `96` |\n| `MIN_SPREAD_CENTS` | Minimum Kalshi minus Polymarket spread required. | `10` |\n| `POLYMARKET_PRIVATE_KEY` | EOA private key used for trading. | `0x...` |\n| `POLYMARKET_PROXY_WALLET_ADDRESS` | Polymarket proxy wallet \u002F Safe address. | `0x...` |\n| `POLYMARKET_CHAIN_ID` | Chain ID for Polymarket CLOB. | `137` |\n| `POLYMARKET_TRADE_USD` | USD amount per buy order. | `10` |\n| `POLYMARKET_BUY_COOLDOWN_SECONDS` | Minimum seconds between buy orders. | `60` |\n\n## API Reference\n\n### `GET \u002Fhealth`\n\nSimple health check.\n\n```bash\ncurl http:\u002F\u002Flocalhost:3000\u002Fhealth\n```\n\nExample response:\n\n```json\n{\n  \"ok\": true,\n  \"ts\": \"2026-05-11T07:08:14.122Z\"\n}\n```\n\n### `GET \u002Fstatus`\n\nReturns the latest market data, trading state, and current arbitrage signal.\n\n```bash\ncurl http:\u002F\u002Flocalhost:3000\u002Fstatus\n```\n\nExample response:\n\n```json\n{\n  \"tradingEnabled\": true,\n  \"afterStartWindow\": true,\n  \"lastTickAt\": 1778483294122,\n  \"polymarket\": {\n    \"upCents\": 82,\n    \"downCents\": 18,\n    \"hasLiquidity\": true,\n    \"fetchedAt\": 1778483293988\n  },\n  \"kalshi\": {\n    \"yesCents\": 95,\n    \"noCents\": 5,\n    \"status\": \"open\",\n    \"isFinished\": false,\n    \"fetchedAt\": 1778483294041\n  },\n  \"signal\": {\n    \"action\": \"buy_polymarket\",\n    \"reason\": \"Kalshi YES 95¢ in [93,96], Polymarket UP 82¢ (spread 13¢ >= 10¢).\",\n    \"kalshiYesCents\": 95,\n    \"polymarketUpCents\": 82,\n    \"spreadCents\": 13\n  }\n}\n```\n\n### `POST \u002Fpoll\u002Fstart`\n\nStarts the polling loop. Polling starts automatically when the service boots, but this endpoint is useful after manually stopping it.\n\n```bash\ncurl -X POST http:\u002F\u002Flocalhost:3000\u002Fpoll\u002Fstart\n```\n\n### `POST \u002Fpoll\u002Fstop`\n\nStops the polling loop without shutting down the HTTP server.\n\n```bash\ncurl -X POST http:\u002F\u002Flocalhost:3000\u002Fpoll\u002Fstop\n```\n\n## Operating Notes\n\n### Monitoring Signals\n\nThe `\u002Fstatus` endpoint always exposes the latest evaluated signal, including no-buy reasons. This is useful for validating market pairing, reviewing spreads, and demonstrating the strategy logic before increasing capital allocation.\n\nBest for:\n\n- Strategy validation\n- Client demos\n- Reviewing live signal behavior\n- Collecting signal frequency data\n\n### Automated Trading\n\nWhen `POLYMARKET_PRIVATE_KEY` and `POLYMARKET_PROXY_WALLET_ADDRESS` are valid, the bot initializes the Polymarket order client and places buy orders when a buy signal appears. Use a dedicated wallet and conservative trade size while validating behavior.\n\nExecution protections included in the current code:\n\n- Configurable trade size via `POLYMARKET_TRADE_USD`\n- Configurable buy cooldown via `POLYMARKET_BUY_COOLDOWN_SECONDS`\n- Price validation before submitting a buy\n- In-memory latest state for transparent API inspection\n\n## Example Client Workflow\n\n1. Select a 15-minute event that exists on both Kalshi and Polymarket.\n2. Copy the Kalshi ticker into `KALSHI_TICKER`.\n3. Copy the matching Polymarket UP and DOWN token IDs into `.env`.\n4. Set `MARKET_START_TIME` and confirm `START_DELAY_MINS`.\n5. Run the bot and watch `\u002Fstatus` to confirm price feeds and signal behavior.\n6. Confirm the signal behavior against live market screens.\n7. Use a limited Polymarket wallet and conservative `POLYMARKET_TRADE_USD`.\n8. Monitor logs and the `\u002Fstatus` endpoint during the active market window.\n\n## Sample Logs\n\n```text\nPolymarket-Kalshi arbitrage bot listening on port 3000\n  GET \u002Fhealth  - health check\n  GET \u002Fstatus  - last prices and current signal\n  POST \u002Fpoll\u002Fstart - start price polling\n  POST \u002Fpoll\u002Fstop  - stop price polling\n[Bot] Polymarket order client ready (trading enabled).\n[Bot] Polling every 5000ms\n[Bot] BUY SIGNAL: {\n  \"action\": \"buy_polymarket\",\n  \"kalshiYesCents\": 95,\n  \"polymarketUpCents\": 82,\n  \"spreadCents\": 13\n}\n[Bot] Polymarket BUY order placed: { \"...\": \"...\" }\n```\n\n## Deployment Notes\n\n- Run on a stable machine with reliable network access.\n- Use process supervision such as `pm2`, Docker, systemd, or your cloud provider's runtime manager.\n- Store secrets in environment variables or a managed secret store.\n- Use a dedicated wallet with limited capital.\n- Monitor `\u002Fhealth`, `\u002Fstatus`, application logs, and wallet balances.\n- Keep polling intervals reasonable to avoid unnecessary API load.\n\n## Security Notes\n\n- Never commit `.env` or private keys.\n- Rotate keys if they were ever exposed.\n- Use a dedicated proxy wallet for bot execution.\n- Start with small trade sizes until the full workflow is verified.\n- Review venue rules and local regulations before using automated trading.\n\n## Commands\n\n```bash\nnpm run dev        # Start development server with auto-reload\nnpm run build      # Compile TypeScript to dist\u002F\nnpm start          # Run compiled production build\nnpm run typecheck  # Type-check without emitting files\n```\n\n## Disclaimer\n\nThis repository is provided for software engineering and automation purposes. Markets can move quickly, APIs can fail, liquidity can disappear, and automated orders can execute at unfavorable times. Review the code, test carefully, and trade only with capital you can afford to risk.\n","这是一个用于监测Polymarket和Kalshi平台上短期预测市场的套利机器人，能够检测价格差异并在满足预设条件时自动在Polymarket上下单。该项目使用TypeScript开发，具备快速更新价格、明确执行规则以及透明运行状态的特点，通过持续对比Kalshi的YES定价与Polymarket的UP定价来发现套利机会，并提供了一个简单的监控API接口。此外，该机器人还支持配置交易凭证以实现自动化订单执行。适用于追求低延迟、高效率的跨平台套利交易场景，特别是对15分钟内结束的市场事件感兴趣的专业投资者。需要注意的是，尽管此项目提供了高度可配置的自动化工具，但并不能保证盈利或完全规避各种交易风险。",2,"2026-06-11 04:00:10","CREATED_QUERY"]