Global Orderbook Module API
The Orderbook API provides real-time orderbook aggregation across multiple exchanges (Binance, Bybit, Gate.io, Kraken). It streams public orderbook data via WebSocket and provides quality metrics for each venue.Key Features
- Multi-venue aggregation: Subscribe to orderbooks across multiple exchanges simultaneously
- Quality metrics: Staleness, spread, depth, and confidence scoring per venue
- Global best prices: Find the best bid/ask across all venues
- Ref-counting subscriptions: Efficient resource management with warm cache
- No authentication required: Orderbook data is public
POST /oems/orderbook/subscribe
Subscribe to orderbook updates for one or more symbols on one or more venues.Request Body (JSON)
- symbols (array, required): List of trading pairs in CCXT format (e.g.,
["BTC/USDT", "ETH/USDT"]) - venues (array, required): List of exchange venues:
"binance","bybit","gateio","kraken"
Request Example
Response Examples
Success
Invalid Request
Subscription Status Values
| Status | Description |
|---|---|
pending | WebSocket connection in progress |
active | Receiving orderbook updates |
error | Connection failed |
warm_cache | Unsubscribed but still cached (5 min) |
POST /oems/orderbook/unsubscribe
Unsubscribe from orderbook updates. Subscriptions move to warm cache (5 minutes) before being fully closed.Request Body (JSON)
- symbols (array, required): List of trading pairs to unsubscribe from
- venues (array, required): List of exchange venues to unsubscribe from
Request Example
Response Example
GET /oems/orderbook/book
Get current orderbook data. Returns either a single venue’s book or a global aggregated view.Query Parameters
- symbol (string, required): Trading pair (e.g., “BTC/USDT”)
- venue (string, optional): Specific venue (omit for global view across all subscribed venues)
- venues (string, optional): Comma-separated list of venues to filter global view (e.g., “binance,gateio”). Use this to get a client-specific view of subscribed venues.
- depth (integer, optional): Number of orderbook levels to return (1-100). Default: 20
Request Examples
Response Examples
Single Venue
Global View
Not Found
Notes
- A negative global spread (best_bid > best_ask) indicates a cross-venue arbitrage opportunity
- Bids are sorted by price descending (best first)
- Asks are sorted by price ascending (best first)
GET /oems/orderbook/quality
Get quality metrics for all venues with orderbook data for a symbol.Query Parameters
- symbol (string, required): Trading pair (e.g., “BTC/USDT”)
Request Example
Response Example
Quality Levels
| Quality | Staleness | Description |
|---|---|---|
GOOD | < 500ms | Fresh data, reliable for execution |
DEGRADED | 500ms - 2s | Slightly stale, use with caution |
STALE | 2s - 5s | Old data, not recommended for execution |
UNAVAILABLE | > 5s | No recent updates, do not use |
Confidence Scoring
Confidence starts at 1.0 and is reduced by:- Staleness: Up to -0.4 (linear to 5000ms)
- Wide spread: Up to -0.2 (linear from 1bps to 20bps)
- Sequence gaps: -0.05 per gap, max -0.3
- If quality is
UNAVAILABLE: confidence = 0
GET /oems/orderbook/subscriptions
Get current subscription status and statistics.Request Example
Response Example
GET /oems/orderbook/stats
Get service statistics including store and subscription metrics.Request Example
Response Example
Supported Venues
| Venue | Update Rate | Notes |
|---|---|---|
| Bybit | ~28/sec | Highest update rate, excellent for HFT |
| Kraken | ~15/sec | Good update rate, reliable |
| Binance | ~9/sec | Standard rate, tightest spreads |
| Gate.io | ~8/sec | Good depth, slightly slower |
Typical Use Cases
1. Smart Order Routing (SOR)
2. Arbitrage Detection
3. Execution Quality Monitoring
WebSocket Streaming
Real-time orderbook streaming via WebSocket for low-latency updates.Connection
Connect to the WebSocket endpoint:Events
Client to Server
| Event | Payload | Description |
|---|---|---|
| subscribe_orderbook | symbol, venues, include_global, depth | Subscribe to orderbook stream |
| unsubscribe_orderbook | symbol | Unsubscribe from stream |
| get_snapshot | symbol, venues | Request current snapshot |
Server to Client
| Event | Payload | Description |
|---|---|---|
| connected | sid, message | Connection acknowledged |
| subscribed | symbol, venues, include_global, depth | Subscription confirmed |
| orderbook_snapshot | symbol, venues, timestamp | Initial snapshot with full depth |
| orderbook_update | venue, symbol, bids, asks, … | Per-venue update with depth |
| global_book | symbol, data, timestamp | Aggregated global view |
Subscribe Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
| symbol | string | required | Trading pair (e.g., “BTC/USDT”) |
| venues | array | all | Filter to specific venues |
| include_global | boolean | true | Include global best prices |
| depth | integer | 5 | Number of price levels: 1, 5, 10, or 20 |
JavaScript Example
Update Payload
Each update includes arrays of price and quantity pairs:- bids: Sorted by price descending (best first)
- asks: Sorted by price ascending (best first)
Python Example
Performance
- Update rate: 10-20 updates/sec per symbol
- Latency: Under 100ms from exchange to client
- Broadcast interval: 100ms (sends only changed data)
- Recommended depth: 5-10 for most use cases, 20 for detailed analysis

