Back to feed

TradeCompute/polymarket-arbitrage-trading-bot

TradeCompute/polymarket-arbitrage-trading-bot
302
+68/wk
932
TypeScript

Polymarket arbitrage trading bot: Polymarket arbitrage trading bot Polymarket arbitrage bot Polymarket trading bot Polymarket trading bot Polymarket trading bot Polymarket trading bot Polymarket trading bot Polymarket trading bot Polymarket trading bot Polymarket trading bot Polymarket trading bot Polymarket trading bot Polymarket tradingbot

From the README

Polymarket Arbitrage Trading Bot (TypeScript)

Production-style TypeScript bot for Polymarket binary crypto markets.
The bot continuously tracks selected markets, evaluates configured strategy rules, and executes buy/sell orders through the Polymarket CLOB API.

What this bot does

  • Selects active market contracts by coin and period (5m, 15m, 1h, 4h, 1d)
  • Polls bid/ask prices for both UP and DOWN tokens
  • Runs strategy logic from trade.toml (trade_1 or trade_2)
  • Posts market orders with retry handling and balance confirmation
  • Prints live status with trend/position legend for operator visibility

Strategy model

This repository is positioned as an arbitrage trading bot and currently implements two configurable rule sets:

trade_1 (time/price-driven exit model)

  • Tracks market progress and UP price ratio
  • Exits existing position when either:
    • elapsed time ratio exceeds trade_1.exit_time_ratio, or
    • UP price ratio exceeds trade_1.exit_price_ratio

trade_2 (entry/exit range model with emergency swap)

  • Enters only when:
    • elapsed time ratio exceeds trade_2.entry_time_ratio, and
    • UP ratio is within trade_2.entry_price_ratio
  • Exits when UP ratio falls into any configured trade_2.exit_price_ratio_range
  • Optionally performs opposite-side immediate buy on successful exit if trade_2.emergency_swap_price matches

Requirements

  • Node.js >= 20.6.0
  • Polymarket signer private key
  • Polymarket proxy wallet address

Quick start

  1. Install dependencies:
npm install
  1. Create .env in the project root:
POLYMARKET_PRIVATE_KEY=your_private_key
PROXY_WALLET_ADDRESS=your_proxy_wallet_address
  1. Configure runtime behavior in trade.toml:
  • strategy: trade_1 or trade_2
  • trade_usd: order amount in USD
  • max_retries: retry count for order execution
  • [market].market_coin: btc | eth | sol | xrp
  • [market].market_period: 5 | 15 | 60 | 240 | 1440
  1. Start the bot:
npm run dev

Runtime output legend

  • Trend:
    • UP 🟢
    • DOWN 🔴
    • FLAT ⚪
  • Position:
    • UP 🟩
    • DOWN 🟥
    • NONE ⬛

The startup header also prints:

  • Current public key
  • Active strategy
  • Selected market window
  • Trade USD amount

Scripts

| Command | Description | | --- | --- | | npm run dev | Run bot in dev mode (tsx src/index.ts) | | npm run build | Compile TypeScript to dist/ | | npm start | Run compiled output (node dist/index.js) |

Project structure

  • src/index.ts - startup flow, market loop, and strategy execution cycle
  • src/config/ - environment and TOML config loading/validation
  • src/services/ - CLOB and Gamma API integrations
  • src/trade/ - strategy decision methods, price processing, and order execution
  • trade.toml - strategy and market configuration

Security and operations

  • Never commit .env or wallet keys.
  • Use a dedicated wallet and risk-limited balance.
  • Test with low trade_usd before increa