Six Strategies, One Risk Layer
A custom Polymarket trading engine in async Python
A trading team had signal ideas but no execution infrastructure. We built one async Python engine running six strategies on Polymarket, with every strategy's exposure capped.
What the trading team needed
Polymarket's prediction markets can be fragmented and inefficient: an opportunity only for a system that reacts fast and never loses track of its exposure. The team wanted copy trading, YES/NO arbitrage, Binance-driven signals and order-book strategies running at once under one risk layer. No off-the-shelf bot did that. We built a single asyncio service with shared position and exposure state and EIP-712-signed orders to the CLOB API, shipped as a Docker image. It runs six strategies concurrently, goes from signal to order in under a second, and recorded 99%+ uptime in production.
Constraints we had to design around
- 01
Protocol-level authentication
Orders need correct EIP-712 signatures and layered CLOB authentication. Small mistakes break the order flow entirely.
- 02
Strategies colliding on one market
Several strategies acting on the same market at once can double exposure. Shared state and pre-trade risk checks were mandatory.
- 03
Copy trading latency vs reliability
On-chain monitoring forces a choice between speed and confirmation. We chose confirmed blocks: reliability mattered more than theoretical speed.
- 04
Thin markets, false signals
A wide spread is often just weak liquidity, not an edge. The engine had to separate real mispricing from noise.
Architecture and what we shipped
- 01
One async engine, shared state
A single asyncio event loop. Each strategy runs independently while a shared state layer tracks positions, exposure and capital.
- 02
Wallet monitoring for copy trading
The engine watches selected Polygon wallets and mirrors qualifying trades once confirmed transactions appear on-chain.
- 03
Binance moves as external signals
Sharp BTC or ETH moves on Binance can reprice related Polymarket markets. The engine uses them as one input for entries.
- 04
Internal arbitrage scanner
Checks whether buying both YES and NO costs less than the guaranteed payout, and only acts when the gap covers execution risk.
- 05
Order-book strategy layer
Momentum, mean reversion, volume spikes and thin-book setups that react to order flow inside the market itself.
- 06
Risk split by strategy
Each strategy has its own capital budget, plus a market-level exposure cap. One bad run cannot consume the whole system.
Shipped in three phases
Core engine and authentication first, then signal strategies, then the order-book layer and final risk controls. Each phase ran in production before the next started.
-
Phase 1
Core engine and auth
Async architecture, CLOB integration, signatures, execution flow and Docker deployment
-
Phase 2
Signal strategies
Copy trading, Binance correlation and internal arbitrage on shared state
-
Phase 3
Order-book layer
Momentum, mean reversion, volume spike and thin-book logic, plus final risk controls
System performance
Strategies running concurrently inside one async engine
Signal-to-order latency, from event detection to order submission
Observed uptime during the production period
Questions about custom trading bots
Why build a custom trading bot instead of trading manually?
Useful windows in prediction markets are short. A bot watches many markets at once, reacts faster and applies the same rules every time, which a human cannot do across six strategies.
How does the copy trading part work?
The engine watches selected wallets on Polygon and reacts to confirmed transactions. It needs no private access to another trader's system, only public on-chain data.
Is YES/NO arbitrage on Polymarket risk-free?
No. The market can move between the first and second order. The engine only takes those trades when the price gap is large enough to cover that execution risk.
How do you stop several strategies from over-exposing one market?
Every strategy has its own capital budget, and a shared state layer enforces a market-level exposure cap before any order is sent. Strategies run independently but cannot exceed the global limits.
Can the architecture work for other exchanges or markets?
Yes. The strategy framework, shared state and risk layer are separate from the Polymarket integration. A new market needs a new integration layer, not a rewrite.
Your edge is the strategy. The execution engine is our job.
Bring the signal logic. We'll scope the engine, the risk layer and the integration, and quote a fixed price.