dexorynlabs/polymarket-trading-bot-tsPublic

polymarket copy tading bot with Typescript + Websocket

AI summary: A TypeScript CLI tool for copy-trading on Polymarket using CLOB and WebSockets.

Stars
2
Forks
0
Watchers
0
Open issues
0
Open PRs
0
Contributors
~1
Commits
34
Branches
1

TypeScriptMITCreated Apr 24, 2026Last push 3mo ago+1 stars this week+1 this month

Star history

since Jan 18, 2026
01122Jan 2026Mar 2026May 2026Aug 2026
2 stars as of Aug 7, 2026, tracked back to Jan 18, 2026. Historical curve reconstructed from public GitHub event archives, calibrated to the current total.

Signals and awards

derived from tracked data
  • Rising fast

    +1 stars this week

  • Permissive license

    MIT

What polymarket-trading-bot-ts does

This project is a TypeScript-based copy-trading bot that interacts with the Polymarket Central Limit Order Book (CLOB). It monitors public trading activity for a whitelisted set of wallet addresses and automatically mirrors their BUY and SELL actions. The bot supports complex position management, including fixed or proportional stake sizing, position limits per token, and configurable take-profit and trailing stop-loss mechanisms. It is designed to run continuously via Node.js and includes a CLI for managing wallets and checking session P&L.

This tool is built for algorithmic traders and researchers who want to automate copy-trading strategies on Polymarket. It requires Node.js 18+, a funded Polygon wallet, and basic familiarity with CLI tools.

  • WebSocket monitoring: polls and listens to public trade activity for configured target addresses in real-time.
  • Configurable sizing: allows users to choose between fixed stake amounts or proportional sizing based on balance.
  • Risk management: implements take-profit triggers and trailing stop-loss logic to secure gains and limit losses.
  • Position limits: restricts maximum buys per token and enforces cooldown periods after closing a position.
  • Command-line interface: provides tools to check readiness, set allowances, and track session profit and loss.

Where teams use it

Mirror trading on Polymarket

Automatically copying the prediction market trades of successful public wallet addresses.

Automated risk management

Using trailing stops and take-profit features to manage Polymarket positions without manual oversight.

Algorithmic execution

Interacting directly with the Polymarket CLOB to ensure rapid trade execution.

Session tracking

Monitoring the performance and profitability of copied trades over a specific running session.

Getting started: npm run build && npm run bot

README

main branch

Polymarket copy trading bot (TypeScript)

Dexoryn Labs — see repository for updates. Warning: this software is for education and research. Prediction markets are risky; you can lose your stake.

A Polymarket CLOB copy-trading tool: it follows configured wallet addresses, sizes orders relative to your balance, and can manage exits with take-profit and trailing stop logic.

Features

  • Copy trading — Polls public trade activity for whitelisted addresses and mirrors BUY/SELL on the CLOB.
  • Sizingfixed or proportional stake between min_stake and max_stake.
  • Position limitsmax_buys_per_token and per-token cooldown after a position is closed.
  • Take-profit / trailing stop — Configurable profit trigger and stop-from-peak; wider behavior on sports slugs (see take-profit.ts / bot.ts).
  • Session P&L — Tracks session stats while the process runs.
  • CLI — Wallets, balance, readiness, allowances (relayer), and close-all.

Requirements

  • Node.js 18+
  • A Polymarket account with USDC, private key (signing), and FUNDER_ADDRESS (Polymarket trading / proxy address as shown on the site).

Quick start

npm install

cp env.example .env
# Set PRIVATE_KEY and FUNDER_ADDRESS in .env

cp config.example.json config.json
# Set wallets_to_track and risk parameters

npm run build

npm run cli check-ready
npm run cli set-allowances   # once, if you use the relayer path

npm run bot
# or: npm start   (uses compiled dist/main.js)

Windows: npm run clean removes the dist folder (no Unix rm required).

Environment variables

Variable Required Description
PRIVATE_KEY Yes EOA private key (0x-prefixed) for signing.
FUNDER_ADDRESS Yes* Polymarket wallet address (needed for CLOB/relayer flows). *Required for set-allowances and normal trading per code paths.
TAKE_PROFIT_PERCENT No Profit trigger (%). Overrides profit_take_percent in config when set.
DEBUG No true for verbose error detail in logs.

config.json

Copy from config.example.json. All boolean/number fields should be valid JSON (no // comments in the file).

Field Description
wallets_to_track List of 0x addresses to follow.
mode proportional or fixed (use fixed_stake when fixed).
min_stake / max_stake USDC bounds for order size.
max_buys_per_token Max BUY entries for the same token.
cooldown_minutes After a position is treated as closed, wait before re-buying the same token.
stop_loss_percent / stop_loss_enabled Trailing stop from peak; can be disabled.
skip_sports If true, skips BUYs on markets detected as sports by slug patterns.
profit_take_percent Default take-profit / tracking threshold when TAKE_PROFIT_PERCENT is unset.

CLI commands

Command Description
npm run bot Start the bot (tsx src/main.ts start).
npm run cli start Same as bot.
npm run cli check-ready Balances, CLOB, allowances.
npm run cli set-allowances Set allowances via relayer (requires FUNDER_ADDRESS).
npm run cli balance Show balance / positions.
npm run cli wallets add 0x… Add a tracked address.
npm run cli wallets list List tracked addresses.
npm run cli wallets remove 0x… Remove an address.
npm run cli config View or set config fields (see --help).
npm run cli status Show env + config summary.
npm run cli close-all --yes Market-close open positions (destructive; confirms with --yes).
npm run dev / npm run build / npm run clean Develop, compile, clean dist.

How it works (high level)

  1. WalletWatcher polls recent trades for each tracked address.
  2. TradeInterpreter maps API events to a normalized trade.
  3. PositionSizer enforces min/max and proportional sizing.
  4. TradeExecutor / RealTrader submit CLOB orders with retries on transient API errors.
  5. TakeProfitManager monitors open positions and may place exit orders per your thresholds.

Project layout

src/
  main.ts          # entry — loads .env, runs CLI
  cli.ts           # Commander: start, balance, wallets, check-ready, etc.
  bot.ts           # startBot: watcher + execution loop
  watcher.ts       # trade polling
  executor.ts      # position/trade coordination
  trader.ts        # CLOB order placement
  take-profit.ts   # profit / stop monitoring
  sizing.ts        # stake calculation
  interpreter.ts   # normalize watch events
  api.ts           # data-api, gamma-api HTTP client
  wallet.ts        # keys, CLOB client, balance
  relayer.ts       # allowance helper
  pnl-tracker.ts   # session P&L
  stats.ts         # trade event stats
  config.ts        # default config and loadConfig()
  logger.ts        # debug-aware logging

Troubleshooting

  • “PRIVATE_KEY not found” — Create .env from env.example.
  • “Not enough balance” / min stake — Fund Polymarket USDC; lower min_stake or top up.
  • CLOB 502/503 — Transient; the trader retries. Persistent failures: check network and Polymarket status.
  • Allowances — Use check-ready and either set-allowances or complete approvals in the Polymarket UI.

License

MIT — see LICENSE.

View on GitHub

Recent activity

commits and pull requests

When work happens

weekday and hour
SunMonTueWedThuFriSat036912151821Sun 0:00 — 0 commitsSun 1:00 — 0 commitsSun 2:00 — 0 commitsSun 3:00 — 0 commitsSun 4:00 — 0 commitsSun 5:00 — 0 commitsSun 6:00 — 0 commitsSun 7:00 — 1 commitsSun 8:00 — 0 commitsSun 9:00 — 0 commitsSun 10:00 — 0 commitsSun 11:00 — 0 commitsSun 12:00 — 0 commitsSun 13:00 — 0 commitsSun 14:00 — 0 commitsSun 15:00 — 1 commitsSun 16:00 — 0 commitsSun 17:00 — 0 commitsSun 18:00 — 0 commitsSun 19:00 — 0 commitsSun 20:00 — 0 commitsSun 21:00 — 0 commitsSun 22:00 — 0 commitsSun 23:00 — 0 commitsMon 0:00 — 0 commitsMon 1:00 — 0 commitsMon 2:00 — 0 commitsMon 3:00 — 0 commitsMon 4:00 — 2 commitsMon 5:00 — 0 commitsMon 6:00 — 0 commitsMon 7:00 — 0 commitsMon 8:00 — 0 commitsMon 9:00 — 1 commitsMon 10:00 — 2 commitsMon 11:00 — 0 commitsMon 12:00 — 0 commitsMon 13:00 — 0 commitsMon 14:00 — 0 commitsMon 15:00 — 0 commitsMon 16:00 — 0 commitsMon 17:00 — 0 commitsMon 18:00 — 0 commitsMon 19:00 — 0 commitsMon 20:00 — 0 commitsMon 21:00 — 0 commitsMon 22:00 — 0 commitsMon 23:00 — 2 commitsTue 0:00 — 0 commitsTue 1:00 — 0 commitsTue 2:00 — 0 commitsTue 3:00 — 0 commitsTue 4:00 — 0 commitsTue 5:00 — 0 commitsTue 6:00 — 0 commitsTue 7:00 — 0 commitsTue 8:00 — 0 commitsTue 9:00 — 0 commitsTue 10:00 — 0 commitsTue 11:00 — 0 commitsTue 12:00 — 0 commitsTue 13:00 — 0 commitsTue 14:00 — 0 commitsTue 15:00 — 0 commitsTue 16:00 — 0 commitsTue 17:00 — 0 commitsTue 18:00 — 0 commitsTue 19:00 — 0 commitsTue 20:00 — 0 commitsTue 21:00 — 0 commitsTue 22:00 — 1 commitsTue 23:00 — 0 commitsWed 0:00 — 0 commitsWed 1:00 — 0 commitsWed 2:00 — 0 commitsWed 3:00 — 0 commitsWed 4:00 — 0 commitsWed 5:00 — 0 commitsWed 6:00 — 0 commitsWed 7:00 — 0 commitsWed 8:00 — 0 commitsWed 9:00 — 1 commitsWed 10:00 — 0 commitsWed 11:00 — 0 commitsWed 12:00 — 1 commitsWed 13:00 — 1 commitsWed 14:00 — 0 commitsWed 15:00 — 0 commitsWed 16:00 — 2 commitsWed 17:00 — 1 commitsWed 18:00 — 0 commitsWed 19:00 — 0 commitsWed 20:00 — 0 commitsWed 21:00 — 0 commitsWed 22:00 — 0 commitsWed 23:00 — 0 commitsThu 0:00 — 0 commitsThu 1:00 — 0 commitsThu 2:00 — 0 commitsThu 3:00 — 0 commitsThu 4:00 — 0 commitsThu 5:00 — 0 commitsThu 6:00 — 0 commitsThu 7:00 — 1 commitsThu 8:00 — 0 commitsThu 9:00 — 0 commitsThu 10:00 — 0 commitsThu 11:00 — 0 commitsThu 12:00 — 0 commitsThu 13:00 — 0 commitsThu 14:00 — 0 commitsThu 15:00 — 0 commitsThu 16:00 — 0 commitsThu 17:00 — 0 commitsThu 18:00 — 0 commitsThu 19:00 — 0 commitsThu 20:00 — 0 commitsThu 21:00 — 0 commitsThu 22:00 — 0 commitsThu 23:00 — 10 commitsFri 0:00 — 0 commitsFri 1:00 — 0 commitsFri 2:00 — 0 commitsFri 3:00 — 0 commitsFri 4:00 — 1 commitsFri 5:00 — 0 commitsFri 6:00 — 0 commitsFri 7:00 — 0 commitsFri 8:00 — 0 commitsFri 9:00 — 0 commitsFri 10:00 — 0 commitsFri 11:00 — 0 commitsFri 12:00 — 0 commitsFri 13:00 — 0 commitsFri 14:00 — 0 commitsFri 15:00 — 0 commitsFri 16:00 — 0 commitsFri 17:00 — 0 commitsFri 18:00 — 0 commitsFri 19:00 — 0 commitsFri 20:00 — 1 commitsFri 21:00 — 0 commitsFri 22:00 — 0 commitsFri 23:00 — 0 commitsSat 0:00 — 3 commitsSat 1:00 — 0 commitsSat 2:00 — 0 commitsSat 3:00 — 0 commitsSat 4:00 — 0 commitsSat 5:00 — 0 commitsSat 6:00 — 0 commitsSat 7:00 — 0 commitsSat 8:00 — 0 commitsSat 9:00 — 0 commitsSat 10:00 — 0 commitsSat 11:00 — 0 commitsSat 12:00 — 0 commitsSat 13:00 — 0 commitsSat 14:00 — 0 commitsSat 15:00 — 0 commitsSat 16:00 — 0 commitsSat 17:00 — 0 commitsSat 18:00 — 1 commitsSat 19:00 — 0 commitsSat 20:00 — 0 commitsSat 21:00 — 0 commitsSat 22:00 — 0 commitsSat 23:00 — 0 commits
Commit volume by weekday and hour (UTC). Larger dots mean more commits.
DateListRankStars gained
Jan 20, 2026daily#18+178
  • freeCodeCamp/freeCodeCamp

    freeCodeCamp.org's open-source codebase and curriculum. Learn math, programming, and computer science for free.

    453.6K stars · TypeScript

  • openclaw/openclaw

    Your own personal AI assistant. Any OS. Any Platform. The lobster way. 🦞

    385.5K stars · TypeScript

  • openclaw/openclaw

    Your own personal AI assistant. Any OS. Any Platform. The lobster way. 🦞

    384.4K stars · TypeScript

  • openclaw/openclaw

    Your own personal AI assistant. Any OS. Any Platform. The lobster way. 🦞

    384.4K stars · TypeScript

  • openclaw/openclaw

    Your own personal AI assistant. Any OS. Any Platform. The lobster way. 🦞

    384.4K stars · TypeScript

  • anomalyco/opencode

    The open source coding agent.

    194.7K stars · TypeScript