Skip to main content
Pro Feature. Requires a Pro or Ultra subscription. Get started at api.mathematicalcompany.com

Copy-Trading

Horizon’s copy-trading module monitors Polymarket wallets and automatically mirrors their trades through the Engine. It supports size scaling, position limits per market, deduplication, and an inverse mode for fading whale activity.
Copy-trading uses Polymarket’s public Data API (hz.get_wallet_trades()) to poll for new trades, then submits mirrored orders through the Horizon Engine with full risk pipeline protection. No access to the source wallet’s private key is needed.

When to Use What

Overview

Standalone Mode

hz.copy_trades() runs a blocking poll loop - the simplest way to start.

Pipeline Mode

hz.copy_trader() returns a pipeline function for use inside hz.run().

Inverse (Fade) Mode

Flip buy/sell to fade the whale’s trades instead of copying them.

Dedup + Watermarks

FIFO bounded dedup (10k capacity) with per-wallet timestamp watermarks prevents replaying history.

Standalone Mode: hz.copy_trades

The simplest entry point. Creates an Engine, seeds dedup state, and runs a blocking poll loop.
Behavior:
  1. Creates an Engine with the specified exchange backend
  2. Seeds dedup state from the last 100 trades per wallet (prevents replaying history)
  3. Polls get_wallet_trades() each cycle for new trades
  4. Filters by min size, valid price, and timestamp watermark
  5. Applies size scaling and position limit clamping
  6. Submits OrderRequest through the Engine (with full risk pipeline)
  7. Handles SIGINT/SIGTERM for graceful shutdown

Pipeline Mode: hz.copy_trader

For use inside hz.run() alongside other pipeline functions.
The pipeline function:
  • Uses ctx.params["engine"] for direct order submission (same pattern as arb_scanner)
  • Seeds dedup on first call only
  • Stores results in ctx.params["copy_trade_results"]
  • Returns None (bypasses the quote mechanism - orders are submitted directly)

Side Mapping

Copy-trading maps source trades to orders as follows: Inverse mode flips OrderSide only (Buy ↔ Sell). The Side (Yes/No) stays the same. This means inverse mode buys when the whale sells, and sells when the whale buys - fading their directional conviction.

Size Calculation

Orders are sized as follows:
For buy orders, the scaled_usdc is clamped to the remaining position limit:
The submitted price includes slippage protection:
  • Buy: min(0.99, source_price + max_slippage)
  • Sell: max(0.01, source_price - max_slippage)

Dedup Strategy

Copy-trading uses a FIFO bounded dedup set (same pattern as Polymarket/Kalshi fill dedup in the Rust core):
  • Primary key: tx_hash (falls back to wallet:condition_id:timestamp:size composite)
  • Capacity: 10,000 entries with FIFO eviction
  • Seeding: On startup, the last 100 trades per wallet are marked as seen
  • Watermark: Per-wallet timestamp - only trades newer than the last seen are processed

Data Types

CopyTraderConfig

CopyTradeResult

Each processed trade produces a result record:

Examples

Copy a Single Whale (Paper Mode)

Fade a Whale (Inverse Mode)

Copy Multiple Wallets

Pipeline Mode with Market Making

Live Trading with Risk Controls

Access Results in Pipeline

Copy-trading submits real orders when exchange="polymarket". Always test with dry_run=True or exchange="paper" first. Position limits and the risk pipeline provide safety guardrails, but you are responsible for monitoring your exposure. The copy-trader polls the public Data API, which may have a delay of a few seconds - you will not get the exact same fill price as the source wallet.