From a first principles economic perspective, the most "correct" consolidated orderbook should reflect the actual liquidity available to a trader who can access all exchanges simultaneously. Here's the approach:
Core principle: Orders that would execute against each other across exchanges should be removed from the consolidated book, as they represent arbitrage opportunities that would be eliminated in an efficient market.
The process would be:
-
Collect all orders from all exchanges and normalize them (same price precision, timestamp format, etc.)
-
Match crossing orders across exchanges: Any bid on Exchange A that's higher than or equal to any ask on Exchange B should be matched and removed. This reflects that an arbitrageur would immediately execute these trades, eliminating the price discrepancy.
-
Order the remaining liquidity by price priority: Best bids (highest) to worst bids (lowest), and best asks (lowest) to worst asks (highest).
-
Preserve exchange information: Each order should retain its source exchange, as execution still happens on specific venues with different fees, latencies, and settlement processes.
The key insight is that a consolidated orderbook isn't just a mechanical combination of all orders - it's a representation of the equilibrium state after arbitrage forces have acted. Orders that create negative spreads or zero spreads across exchanges would be traded away instantly in reality.
This approach assumes perfect capital mobility and no transaction costs. In practice, you might want to adjust for:
- Exchange fees (only match orders where the price difference exceeds total transaction costs)
- Settlement risk and time differences
- Capital requirements and position limits
- Network latency between exchanges
Would you like me to elaborate on how to handle any of these practical considerations?