I started as a long-term investor who believed in DCA and compounding. Then I discovered Polymarket’s BTC Up/Down 5-minute markets — and got hooked on building a fully automated trading engine. Here’s the complete technical story: the architecture, the lessons, the failures, and the open-source result.
Why 5-Minute BTC Markets Are Deceptively Hard
Each slot has a “Price to Beat.” You bet whether BTC will close above or below it in the next 5 minutes. Sounds simple, but:
- Extreme volatility in tiny windows.
- Traditional indicators (RSI, MACD, EMA) lose edge.
- No true market orders — everything is limit orders via CLOB.
- Shares aren’t immediately sellable due to on-chain settlement delays.
I spent weeks staring at live order books before realizing humans can’t compete consistently.
Polymarket Under the Hood (Technical Deep Dive)
- Chain: Polygon (Ethereum L2) — low fees.
- Token Framework: Gnosis Conditional Tokens (ERC-1155). 1 USDC → 1 YES + 1 NO token. Full set always redeems to $1.
- Resolution: Chainlink price feeds (trustless, automatic for price markets).
- Trading Layer: Hybrid CLOB — off-chain matching engine + EIP-712 signatures + on-chain settlement via CTF Exchange.
- Order Lifecycle: Signed → MATCHED → MINED → CONFIRMED (this delay is critical for strategy design).
Understanding this flow prevented many “why can’t I sell immediately?” bugs.
Evolution of the Engine
v1 – “late-entry” (Event-Driven, Terminal UI)
- Real-time WebSocket order book subscription.
- Minimal REST calls.
- Signals based on RSI + ATR + cross-exchange price divergence (Binance, Coinbase, Chainlink).
- Hold-to-resolution only.
Result: ~95% win rate on paper, but painful losses on the remaining 5% because I couldn’t exit early.
v2 – “early-bird” (Lifecycle-Based, Extensible)
Built with heavy help from Claude Opus 4.6 + Plannotator.
Core Architecture:
- Every market runs as a lifecycle:
start → run → end. - Engine orchestrates multiple overlapping 5-min slots.
- Strategies are pluggable functions that receive engine APIs for placing/cancelling orders.
- Full simulation mode with realistic latency, partial fills, and confirmation delays.
- Rich logging + interactive chart visualizer for post-trade analysis.
This design made it easy to test, iterate, and swap strategies without touching core engine code.
Key Lessons Learned
- Exit discipline beats entry accuracy — Take profit early; don’t hold to resolution.
- Simulation must mirror reality — Include on-chain delays and order book dynamics.
- Order book is king — Price feeds help, but microstructure tells the real story.
- AI helps with architecture, not magic strategies — Context and domain knowledge still win.
- Emotions are expensive — Automation removed 90% of bad decisions.
Final Thoughts
I’ve made a few tens of thousands dollars so far, but the real win was the learning journey. Building this forced me to understand prediction market mechanics, blockchain settlement, order book dynamics, and disciplined strategy development.
If you’re interested in prediction markets, automated trading, or just want to explore Polymarket’s tech, the repo is a great starting point.
Check it out, fork it, and build your own edge.
If you have more questions, please feel free to contact me at any time: https://t.me/FatherSon97
Top comments (0)