A beginner-friendly guide to setting up and running your first automated trading bot on Polymarket.
Repository: https://github.com/Obsidian-Trades/polymarket-copy-trading-bot
This bot places real money trades on the blockchain. Please read this before doing anything:
- You can lose money. This is not guaranteed to be profitable.
- Start with very small amounts (e.g. $5–$10) while you're learning.
- Use a separate, dedicated wallet — never your main crypto wallet.
- This is a tool for experienced users who understand the risks. If you're brand new to crypto trading, take time to learn the basics first.
In plain English: Polymarket runs short-duration prediction markets where you can bet on whether Bitcoin's price will go Up or Down in the next 5 minutes. Every pair of Up + Down tokens always resolves to a combined value of $1.
This bot exploits small pricing gaps in those markets:
- It watches for a moment when you can buy both Up and Down tokens for a combined price less than $1.
- It buys both sides simultaneously — no matter which direction Bitcoin moves, the pair is worth $1 at resolution.
- The difference between what you paid and $1 is your profit.
It also includes a copy-trading mode that mirrors the trades of a target wallet you choose to follow.
Here's what the bot's activity looks like in practice:
This repo has two main modes. Pick the one that fits your goal:
| Mode | What it does | Best for |
|---|---|---|
| Main Arb Bot | Automatically trades 5-min BTC markets | Hands-off automated trading |
| Copy Trader | Mirrors trades from a wallet you choose | Following a successful trader |
Before installing anything, make sure you have all of the following:
- A computer running Windows, Mac, or Linux
- Node.js version 18 or newer — Download here. To check your version, run
node --versionin your terminal. - A Polymarket account — Sign up at polymarket.com
- A Polygon wallet — this is where your funds live (e.g. MetaMask set to Polygon network)
- Your wallet's private key — the secret key for your trading wallet (
⚠️ never share this with anyone) - Your Polymarket proxy wallet address — found in your Polymarket account settings
- USDC on Polygon — the stablecoin used for trading (not Ethereum USDC, it must be on Polygon)
- A small amount of MATIC — Polygon's native token, used to pay for gas fees (a few dollars' worth is enough)
- A private Polygon RPC endpoint from a service like Alchemy or Infura. The free public RPC can be unreliable. Both services have free tiers.
If you have Git installed:
git clone https://github.com/Obsidian-Trades/polymarket-copy-trading-bot.git
cd polymarket-copy-trading-botOr click the green Code button on GitHub and choose Download ZIP, then unzip it.
Open a terminal inside the project folder and run:
npm installThis downloads all the libraries the bot needs. It may take a minute.
On Mac/Linux:
cp .env.example .envOn Windows (PowerShell):
Copy-Item .env.example .envThis creates a file called .env where you'll put all your private settings. This file stays on your computer only — it is never uploaded anywhere.
Open .env in any text editor (Notepad, VS Code, etc.) and fill in your details. See the configuration section below for a full explanation of every setting.
npm startThat's it! The bot will start logging activity to your terminal and to a file called bot.log.
Your .env file controls everything. Here's what each setting means, explained in plain English.
These must be filled in or the bot won't start:
| Setting | What to put here |
|---|---|
PRIVATE_KEY |
The private key of your dedicated trading wallet. Looks like a long string of letters and numbers. Keep this secret! |
PROXY_WALLET |
Your Polymarket proxy wallet address. Find this in your Polymarket account settings. Starts with 0x. |
POLYGON_RPC |
Your RPC URL from Alchemy or Infura. Looks like https://polygon-mainnet.g.alchemy.com/v2/your-key-here. |
These control how aggressively the bot trades. Start with conservative (smaller) values.
| Setting | What it does | Beginner tip |
|---|---|---|
MAX_SPEND_PER_MARKET |
Maximum USDC to spend in one 5-minute market | Start with 5 (=$5) |
TARGET_EDGE |
Minimum profit margin before the bot buys. 0.02 means it needs at least 2 cents per dollar of edge. |
Higher = safer, fewer trades |
MERGE_THRESHOLD_USDC |
Minimum matched pair size before merging back to USDC | Leave at default to start |
MAX_TAKER_FILL_USDC |
Max size for a single buy order | Keep this small at first |
MAX_INVENTORY_IMBALANCE_USDC |
Stops the bot if one side gets too much larger than the other | Safety guardrail — leave it |
COMBINED_ASK_STOP |
Hard stop if the market price becomes unfavorable | Safety guardrail — leave it |
MAX_LOSS_PER_HOUR_USDC |
The bot stops if it loses this much in an hour | Set this to a number you're comfortable losing |
LADDER_LEVELS |
List of price points to post orders at on each side | Leave at default to start |
LADDER_SIZE_PER_LEVEL_USDC |
How much to put at each price level | Start small (e.g. 1) |
POLY_API_KEY=
POLY_API_SECRET=
POLY_API_PASSPHRASE=
Leave these blank on your first run. The bot will automatically generate them from your wallet. Only fill these in if you've been given credentials directly from Polymarket.
If you want to follow another trader instead of running the arb bot, use these settings.
| Setting | What it does |
|---|---|
TARGET_WALLET |
The Polymarket wallet address you want to mirror |
COPY_TRADE_BUY_PERCENT |
What percentage of their trade size to copy. 50 means you spend 50% of what they spend. |
COPY_TRADE_POLL_MS |
How often (in milliseconds) to check for new trades. 5000 = every 5 seconds. |
| Setting | What it does | Example |
|---|---|---|
COPY_TARGETS |
Comma-separated wallet addresses to follow | 0xabc...,0xdef... |
COPY_SIZE_MODE |
How to size your copy trades | FIXED (easiest for beginners) |
COPY_FIXED_USDC |
If using FIXED mode, how much to spend per copied trade | 2 |
COPY_MAX_USDC_PER_TRADE |
Hard cap per single trade | 5 |
COPY_MAX_USDC_PER_HOUR |
Maximum spend in any one hour | 20 |
COPY_MAX_USDC_TOTAL |
Total session spending limit | 50 |
COPY_MAX_SLIPPAGE |
Maximum price difference allowed vs. target's fill price | 0.05 = 5% |
COPY_STALE_MS |
Ignore trades older than this (milliseconds). Prevents copying old signals. | 10000 |
COPY_DRY_RUN |
Practice mode — logs what it would do without spending real money | Set to true first! |
npm startOr alternatively:
npm run arbSet TARGET_WALLET in your .env, then run the same command:
npm startThe bot will mirror future buys from that wallet while also running its own arb logic.
node src/copy/index.js💡 Always test copy trading with
COPY_DRY_RUN=truefirst until you're confident it's working the way you expect.
npm run dev.
├── .env.example ← Template for your settings — copy this to .env
├── package.json ← Project metadata and scripts
├── img/ ← Screenshots used in this README
└── src/
├── index.js ← Main entry point — starts everything up
├── trader.js ← Core arb logic (ladder posting, order management)
├── market.js ← Finds and tracks Polymarket markets
├── clob.js ← Handles communication with Polymarket's order book
├── onchain.js ← Blockchain interactions (approvals, merges, redeems)
├── copy-trader.js ← Integrated wallet-mirroring module
├── pnl.js ← Profit/loss tracking
├── logger.js ← Logging setup
└── copy/
├── index.js ← Entry point for standalone copy trader
├── activityFeed.js ← Watches target wallet for new trades
├── copyTrader.js ← Copy trade execution and risk checks
└── config.js ← Copy trader configuration loader
The bot outputs two streams of logs:
- Terminal (console): Color-coded logs so you can watch activity live
bot.logfile: Full JSON logs saved to disk for review later
Use bot.log to investigate any issues after a session — it contains full error details, order IDs, and timing info.
Your .env file is missing required fields. Open it and double-check that these are filled in (not blank):
PRIVATE_KEYPROXY_WALLETCOPY_TARGETS(if using copy trading)
- Make sure
PRIVATE_KEYmatches the wallet connected to your Polymarket account - Make sure
PROXY_WALLETis the correct proxy address for that account (not your main wallet address) - Try using a private RPC endpoint (Alchemy/Infura) instead of the default public one
- Leave
POLY_API_*fields blank — the bot will auto-generate them
- Check that target wallet addresses are all lowercase in your settings
- The target wallet must be placing new buy orders — the bot ignores sells and old fills
- Check that your spend caps (
COPY_MAX_USDC_PER_TRADE, etc.) aren't set to zero or too low - Make sure
COPY_DRY_RUNis set tofalseif you want real orders
- Make sure you have enough MATIC for gas fees
- The market must be fully resolved before you can redeem winnings
- Check
bot.logfor the full error message — it will tell you what went wrong specifically
Follow these steps your very first time:
- Created a separate, dedicated wallet for the bot
- Added a small amount of USDC on Polygon (start with $10–$20)
- Added a small amount of MATIC for gas (a few dollars is enough)
- Filled in
.envwith real wallet details - Set a private RPC endpoint (Alchemy or Infura free tier)
- Set
MAX_SPEND_PER_MARKETto a small value (e.g.5) - Set
MAX_LOSS_PER_HOUR_USDCto a number you're comfortable losing - If testing copy trading: set
COPY_DRY_RUN=truefirst - Ran the bot and reviewed
bot.logafter a session - Only scaled up after confirming everything works as expected
| Term | What it means |
|---|---|
| Polygon | A fast, low-fee blockchain where Polymarket runs |
| USDC | A stablecoin worth $1 USD, used for all Polymarket trades |
| MATIC | Polygon's native token, used to pay gas fees |
| Private key | A secret code that proves you own your wallet. Never share it. |
| Proxy wallet | A Polymarket-specific wallet that the platform uses on your behalf |
| RPC endpoint | A URL that lets software communicate with the blockchain |
| Gas fee | A small fee (in MATIC) paid to the Polygon network for every transaction |
| CLOB | Central Limit Order Book — Polymarket's order matching system |
| Arb / Arbitrage | Profiting from price differences in a market |
| Taker order | An order that buys immediately at the best available price |
| Merge | Combining matched Up+Down pairs back into USDC |
| Redeem | Claiming your USDC payout after a market resolves |
| Resolution | When a market closes and the winning outcome is determined |
This software is provided for research and use by experienced traders. It is not financial advice and does not guarantee profit. Real-money trading involves market risk, execution risk, smart contract risk, and operational risk. You are fully responsible for how you configure and use this software.
Built for Polymarket on Polygon. Not affiliated with Polymarket.




