Data Feeds Professional-grade market data infrastructure - real-time streams, historical data, and analytics with sub-microsecond latency
Specification : LP-9004 Market Data Protocol | LP-9002 API Specification
LX provides institutional-grade market data feeds with Bloomberg/Refinitiv-level quality, sub-microsecond latency, and comprehensive coverage across all supported markets.
+------------------------------------------------------------------+
| LX DATA INFRASTRUCTURE |
+------------------------------------------------------------------+
| |
| Real-Time Feeds Historical Data |
| +---------------------------+ +---------------------------+ |
| | Order Book (L1/L2/L3) | | OHLCV Candles | |
| | Trade Tick Stream | | Tick-by-Tick Archive | |
| | Best Bid/Offer (BBO) | | Order Book Snapshots | |
| | Market Status Updates | | Funding Rate History | |
| +---------------------------+ +---------------------------+ |
| | | |
| v v |
| +---------------------------+ +---------------------------+ |
| | WebSocket Streams | | REST API / Bulk Download | |
| | Binary Protocol (gRPC) | | Parquet / CSV / JSON | |
| | Multicast UDP | | S3-Compatible Storage | |
| +---------------------------+ +---------------------------+ |
| |
+------------------------------------------------------------------+
Metric Specification Guarantee End-to-End Latency < 50 microseconds 99.9th percentile Tick-to-Trade < 2 microseconds GPU engine Order Book Updates < 100 nanoseconds Internal Data Freshness < 1 millisecond All feeds Uptime SLA 99.99% Monthly Message Throughput 10M+ messages/sec Per connection
All LX data follows strict schema standards for consistency and interoperability.
// All timestamps are Unix nanoseconds (int64)
interface Timestamp {
// Nanoseconds since Unix epoch (1970-01-01T00:00:00Z)
// Example: 1702339200000000000 = 2023-12-12T00:00:00Z
timestamp_ns : bigint
// Human-readable ISO 8601 (optional, for display)
timestamp_iso ?: string // "2023-12-12T00:00:00.000000000Z"
}
// Fixed-point decimal representation
interface Decimal {
// String representation for exact precision
value : string // "50000.12345678"
// Scaled integer (price * 10^decimals)
scaled : bigint // 5000012345678n
// Decimal places for this market
decimals : number // 8
}
// All prices use quote currency precision
// All quantities use base currency precision
BASE-QUOTE[-TYPE][-EXPIRY]
Examples:
BTC-USD # Spot
ETH-USDT # Spot
BTC-USD-PERP # Perpetual
BTC-USD-241227 # Future (Dec 27, 2024)
BTC-USD-C-50000 # Call option, strike 50000
import { LxDataClient } from '@luxfi/dex-data'
const client = new LxDataClient ({
endpoint: 'wss://data.lux.network/ws' ,
apiKey: process.env. LX_API_KEY
})
// Subscribe to order book
await client. subscribe ({
channel: 'orderbook' ,
symbol: 'BTC-USD' ,
depth: 25
})
// Handle updates
client. on ( 'orderbook' , ( update ) => {
console. log ( `${ update . symbol } bid: ${ update . bids [ 0 ]. price }` )
})
// Subscribe to trades
await client. subscribe ({
channel: 'trades' ,
symbol: 'BTC-USD'
})
client. on ( 'trade' , ( trade ) => {
console. log ( `Trade: ${ trade . price } x ${ trade . size }` )
})
# Get order book snapshot
curl -H "X-API-Key: $API_KEY " \
"https://api.lux.network/v1/data/orderbook/BTC-USD?depth=100"
# Get recent trades
curl -H "X-API-Key: $API_KEY " \
"https://api.lux.network/v1/data/trades/BTC-USD?limit=1000"
# Get OHLCV candles
curl -H "X-API-Key: $API_KEY " \
"https://api.lux.network/v1/data/candles/BTC-USD?interval=1h&limit=500"
import (
" github.com/luxfi/dex/pkg/data "
pb " github.com/luxfi/dex/pkg/data/proto "
)
client, err := data. NewClient ( & data . Config {
Endpoint: "data.lux.network:9760" ,
APIKey: os. Getenv ( "LX_API_KEY" ),
})
// Stream order book
stream, err := client. StreamOrderBook (ctx, & pb . OrderBookRequest {
Symbol: "BTC-USD" ,
Depth: 100 ,
})
for {
update, err := stream. Recv ()
if err != nil {
break
}
fmt. Printf ( "Bid: %s Ask: %s\n " , update.BestBid, update.BestAsk)
}
Channel Description Rate Limit ticker 24h rolling statistics 10 req/sec trades Public trade stream 100 msg/sec orderbook Order book updates 1000 msg/sec candles OHLCV candles 10 req/sec
Channel Description Requirements orders User's order updates API key fills User's trade fills API key positions Position updates API key balances Balance changes API key
Channel Description Tier orderbook_l3 Full order book with order IDs Professional trades_raw Unthrottled trade stream Professional liquidations Liquidation events Professional funding_predictions Predicted funding rates Enterprise
// Client must send ping every 30 seconds
// Server responds with pong containing server timestamp
// Ping
{ "type" : "ping" , "timestamp" : 1702339200000 }
// Pong
{ "type" : "pong" , "timestamp" : 1702339200001 , "server_time" : 1702339200000 }
const reconnectConfig = {
// Initial delay before first reconnect attempt
initialDelay: 100 , // ms
// Maximum delay between attempts
maxDelay: 30000 , // ms
// Exponential backoff multiplier
backoffMultiplier: 2 ,
// Add random jitter to prevent thundering herd
jitterFactor: 0.1 ,
// Maximum reconnection attempts
maxAttempts: 10
}
Tier WebSocket Connections Subscriptions per Connection Messages per Second Free 2 10 100 Standard 10 100 1,000 Professional 50 500 10,000 Enterprise Unlimited Unlimited 100,000+
All messages include sequence numbers for gap detection:
interface DataMessage {
// Global sequence (monotonically increasing)
sequence : bigint
// Channel-specific sequence
channel_sequence : bigint
// Timestamp of generation
timestamp_ns : bigint
}
// Request missing messages
{
"type" : "replay" ,
"channel" : "trades" ,
"symbol" : "BTC-USD" ,
"from_sequence" : 12345 ,
"to_sequence" : 12350
}
// Response includes all messages in range
{
"type" : "replay_response" ,
"messages" : [ ... ],
"complete" : true
}
All data is validated before distribution:
Price Sanity : Prices within 50% of reference
Timestamp Monotonic : Strictly increasing
Checksum Verification : CRC32 on order book state
Signature Verification : Cryptographic proof of origin
// Measure end-to-end latency
client. on ( 'message' , ( msg ) => {
const now = Date. now () * 1_000_000 // Convert to nanoseconds
const latency = now - msg.timestamp_ns
metrics. recordLatency ( 'e2e' , latency)
})
{
"type" : "metrics" ,
"latency" : {
"p50_us" : 12 ,
"p95_us" : 45 ,
"p99_us" : 89 ,
"p999_us" : 234
},
"throughput" : {
"messages_per_sec" : 1234567 ,
"bytes_per_sec" : 45678901
}
}
Data Type Hot Storage Warm Storage Cold Storage Archive Tick Data 7 days 90 days 1 year 5 years OHLCV 30 days 1 year 5 years Unlimited Order Book 24 hours 30 days 1 year N/A Funding 30 days 1 year Unlimited Unlimited Analytics 7 days 90 days 1 year 5 years
Section Description Real-Time Feeds WebSocket streaming, connection management Historical Data REST API, bulk downloads, data formats Order Book L1/L2/L3 depth, snapshots, incremental updates Trades Trade stream, tick data, aggregations Candles OHLCV data, timeframes, custom intervals Funding Rates Perpetual funding, predictions, history Liquidations Liquidation events, large liquidations Analytics Open interest, volume, market statistics Data Export Bulk download, formats, scheduling