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:
- Creates an Engine with the specified exchange backend
- Seeds dedup state from the last 100 trades per wallet (prevents replaying history)
- Polls
get_wallet_trades()each cycle for new trades - Filters by min size, valid price, and timestamp watermark
- Applies size scaling and position limit clamping
- Submits
OrderRequestthrough the Engine (with full risk pipeline) - Handles SIGINT/SIGTERM for graceful shutdown
Pipeline Mode: hz.copy_trader
For use insidehz.run() alongside other pipeline functions.
The pipeline function:
- Uses
ctx.params["engine"]for direct order submission (same pattern asarb_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:scaled_usdc is clamped to the remaining position limit:
- 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 towallet:condition_id:timestamp:sizecomposite) - 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