The most-requested integration on Predexon. You pick a profitable wallet, watch every fill it does, and mirror those fills into your own account at a fraction of the size.
You’ll build:
- A WebSocket listener that fires on every trade by the target wallet
- A handler that translates target-wallet trades into your-account orders
- A scale-and-execute path that mirrors on the same venue
Endpoints used: 1 WebSocket channel + 2 Trading API endpoints. Runs on Dev plan or higher (WebSocket requires Dev+).
Architecture
Step 1 — Verify the target
Before mirroring, check they’re actually profitable. Pull the wallet profile:
import os, requests, time, json
from websockets.sync.client import connect
DATA = "https://api.predexon.com"
TRADE = "https://trade.predexon.com"
WSS = "wss://wss.predexon.com/v1"
KEY = os.environ["PREDEXON_API_KEY"]
H = {"x-api-key": KEY}
TARGET = "0xSmartTraderAddressHere"
ACCOUNT_ID = "your-account-id" # set up via builder-guide
profile = requests.get(f"{DATA}/v2/polymarket/wallet/{TARGET}", headers=H).json()
print(f"Profit: ${profile['realized_profit_usd']:,.0f} ROI: {profile['roi']:.1%}")
assert profile["realized_profit_usd"] > 50_000, "Target isn't profitable enough"
Re-run this check daily — wallets degrade.
Step 2 — Subscribe to their trades
The trades channel takes a users filter. You’ll receive every fill they take in real time, on both V1 and V2 Polymarket contracts.
def subscribe():
return json.dumps({
"action": "subscribe",
"platform": "polymarket",
"version": 1,
"type": "orders",
"filters": {"users": [TARGET]},
})
with connect(f"{WSS}/{KEY}") as ws:
ws.send(subscribe())
for raw in ws:
msg = json.loads(raw)
if msg.get("type") != "event":
continue
handle_trade(msg["data"])
Step 3 — Scale and mirror
The hardest part of copy-trading is sizing. Mirror their trade as a fraction of their original size, capped by your venue balance.
SIZE_RATIO = 0.10 # mirror 10% of their size
MAX_PER_TRADE_USD = 500
def handle_trade(trade):
# only mirror trades initiated by the target wallet (not against them)
if trade["user"].lower() != TARGET.lower():
return
# only follow buys; let me close on my own logic
if trade["side"] != "BUY":
return
target_shares = float(trade["shares_normalized"])
target_price = float(trade["price"])
notional = target_shares * target_price
# scale
mirror_shares = target_shares * SIZE_RATIO
mirror_notional = mirror_shares * target_price
if mirror_notional > MAX_PER_TRADE_USD:
mirror_shares = MAX_PER_TRADE_USD / target_price
# the target trades on Polymarket — mirror directly on the same token_id
resp = requests.post(
f"{TRADE}/api/accounts/{ACCOUNT_ID}/orders",
headers={**H, "Content-Type": "application/json"},
json={
"venue": "polymarket",
"market": {"tokenId": trade["token_id"]},
"side": "buy",
"type": "market", # or "limit" at target_price * 1.005
"size": f"{mirror_shares:.2f}",
},
).json()
print(f"Mirrored: {trade['token_id']} shares={mirror_shares:.2f} → {resp.get('status')}")
The example above mirrors on the same venue (Polymarket → Polymarket), which is the most reliable copy-trading path.
Step 4 — Run it under supervision
Things that will go wrong in production:
| Failure | Mitigation |
|---|
| WebSocket disconnect | Wrap the loop with reconnect + resume. See Subscriptions. |
| Mirror order fails (insufficient balance) | Catch the 400, alert yourself, top up the venue, don’t auto-retry. |
| Target sells before you fill | Use market orders + smaller size; or accept the slippage as part of the cost. |
| Target wallet changes strategy | Re-pull the wallet profile daily; pause mirroring if realized_profit drops. |
| You mirror a trade and they immediately reverse | Build a “follow exits too” version: also handle side: "SELL" to close mirrored positions. |
For the simplest possible production version, also subscribe to the activity channel to mirror splits, merges, and redemptions.
Variations
- Multi-wallet copy-trading: subscribe with
filters: {"users": [w1, w2, w3, ...]} and route each trade to the right end-user account in your DB.
- Filtered copy-trading: only mirror trades above a notional threshold, or in specific market categories.
- Agent-driven copy-trading: replace the WebSocket loop with the Agent Cookbook recipe 4, which polls and reasons about whether to mirror.
Reference