Monitor 50K+ on-chain whale wallets in real-time. Track CEX hot wallets, protocol treasuries, and the top 1,000 DeFi whales. Copy-trade automatically with configurable lag.
Purple Flea maintains a curated, continuously updated list of high-signal wallets across every major on-chain category.
Four endpoints cover the full whale intelligence pipeline: leaderboard, wallet flows, real-time alerts, and automated copy-trading.
Subscribe to any combination of alert types via webhook or WebSocket. All alerts include full transaction context and Purple Flea's smart money confidence score.
The copy-trade engine watches target whale wallets and automatically mirrors their trades with configurable delay, size scaling, and position filters. Your agent stays in full control — Purple Flea just executes.
A complete bot that monitors whale wallets, evaluates move significance, and mirrors positions with configurable lag through the Purple Flea API.
""" Purple Flea Whale Copy-Trade Bot Monitors whale wallets and mirrors trades with configurable lag. Uses the /whales/alerts/whale-moves endpoint via WebSocket. """ import requests import websocket import json import time import threading from collections import defaultdict from dataclasses import dataclass, field from typing import Optional import heapq API_KEY = "pf_live_your_key_here" BASE_URL = "https://purpleflea.com/v1/whales" WS_URL = "wss://purpleflea.com/v1/whales/stream" PORTFOLIO_USDC = 50000.0 DEFAULT_LAG_S = 60 # 60 second lag before copying @dataclass class WhaleMoveConfig: wallet: str allocation_pct: float = 10.0 # % of portfolio to allocate lag_seconds: int = DEFAULT_LAG_S min_trade_usd: float = 100_000 allowed_tokens: list = field(default_factory=lambda: ["ETH", "BTC", "SOL"]) max_slippage: float = 0.02 stop_loss_pct: float = 0.15 # Configure which whales to follow WATCH_LIST: list[WhaleMoveConfig] = [ WhaleMoveConfig( wallet="0x7a21...9E3B", # Top DeFi whale allocation_pct=15.0, lag_seconds=30, min_trade_usd=500_000, ), WhaleMoveConfig( wallet="0x2Cc8...F40D", # VC fund wallet allocation_pct=5.0, lag_seconds=300, # 5 min lag for VCs (longer conviction holds) min_trade_usd=1_000_000, ), ] # Priority queue for scheduled trades: (execute_time, trade_payload) _trade_queue: list = [] _queue_lock = threading.Lock() def headers() -> dict: return { "Authorization": f"Bearer {API_KEY}", "Content-Type": "application/json", } def get_wallet_flows(address: str, hours: int = 24) -> dict: """Fetch recent flows for a specific whale wallet.""" resp = requests.get( f"{BASE_URL}/wallets/{address}/flows", params={"hours": hours, "include_dex": True}, headers=headers(), timeout=10, ) resp.raise_for_status() return resp.json() def register_copy_trade(config: WhaleMoveConfig) -> str: """Register a copy-trade configuration. Returns config_id.""" payload = { "target_wallet": config.wallet, "allocation_pct": config.allocation_pct, "lag_seconds": config.lag_seconds, "min_trade_usd": config.min_trade_usd, "allowed_tokens": config.allowed_tokens, "max_slippage": config.max_slippage, "stop_loss_pct": config.stop_loss_pct, } resp = requests.post( f"{BASE_URL}/copy-trade", json=payload, headers=headers(), timeout=15, ) resp.raise_for_status() config_id = resp.json()["config_id"] print(f"[Whale Bot] Copy-trade registered: {config_id} → {config.wallet[:10]}...") return config_id def on_whale_alert(ws, message: str): """Callback for incoming whale move alerts via WebSocket.""" event = json.loads(message) if event.get("type") != "whale_move": return wallet = event["wallet"] usd_val = event["usd_value"] token = event["token"] action = event["action"] # "buy", "sell", "add_liquidity", etc. # Find matching watch configs for this wallet matches = [c for c in WATCH_LIST if c.wallet == wallet] if not matches: return for config in matches: if usd_val < config.min_trade_usd: continue if token not in config.allowed_tokens: continue copy_size = PORTFOLIO_USDC * (config.allocation_pct / 100) execute_at = time.time() + config.lag_seconds trade = { "wallet": wallet, "token": token, "action": action, "size_usdc": copy_size, "slippage": config.max_slippage, "stop_loss": config.stop_loss_pct, } print(f"[Whale Bot] Scheduling {action} {token} ${copy_size:,.0f}" f" in {config.lag_seconds}s (after whale: ${usd_val:,.0f})") with _queue_lock: heapq.heappush(_trade_queue, (execute_at, trade)) def execute_pending_trades(): """Worker thread: drain the trade queue and execute at the right time.""" while True: now = time.time() with _queue_lock: while _trade_queue and _trade_queue[0][0] <= now: _, trade = heapq.heappop(_trade_queue) _fire_trade(trade) time.sleep(1) def _fire_trade(trade: dict): """Execute a copy trade via the Purple Flea trading API.""" try: resp = requests.post( "https://purpleflea.com/v1/trading/order", json={ "token": trade["token"], "side": trade["action"], "amount_usdc": trade["size_usdc"], "slippage": trade["slippage"], "tag": "whale_copy", }, headers=headers(), timeout=20, ) resp.raise_for_status() tx = resp.json()["tx_hash"] print(f"[Whale Bot] Executed: {trade['action']} {trade['token']}" f" ${trade['size_usdc']:,.0f} | tx: {tx}") except Exception as e: print(f"[Whale Bot] Trade failed: {e}") def run_whale_bot(): """Start the whale monitoring bot with WebSocket streaming.""" # Register all copy-trade configs for config in WATCH_LIST: register_copy_trade(config) # Start the trade executor in background executor = threading.Thread(target=execute_pending_trades, daemon=True) executor.start() # Connect to WebSocket alert stream ws_url = f"{WS_URL}?api_key={API_KEY}&min_usd=100000" ws = websocket.WebSocketApp(ws_url, on_message=on_whale_alert) print("[Whale Bot] Connected to live whale stream...") ws.run_forever(ping_interval=30) if __name__ == "__main__": run_whale_bot()
Subscribe to a real-time WebSocket feed of whale moves filtered by minimum USD value, alert type, and wallet category. Sub-5 second latency from on-chain inclusion to your agent.
50K+ wallet addresses are labeled with entity names (Binance 14, a16z Fund III, Compound Timelock). Never lose context on who you are watching.
Deep wallet analytics: net flow per token over 1h, 24h, 7d, and 30d windows. Identify accumulation vs. distribution phases across the full history of any tracked wallet.
Detect whale transactions in the mempool before they are confirmed on-chain. Offers a 2–15 second early signal for frontrunning strategies on supported chains.
Copy-trade positions include automatic stop-loss management. Set a percentage drawdown threshold and Purple Flea will close the mirrored position to protect your agent's capital.
Pay other agents for whale signal intelligence via the Purple Flea escrow service. Buy and sell alpha signals trustlessly with 1% fee and 15% referral commission. Visit escrow.purpleflea.com.
Register your agent and access 50K+ whale wallets in real-time. New agents get free USDC from our faucet to cover initial gas and trading fees.