Data Sources
Real-Time Data
The WebSocket API provides real-time streaming data from exchanges.
Market Data
| Data Type | Source | Latency | Delivery |
|---|---|---|---|
| Order Book | Exchange WebSocket | < 100ms | Push (subscription) |
| Trades | Exchange WebSocket | < 100ms | Push (subscription) |
| Instruments | Exchange REST | On-demand | RPC query |
| Venues | Cadenza Platform | Static | RPC query |
Trading Data
| Data Type | Source | Delivery |
|---|---|---|
| Order updates | Exchange + Cadenza | Push (subscription) |
| Executions | Exchange | Push (subscription) |
| Portfolio | Exchange + Cadenza | Push (subscription) |
| Balances | Exchange | Push (subscription) |
Data Flow
┌──────────────┐ ┌──────────────┐ ┌──────────────┐
│ Exchange │────▶│ Cadenza │────▶│ Client │
│ WebSocket │ │ Server │ │ │
└──────────────┘ └──────────────┘ └──────────────┘
│ │ │
│ Market Data │ Aggregated & │
│ Order Updates │ Normalized Data │
│ Executions │ │
Order Book Updates
Order book data is streamed with incremental updates:
Initial Snapshot
When subscribing, you receive a full order book snapshot:
{
"type": "snapshot",
"bids": [["50000.00", "1.5"], ["49999.00", "2.0"]],
"asks": [["50001.00", "1.2"], ["50002.00", "0.8"]],
"timestamp": 1703052635110
}
Incremental Updates
Subsequent messages contain only changes:
{
"type": "update",
"bids": [["50000.00", "2.0"]],
"asks": [["50001.00", "0"]],
"timestamp": 1703052635200
}
- Quantity
"0"means remove the price level - Non-zero quantity means update or add the level
Trading Account Updates
Account updates are pushed in real-time:
Order Update
{
"type": "order",
"tradeOrderId": "770e8400-...",
"status": "FILLED",
"executedQuantity": "0.1",
"timestamp": 1703052635110
}
Balance Update
{
"type": "balance",
"symbol": "USDT",
"available": "10000.00",
"locked": "5000.00",
"timestamp": 1703052635110
}
Data Consistency
Sequence Numbers
Some channels include sequence numbers for ordering:
{
"seq": 12345,
"data": {...}
}
If you detect a gap in sequence numbers, re-subscribe to get a fresh snapshot.
Reconnection
After reconnection:
- Re-subscribe to all channels
- You'll receive fresh snapshots
- Rebuild local state from snapshots
Comparison: HTTP vs WebSocket
| Aspect | HTTP API | WebSocket API |
|---|---|---|
| Data freshness | On-demand | Real-time push |
| Order book | Snapshot only | Streaming updates |
| Order status | Polling required | Push notifications |
| Latency | Higher | Lower |
| Use case | Infrequent queries | Continuous monitoring |