ARCHITECTURAL COMPARISON · OHLCV CANDLES VS. L3 PRICE-TIME FIFO
VectorBT & Backtesting.py vs. C++23 L3 FIFO Order-Book Simulation
Vectorized Python libraries such as VectorBT and Backtesting.py are excellent tools for sweeping thousands of daily or hourly directional indicator combinations where orders cross the spread as takers on deep spot markets. They break down, however, the moment a strategy posts resting maker liquidity or trades discrete-tick Central Limit Order Books like Polymarket ($0.001 ticks) and Hyperliquid (Alo post-only perps).
| Execution Dimension | VectorBT / Backtesting.py (OHLCV) | Fera Terra (C++23 L3 Shadow-CLOB) |
|---|---|---|
| Passive Fill Rule | Fills 100% if bar low ≤ bid_price (Q_ahead = 0) |
✓ Fills only after contra volume clears queue_ahead_lots |
| Cancellation Latency | 0 ms instantaneous bar-boundary cancel |
✓ Holds canceled quotes matchable across Δt_cancel (0–250 ms) |
| Venue Wire Compatibility | Requires rewriting bot into DataFrame arrays | ✓ Unmodified py-clob-client, Hyperliquid SDK, Rust, or Go binary on :8085 |
| Venue-Specific Physics | Flat percentage commission | ✓ Polymarket ERC-1155 splits + p(1−p) fees; Hyperliquid Alo & funding |
Why low ≤ bid_price Creates Selection Bias
Suppose 10,089 shares rest ahead of your 150-share Polymarket bid at $0.421. Two market regimes occur:
- Benign touch-and-bounce:
200shares trade at$0.421and price reverts to$0.440. Barlowequals$0.421, so an OHLCV backtester credits you a winning maker fill. On the real FIFO queue,9,889shares remained ahead of you — your fill was0. - Toxic news sweep: FOMC headlines print and
45,000shares dump through$0.421 → $0.180while your cancel takes140 ms. Both the backtester and mainnet fill you100%— straight into an instant markout loss.
Workflow: Screen Signals in VectorBT, Gate Execution in Fera Terra
pip install feraterra feraterra benchmark \ --pack polymarket_news_shock \ --bot my_polymarket_bot.py \ --cancel-latency-ms 140 \ --html-out fifo_vs_naive.html