- Language
- TypeScript
- Last commit
- 2h ago
- Forks
- 0
- Open issues
- 0
- Registry update
- Oct 14, 2026
Connect
npm + pypi$claude mcp add pmwallets-copytrade \ -- npx -y [email protected]
Environment variables
Nothing to configure — it works as is.
Security review
Review passedReviewed 28m ago.
- metadata
- scanned
- packages
- 2 checked
No findings.
Tools
This server runs on your machine, so its tool list is not fetched before install — the README below describes what it offers.
Polymarket copy-trading bot (Node.js / TypeScript)
A ready-to-run Polymarket copy-trading bot built on PMWallets: it follows the traders you subscribe to and mirrors their fills on the Polymarket CLOB with your own account, inside the limits you set.
pmwallets-copytrade on npm · 中文说明 · Python version: polymarket-copy-trading-bot-python ·
SDK: pmwallets-node
What the bot does
- You pick the traders on pmwallets.com: filter the board by the lower bound of the win-rate confidence interval, profit without the single best market, activity and style, then subscribe.
- The bot receives every fill of those traders over the PMWallets WebSocket, typically within a second of the
block (measured latency). Missed frames are detected (
session/seq) and replayed from the last fill handled, including everything that happened while the bot was down. - It mirrors them on Polymarket with your own account, inside the limits you set. Your keys never leave your machine; PMWallets never sees them and never places orders.
Quick start
# Node.js ≥ 20
npm install -g pmwallets-copytrade
pmwallets-copytrade init # writes config.yaml
export PMW_API_KEY=pmw_... # https://pmwallets.com/keys
pmwallets-copytrade run # dry-run: logs every decision, trades nothing
When the dry-run log looks right, switch to live:
mode: live
polymarket:
privateKey: ${POLY_PRIVATE_KEY} # signs your orders
signatureType: 3 # see "Set up a Polymarket account for the bot"
funderAddress: ${POLY_FUNDER_ADDRESS} # your Polymarket profile address (holds the USDC)
pmwallets-copytrade status prints open positions, today's spend and any order still being confirmed. If the bot
cannot establish by itself whether an order filled, it keeps the order's reservation (no further BUY can exceed
your limits because of it) and asks you: check polymarket.com and run
pmwallets-copytrade reconcile <key> --none or --filled <shares> --usdc <usdc> with the bot stopped. Every decision — including each skip and its
reason — is appended to pmw-data/decisions.<mode>.jsonl, and everything the bot prints also goes to pmw-data/bot.<mode>.log.
Something went wrong? Run pmwallets-copytrade diagnose and email the pmw-diagnose-<time>.json.gz it writes to
[email protected], with a line about what happened. The file has the bot's version, the check result, your
config with the keys removed, the state files and the newest logs and decisions. It contains no private key or API
key (they are removed by name, then by value from the whole file), but it does show your wallet addresses, the traders
you copy, your trades and your machine's IP. Never send config.yaml or .env themselves.
How it decides
The rules come from a copy-trading bot that ran live on Polymarket; each one is there because of a lost trade or a rejected order.
BUY (the trader bought)
- skip fills older than
maxFillAgeSec(a replay after downtime must not buy history), belowminTargetNotionalUsdc, or from a role you excluded; - one copy per trader transaction, one position per (trader, outcome), at most
maxBuysPerOutcomebuys into it (DCA),maxOpenPositionsPerTarget/maxOpenPositions/maxDailySpendUsdccaps; - the market must be open, accepting orders and not settle within
minSecondsToEndDate; - the best ask must sit in
[minPrice, maxPrice], be at mostmaxSlippageabove what the trader paid, and the book must holdminBookDepthUsdc; - order: fill-or-kill for an exact number of shares at the best ask (
orderSizeUsdc/ ask), rounded so the CLOB accepts it. Share-denominated on purpose — a USDC-budget market order can overfill.
SELL (the trader sold)
sellMode: allexits everything the bot bought following that trader in that outcome. Shares booked to another trader in the same outcome are never sold: the most it sells is your token balance minus what the other traders hold. If that comes to nothing, it stops and asks you to reconcile;- the exit is saved and retried (with backoff, across restarts) until the position is gone. Freshness does not apply: if the trader left while the bot was down, it still gets out;
- order: fill-and-kill at the best bid — a partial exit beats none, and the rest is retried.
Polymarket V2 markets (canary markets now; every new market from 2026-11-02)
- the same rules, on Polymarket's new exchange (ExchangeV3, with the shares held in PositionManager instead of
Conditional Tokens). Which exchange a market trades on comes from the CLOB market's
version, and it must agree with the shape of the outcome id (a V2 position id is not a hash). If they disagree — or the CLOB does not say for an id shaped like a V2 position — the BUY is skipped (skipped_market_version) and an exit is kept and retried: the bot never guesses which exchange to sign for; - combos (multi-leg parlays) are quoted by RFQ and never trade on the order book: always skipped (
skipped_combo); - they need approvals of their own — see the account section below.
Safety
- dry-run by default; live needs an explicit
mode: live; - at most once: a fill is marked decided in the state file before any order is sent, so a crash can miss a copy but never place it twice. One bot per data directory: a second instance refuses to start;
- no lost fills: every order is saved as pending before it is sent. An order the exchange reports as killed
(such replies have carried real partial fills) is looked up again by its order id with backoff until its fill —
or its absence — is certain, even across restarts. One that got no answer at all has no id to look up: if a
matching trade appears, the bot does not guess whose it is (it could be yours by hand, or another trader's copy)
and hands it to you to
reconcile; - resolved markets are swept every 10 minutes so they stop counting against the caps.
Where to run it. PMWallets' servers are in the United Kingdom, but Polymarket does not accept new API orders
from the UK, the US, Germany, France and several other countries
(Polymarket: geographic restrictions). Ireland (AWS
eu-west-1) is the nearest region where it does — close to our servers and to Polymarket's in London. check
reports whether your machine's region is allowed. Measured latency: https://pmwallets.com/latency.
One stream per account, and the bot comes first. PMWallets keeps one WebSocket per account. A connection made
with an API key (the bot) takes priority: the live-feed page on pmwallets.com never takes the stream from it — while
the bot is connected the page says so and stays off. Between two API connections the first one keeps the stream:
a second bot on the same account (another key, or the same bot started twice) is refused and stops with a clear error.
To move the stream to a new bot on purpose, set pmwallets.takeover: true on the new one — the old one is told it was
replaced and stops. A bot's own reconnects after a network drop never need this. When PMWallets restarts its stream
service the bot reconnects at once and replays anything it missed.
For AI agents and scripts
Besides run, the bot has one-off commands that print JSON, so an AI agent (or a script) can decide and trade by
itself — for example on the fills pmwallets watch --exec hands it. They use the same config; its mode decides:
dry-run simulates each order against the live order book and sends nothing, live trades.
pmwallets-copytrade market <tokenId> # question, outcomes, prices, order book
pmwallets-copytrade balance # USDC to trade, approvals
pmwallets-copytrade positions # open positions, value, PnL
pmwallets-copytrade trades --limit 20
pmwallets-copytrade order buy <tokenId> --usdc 5 --max-price 0.45 --key <eventId>
pmwallets-copytrade order sell <tokenId> --all --min-price 0.40 --key <eventId>:exit
pmwallets-copytrade mcp --config /abs/path/config.yaml # the same as MCP tools
- BUY is fill-or-kill;
--usdcis a ceiling (sized at the limit, so the order cannot cost more). SELL is fill-and-kill, capped at what the account holds. --keymakes retries safe: the key is written todataDirbefore the order is sent, and the same key never sends a second order. Use the fill'seventId.status: unknown(orverify: true) means the order may have filled — checktradesbefore sending another. Exit code 0 = filled or dry_run, 2 = not traded, 3 = unknown.- These orders are your own trades: the bot's books (positions, daily cap) do not count them. Don't sell with them what a running bot is holding for a target.
Configuration
pmwallets-copytrade init writes a commented config.yaml. ${NAME} in the file is replaced by the environment
variable NAME; a missing variable stops the bot at start-up. Invalid values are rejected at start-up, never
silently ignored.
Set up a Polymarket account for the bot (recommended)
Give the bot an account of its own, holding only what you are willing to let it trade. This is the setup we recommend and document; follow it step by step:
This setup has been tested with real money — a MetaMask (or other browser-wallet) account connected on polymarket.com, signing with that wallet's own private key. Accounts made with email or Google, the older Safe / Proxy accounts and plain wallets are supported by the code, but we have not run them live. If you can, make a new account as below rather than reusing one of those.
- Create a new wallet account in MetaMask (or Rabby): account menu → Add account. Use it for nothing but this.
- Sign up on polymarket.com by connecting that wallet (choose MetaMask in the
sign-in dialog). Every account created on polymarket.com since 2026-05-04 gets a Deposit Wallet — that is
signatureType: 3. - Deposit a small amount on polymarket.com (Deposit). The balance polymarket.com shows is what the bot trades.
- Copy two values:
funderAddress— the account wallet address in the polymarket.com profile menu (not the MetaMask address);privateKey— the key of the MetaMask account from step 1 (MetaMask → Account details → Show private key). Put it in an environment variable, never inconfig.yaml.
- Configure
signatureType: 3,privateKey: ${POLY_PRIVATE_KEY},funderAddress: ${POLY_FUNDER_ADDRESS}and runpmwallets-copytrade check. It places no order; it must show your balance and account may open positions. - Run in
mode: dry-rununtil the decision log looks right, then switch tomode: livewith a smallcopy.orderSizeUsdc.
Why a separate account: the private key the bot holds can move everything in that account, and copy trading should never be able to touch money you did not mean to put at risk. The key never leaves your machine.
Already have an account? Which type it is (polymarket.signatureType)
The first row, for an account signed up by connecting MetaMask or another browser wallet, has been tested
live. The other rows follow Polymarket's documentation but are untested with this bot: run check, then
dry-run, then live with a very small copy.orderSizeUsdc, and tell [email protected] if anything fails.
The type decides which key signs your orders and which address holds the money (Polymarket: wallet types). It has no default — the bot refuses to trade until you set it, because signing as the wrong type gets every order rejected.
signatureType | Your account is this if… | privateKey | funderAddress |
|---|---|---|---|
| 3 · Deposit Wallet ✅ tested | it was created on polymarket.com on or after 2026-05-04 by connecting MetaMask or another browser wallet | that browser wallet's key | the account wallet in the profile menu (not the MetaMask address) |
| 3 · Deposit Wallet (untested) | it was created on polymarket.com on or after 2026-05-04 with email or Google | the key polymarket.com lets you export for the account's sign-in wallet | the account wallet in the profile menu |
| 2 · Safe Wallet | it was created before 2026-05-04 by connecting MetaMask, Rabby or another browser wallet | that browser wallet's key | the account wallet in the profile menu (not the MetaMask address) |
| 1 · Proxy Wallet | it was created before 2026-05-04 with email or Google (Magic) | the Magic key polymarket.com lets you export (look for Export Private Key in the settings) | the account wallet in the profile menu |
| 0 · plain wallet | you trade from your own address, with the funds on that address, not through a polymarket.com account | that address's key | the same address (may be omitted) |
A plain wallet (type 0) must also approve Polymarket's exchange contracts on-chain before its first trade — the bot does not do this for you (see Polymarket's approval example). Accounts made on polymarket.com (types 1–3) are set up by Polymarket.
Polymarket V2 markets need two more approvals: the approvals above do not cover ExchangeV3
(0xe3333700cA9d93003F00f0F71f8515005F6c00Aa). To buy, pUSD (0xC011a7E12a19f7B1f670d46F03B03f3342E82DFB) must
approve ExchangeV3; to sell, PositionManager (0x006F54F7f9A22e0000CC2AB60031000000ae9fEF) must
setApprovalForAll(ExchangeV3, true) (Polymarket: V2 migration).
A plain wallet sends both itself (the example above does not include them yet); on an account made on
polymarket.com, accept the approval prompt polymarket.com shows. check reports the pUSD approval for ExchangeV3 on a
line of its own. It cannot see the PositionManager one: without it, SELLs in V2 markets are rejected and retried.
Whatever the type, run pmwallets-copytrade check before mode: live. A balance of $0 while polymarket.com shows
money means the type or the address is wrong. Polymarket also restricts trading from some regions; check reports
when the account may only close positions.
All options
| Key | Default | What it does |
|---|---|---|
mode | dry-run | dry-run logs every decision and simulates fills at the best price on the book; live sends real orders. |
pmwallets.apiKey | — (required) | Your PMWallets API key (pmw_…, from pmwallets.com/keys). |
pmwallets.baseUrl | https://api.pmwallets.com | PMWallets API endpoint. |
pmwallets.takeover | false | Take the account's fill stream over from whichever client holds it (that client stops). Default: refuse to start next to it. |
polymarket.signatureType | — | Account type 0–3, see above. No default: required for mode: live and check. |
polymarket.privateKey | — | Key that signs your orders. Required in live mode. |
polymarket.funderAddress | — | Address that holds your funds. Required in live mode unless signatureType is 0. |
polymarket.apiKey / apiSecret / apiPassphrase | derived | Polymarket CLOB API credentials; derived from privateKey at start-up when absent. |
polymarket.clobUrl | https://clob.polymarket.com | Polymarket CLOB endpoint. |
targets | [] | Entities to copy (0x address, or board handle once you own the address). Empty = every entity your account subscribes to. |
targets[].orderSizeUsdc | copy.orderSizeUsdc | Per-target order size. |
targets[].maxBuysPerOutcome | copy.maxBuysPerOutcome | Per-target cap on BUYs into one outcome. |
copy.orderSizeUsdc | 10 | USDC spent on each copied BUY, converted to shares at the best ask and rounded down to a size the CLOB accepts. |
copy.roles | [taker, maker] | Copy the target's taker fills, maker fills, or both. Taker fills are easier to follow. |
copy.maxBuysPerOutcome | 3 | Copy up to this many BUYs into the same outcome (averaging in), then only hold. |
copy.maxOpenPositions | 20 | Outcomes held at once across all targets (unconfirmed BUYs count). |
copy.maxOpenPositionsPerTarget | 5 | Outcomes held at once per target. |
copy.maxFillAgeSec | 60 | A target BUY older than this when it reaches the bot is not copied (a replay after downtime must not buy history). SELLs are never too old. |
copy.minTargetNotionalUsdc | 25 | Ignore target BUYs smaller than this. |
copy.minPrice / copy.maxPrice | 0.05 / 0.95 | Only BUY when the best ask is inside this band. |
copy.maxSlippage | 0.03 | Skip if the best ask is more than this above the target's price (0.03 = 3 cents). |
copy.minBookDepthUsdc | 50 | Skip if the side we take holds less than this much USDC. |
copy.minSecondsToEndDate | 60 | Don't BUY a market that settles sooner than this. |
copy.maxSecondsToEndDate | 0 | Don't BUY a market that settles later than this; 0 = no limit. |
copy.sellMode | all | all: when the target sells, exit what the bot bought following that target in that outcome. none: hold to settlement. |
risk.maxDailySpendUsdc | 200 | Total USDC of copied BUYs per UTC day, unconfirmed orders included; 0 = no limit. |
dataDir | ./pmw-data | Where the state, stream cursor, lock file and decision log live. |
Commands, environment and files
pmwallets-copytrade init [file] | Write the example config. |
pmwallets-copytrade run [--config file] [--json] | Start the bot (--json: one JSON log line per event). |
pmwallets-copytrade check [--config file] | Verify the trading setup without trading: key, subscriptions, account type, balance, restrictions. |
pmwallets-copytrade status [--config file] | Open positions, today's spend, orders still being confirmed, exits being retried. |
pmwallets-copytrade reconcile [<key> --none | <key> --filled <shares> --usdc <usdc>] | Settle an order the bot could not verify by itself. Run with the bot stopped. |
pmwallets-copytrade diagnose [--config file] | Write pmw-diagnose-<time>.json.gz for support (no keys; see above). |
pmwallets-copytrade --version | Print the version. |
HTTPS_PROXY / HTTP_PROXY / NO_PROXY | Honoured for the PMWallets API, the WebSocket and the Polymarket CLOB. |
<dataDir>/state.<mode>.json | Positions, decided fills, orders being confirmed, pending exits, today's spend. |
<dataDir>/stream.<mode>.json | Where the fill stream resumes after a restart. |
<dataDir>/decisions.<mode>.jsonl | Every decision, including each skip and its reason. Rotated at 20 MB, 5 old pieces kept (.1 … .5). |
<dataDir>/bot.<mode>.log | Everything run prints, one JSON line per event, starting with the version. Rotated at 10 MB, 5 old pieces kept. |
<dataDir>/lock.<mode> | One bot per data directory and mode. |
Development
npm install
npm test
npm run build
The same config.yaml, state files and lock file work with the Python version. testdata/ holds the
contract cases both implementations must pass — keep it identical in both repositories.
Using PolymarketGateway as a library: buyFok, sellFak and tokenBalance take an optional last argument v2.
true trades a Polymarket V2 position through ExchangeV3; omitted or false keeps the CTF path, so code written before
V2 works unchanged for CTF tokens. A V2 position id without true, or a combo id with any value, is refused before
anything is signed or sent (tokenBalance throws). The Exchange interface carries the same optional argument.
Token ids must be canonical decimal strings — no hex, sign, whitespace or leading zeros: every gateway method refuses
any other form before a lookup or the SDK sees it, and the bot skips such a fill (skipped_invalid_token_id).
Resources
- Polymarket smart-money leaderboard — profitable Polymarket traders scored from the Polygon chain, with win-rate confidence intervals
- Polymarket copy trading guide — which wallets are worth following and how to get their fills in time
- How to learn from Polymarket smart money — reading a trader's record: confidence intervals, maker vs taker, market specialism
- PMWallets API documentation — WebSocket and webhook fill push, fills replay, trade-history exports
- Measured fill-push latency — block-to-push p50 / p95, published live
- Ways to follow Polymarket wallets, compared — official leaderboard, free trackers, SQL dashboards
- FAQ · 中文站
Guides
- How to set up a Polymarket copy-trading bot — a dedicated account, a region Polymarket accepts orders from, dry-run first
- Polymarket copy-trading risks — price moving before your order, competing for the same book, copying makers, fees, missed exits
- Backtest copy trading before risking money — a trader's fill history plus your real delay, slippage and fees
- Polymarket order types: GTC, GTD, FOK and FAK — and which a bot should use
- How to spot a market maker — and why not to copy one
- Luck or skill? — take away the best market and look again
- Polymarket win rate — why 100% means nothing without a sample size
- Polymarket leaderboards by category — sports, crypto, politics, esports and more, ranked from on-chain PnL
- Busiest Polymarket markets — the 1,000 most-traded markets of the last 30 days and how their traders did
- All guides · llms.txt
Proxies
HTTPS_PROXY / HTTP_PROXY / NO_PROXY are honoured for the PMWallets API, the WebSocket and the Polymarket CLOB.
Disclaimer
This software places real orders with real money when mode: live. A copied order is not the trader's order: the
price may have moved, fees apply and liquidity is shared. Past results do not predict future ones. PMWallets
provides data about what traders did, not advice. Use at your own risk; see LICENSE (MIT).
From the server's repository — third-party content, read it before running anything it suggests.
More in Finance
Korea Tax Calculator
io.github.UpstageAI
Korean tax calculation and tax-audit judgment MCP: 41 tools with statutory citations.
flipzi-mcp
io.flipzi
Trading card prices, sold comps, history and movers from the Flipzi Data API. Bring your own key.
e-arveldaja-mcp
io.github.iseppo
Estonian e-arveldaja (RIK e-Financials) accounting — invoices, bank import, reports.
Cue
io.github.murtazox04
Notify people through Cue: preferences, attention budgets, quiet hours and approval apply.
openInvest
io.github.longsizhuo
Investment runtime for AI agents — LLM investment committee, portfolio ledger, decision accounting
Particles
org.linkedparticles
An append-only ledger of sourced, dated, confidence-scored claims your agent cites and you audit
Listing from the official MCP Registry · repository facts from GitHub, 30m ago.