Back to feed

Composio-HQ/polymarket-kalshi-arbitrage-bot

Composio-HQ/polymarket-kalshi-arbitrage-bot
243
+47/day
409
TypeScriptWeb

Polymarket Kalshi arbitrage prediction-markets trading-bot TypeScript Node.js CLOB Polygon ethers automated-trading spread-trading DeFi crypto algorithmic-trading market-making Kalshi-API Polymarket-CLOB express axios dotenv

From the README

Polymarket–Kalshi Arbitrage Bot

Repository:

15-minute market trading bot that detects price differences between Polymarket and Kalshi and decides when to buy on Polymarket based on configurable rules.

This is 90% profitable logic, 100% profitable logic version 2 in sale! 🤞

How it works

  • Real-time detection: Fetches UP/DOWN (Yes/No) token prices from both Polymarket (CLOB) and Kalshi (orderbook + market status) on a configurable interval.
  • Start window: The bot only evaluates buy signals after 8 minutes (configurable) from market start time.
  • Buy rules:
    1. Spread rule: When Kalshi’s YES price is in the 93–96¢ range and Polymarket’s UP token is at least 10¢ cheaper (or equal), the bot signals buy on Polymarket.
    2. Late resolution: If Kalshi has finished (closed/settled) but Polymarket is still open and has liquidity, the bot signals buy on Polymarket (arbitrage on timing difference).

Stack

  • Express + TypeScript
  • Axios for Polymarket and Kalshi HTTP APIs
  • @polymarket/clob-client + ethers for placing Polymarket orders (when trading enabled)
  • dotenv for configuration

Setup

npm install
cp .env.example .env
# Edit .env: set MARKET_START_TIME, KALSHI_TICKER, POLYMARKET_TOKEN_UP, POLYMARKET_TOKEN_DOWN, POLYMARKET_PRIVATE_KEY, POLYMARKET_PROXY_WALLET_ADDRESS
npm run build
npm start

For development with auto-reload:

npm run dev

Configuration (.env)

| Variable | Description | Example | |----------|-------------|---------| | PORT | Server port | 3000 | | POLL_INTERVAL_MS | How often to fetch prices (ms) | 5000 | | MARKET_START_TIME | Market start (ISO 8601); used for “after 8 min” window | 2025-02-19T15:00:00.000Z | | START_DELAY_MINS | Minutes after start before evaluating | 8 | | KALSHI_API_BASE | Kalshi API base URL | | |KALSHI_TICKER| Kalshi market ticker for this 15-min market |KXHIGHNY-24JAN01-T60| |POLYMARKET_CLOB_BASE| Polymarket CLOB base | | | POLYMARKET_TOKEN_UP | Polymarket token ID for UP (Yes) | (from Polymarket market page) | | POLYMARKET_TOKEN_DOWN | Polymarket token ID for DOWN (No) | (from Polymarket market page) | | KALSHI_MIN_CENTS | Min Kalshi YES price for spread rule | 93 | | KALSHI_MAX_CENTS | Max Kalshi YES price for spread rule | 96 | | MIN_SPREAD_CENTS | Min spread (Kalshi − Polymarket) to signal buy | 10 | | POLYMARKET_PRIVATE_KEY | EOA private key | 0x... | | POLYMARKET_PROXY_WALLET_ADDRESS | Gnosis Safe / proxy wallet address | 0x... | | POLYMARKET_CHAIN_ID | CLOB chain (Polygon = 137) | 137 | | POLYMARKET_TRADE_USD | USD amount per buy order | 10 | | POLYMARKET_BUY_COOLDOWN_SECONDS | Min seconds between buy orders | 60 |

API

  • GET /health – Health check.
  • GET /status – Last Polymarket and Kalshi prices, current arbitrage signal, whether trading is enabled, and whether the start window