TradeCompute/polymarket-arbitrage-trading-bot
TradeCompute/polymarket-arbitrage-trading-botPolymarket 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_1ortrade_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
- elapsed time ratio exceeds
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
- elapsed time ratio exceeds
- 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_pricematches
Requirements
- Node.js
>= 20.6.0 - Polymarket signer private key
- Polymarket proxy wallet address
Quick start
- Install dependencies:
npm install
- Create
.envin the project root:
POLYMARKET_PRIVATE_KEY=your_private_key
PROXY_WALLET_ADDRESS=your_proxy_wallet_address
- Configure runtime behavior in
trade.toml:
strategy:trade_1ortrade_2trade_usd: order amount in USDmax_retries: retry count for order execution[market].market_coin:btc | eth | sol | xrp[market].market_period:5 | 15 | 60 | 240 | 1440
- 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 cyclesrc/config/- environment and TOML config loading/validationsrc/services/- CLOB and Gamma API integrationssrc/trade/- strategy decision methods, price processing, and order executiontrade.toml- strategy and market configuration
Security and operations
- Never commit
.envor wallet keys. - Use a dedicated wallet and risk-limited balance.
- Test with low
trade_usdbefore increa