Introduction
On-chain trading is transparent. Every trade made by profitable DeFi wallets is publicly visible on the blockchain — the entry price, the size, the leverage, the exit. Nothing is hidden. This is a fundamental asymmetry that AI agents can exploit: while human traders might spend hours researching which wallets to follow, an agent can monitor hundreds of wallets simultaneously, parse every transaction in real time, and replicate trades within seconds of execution.
Copy trading is not new. Centralized exchanges like eToro popularized it for retail investors years ago. But on-chain copy trading offers something different: permissionless access to the trade history of every wallet on every major chain, with no intermediary required. An AI agent using Purple Flea's trading API can monitor profitable Hyperliquid traders, detect their positions as they open, and execute proportionally-sized replicas — fully automated, running around the clock.
What is Copy Trading?
Copy trading means following a profitable trader by mirroring their exact trade decisions. When they buy, you buy. When they sell, you sell. The key difference from signal following is that copy trading is systematic and automatic — there is no human making discretionary decisions about whether to follow each trade. The position sizes are typically scaled proportionally to your capital relative to the target trader.
The on-chain version of copy trading works like this:
- Identify a set of target wallet addresses with a demonstrably profitable track record
- Monitor those wallets in real time for new on-chain trade transactions
- When a target wallet executes a trade, parse the transaction to extract symbol, side, size, and leverage
- Replicate the trade in your own account at a proportionally scaled size
- Mirror exits and stop-losses as they occur
Finding Wallets to Copy
The hardest part of copy trading is identifying which wallets are worth following. On-chain history is available for everyone, but most profitable periods are the result of luck rather than skill. Rigorous filtering is essential.
Where to Source Candidates
- Hyperliquid leaderboard: Shows top traders by PnL over 7d, 30d, and all-time. A solid starting point for perpetuals copy trading.
- Nansen "Smart Money" categories: Nansen classifies wallets by behavior — DeFi whales, NFT collectors, yield farmers. The Smart Money label indicates wallets with consistently profitable on-chain activity.
- DeBank and Zapper portfolio trackers: Let you view the complete portfolio history of any wallet, including historical APY, protocol interactions, and realized gains.
- On-chain analytics tools: Dune Analytics dashboards can surface wallets with exceptional PnL in specific strategies or protocols.
Qualification Criteria
Before including any wallet in your copy set, apply strict criteria to separate skill from luck:
- ROI > 30% over the last 90 days — a meaningful performance bar
- Trade count > 50 in the measurement period — rules out single lucky trades
- Sharpe ratio > 1.0 — ensures returns are risk-adjusted, not just volatile
- Maximum drawdown < 30% — eliminates reckless high-leverage gamblers
- Recent activity: Exclude wallets that haven't traded in the last 14 days — strategies go stale
The Copy Trading Architecture
A production copy trading agent has four core components that run as a continuous loop:
- Wallet monitor: Polls on-chain transaction data for each target wallet every 30 seconds, detecting new trades as they occur
- Trade parser: Decodes the raw transaction to extract the symbol, side (long/short), size in USD, leverage used, and whether it is an open or close
- Size calculator: Scales the position proportionally to your capital. If the target trades $100K and your capital is $10K, the copy ratio is 0.1 — you take a $10K position for every $100K they take
- Executor: Submits the scaled trade to the Purple Flea trading API with appropriate risk controls applied
Python Copy Trading Agent
The following agent polls a target wallet every 30 seconds and replicates any new trades at 10% of the original size:
import requests
import time
TARGET_WALLET = "0xsmart_trader_address"
COPY_RATIO = 0.1 # Copy 10% of their position size
PF_KEY = "your-api-key"
HEADERS = {"Authorization": f"Bearer {PF_KEY}"}
def get_recent_trades(wallet: str, since_timestamp: int) -> list:
"""Get recent trades for a wallet via on-chain data"""
r = requests.get(
"https://purpleflea.com/api/v1/copy-trading/trades",
params={"wallet": wallet, "since": since_timestamp},
headers=HEADERS
)
return r.json()["trades"]
def copy_trade(trade: dict):
"""Replicate a trade at fractional size"""
r = requests.post(
"https://purpleflea.com/api/v1/trade",
json={
"symbol": trade["symbol"],
"side": trade["side"],
"size_usd": trade["size_usd"] * COPY_RATIO,
"leverage": min(trade["leverage"], 3), # Cap leverage at 3x
},
headers=HEADERS
)
return r.json()
def run_copy_trader():
last_check = int(time.time()) - 3600 # Start from 1 hour ago
while True:
trades = get_recent_trades(TARGET_WALLET, last_check)
for trade in trades:
result = copy_trade(trade)
print(f"Copied {trade['symbol']} {trade['side']} → {result}")
last_check = int(time.time())
time.sleep(30)
if __name__ == "__main__":
run_copy_trader()
Key points in this implementation: the since_timestamp parameter ensures you never process the same trade twice, the leverage cap at 3x protects against copying wildly leveraged positions, and the 30-second poll interval keeps latency low without hammering rate limits.
Risk Management for Copy Trading
Blindly copying any wallet is a fast path to losses. Copy trading still requires a disciplined risk framework applied on top of the copying logic:
- Maximum position per trade: Never allocate more than 5% of your portfolio to a single copy trade, regardless of the original size
- Lag protection: Skip any trade that is more than 5 minutes old. If the target bought BTC at $85,000 and the price is now $85,800, you are entering at a worse price than they did — the edge is gone
- Consecutive loss filter: Stop following a wallet if it records 3 consecutive losses. Even good traders have bad periods; systematic underperformance warrants review
- Leverage hard cap: Never copy leverage above 3x regardless of what the original trader used. Highly leveraged positions have liquidation risk even with small adverse moves
- Daily loss limit: Halt all copying for 24 hours if the copy portfolio loses more than 8% in a day
Lag is your biggest enemy. On-chain transactions are visible the moment they are submitted, but confirmation takes time. By the time your agent polls, parses, and executes, the market may have already absorbed the move. For high-frequency copy trading, use WebSocket connections to transaction mempool feeds instead of polling.
Building a Copy Trading Network with Escrow
Individual copy trading is just the beginning. A more sophisticated structure is a copy trading network: one agent generates alpha signals, and a network of follower agents copies those signals and shares a percentage of profits back to the signal provider.
Purple Flea's escrow API enables trustless profit sharing between agents. The signal provider registers a copy trading strategy on-chain. Follower agents subscribe and agree to a profit share percentage. When a trade closes in profit, the escrow contract automatically routes the agreed percentage to the signal provider — no manual settlement, no trust required.
This creates a market for on-chain alpha: profitable traders have an incentive to share signals because they earn a passive income from followers, and followers benefit from leveraging proven strategies. See our copy trading network documentation for the full architecture.
Conclusion
Copy trading is one of the most accessible entry points for AI agents entering financial markets. Rather than developing original alpha from scratch, agents can bootstrap with proven strategies by following the best on-chain traders — then progressively layer in their own signal logic as they accumulate performance data.
The keys to success are rigorous wallet selection (skill over luck), aggressive lag protection, disciplined position sizing, and continuous monitoring of the wallets you follow. A strategy that worked last month may not work next month.
Ready to build? Start with the copy trading API reference and the trading API docs. Register a free agent key at purpleflea.com/register.