Data Feeds

Professional-grade market data infrastructure - real-time streams, historical data, and analytics with sub-microsecond latency

Market Data Feeds

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.

Data Feed Overview

+------------------------------------------------------------------+
|                    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     |  |
|  +---------------------------+     +---------------------------+  |
|                                                                    |
+------------------------------------------------------------------+

Performance Specifications

MetricSpecificationGuarantee
End-to-End Latency< 50 microseconds99.9th percentile
Tick-to-Trade< 2 microsecondsGPU engine
Order Book Updates< 100 nanosecondsInternal
Data Freshness< 1 millisecondAll feeds
Uptime SLA99.99%Monthly
Message Throughput10M+ messages/secPer connection

Available Data Products

Real-Time Feeds

FeedUpdate FrequencyLatencyProtocol
Order Book L1On change< 10 usWebSocket, gRPC
Order Book L2On change< 25 usWebSocket, gRPC
Order Book L3On change< 50 usgRPC, Multicast
Trade StreamOn execution< 5 usWebSocket, gRPC
Candle StreamPer interval< 100 msWebSocket
Funding Rates8 hoursReal-timeWebSocket
LiquidationsOn event< 10 usWebSocket
Analytics1 second< 1 sWebSocket, REST

Historical Data

DatasetRetentionGranularityFormat
OHLCV CandlesUnlimited1s to 1MParquet, CSV
Tick Data5 yearsNanosecondParquet
Order Book Snapshots1 year1 minuteParquet
Funding HistoryUnlimited8 hoursCSV, JSON
Liquidation History2 yearsPer eventParquet

Data Schema Standards

All LX data follows strict schema standards for consistency and interoperability.

Timestamp Format

// 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"
}

Price and Quantity Format

// 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

Symbol Naming Convention

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

Quick Start

WebSocket Connection

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}`)
})

REST API

# 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"

gRPC Connection

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)
}

Data Channels

Public Channels (No Authentication)

ChannelDescriptionRate Limit
ticker24h rolling statistics10 req/sec
tradesPublic trade stream100 msg/sec
orderbookOrder book updates1000 msg/sec
candlesOHLCV candles10 req/sec

Authenticated Channels

ChannelDescriptionRequirements
ordersUser's order updatesAPI key
fillsUser's trade fillsAPI key
positionsPosition updatesAPI key
balancesBalance changesAPI key

Premium Channels

ChannelDescriptionTier
orderbook_l3Full order book with order IDsProfessional
trades_rawUnthrottled trade streamProfessional
liquidationsLiquidation eventsProfessional
funding_predictionsPredicted funding ratesEnterprise

Connection Management

Heartbeat Protocol

// 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 }

Reconnection Strategy

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
}

Connection Limits

TierWebSocket ConnectionsSubscriptions per ConnectionMessages per Second
Free210100
Standard101001,000
Professional5050010,000
EnterpriseUnlimitedUnlimited100,000+

Data Quality Guarantees

Sequence Numbers

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
}

Gap Recovery

// 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
}

Data Validation

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

Latency Monitoring

Client-Side Measurement

// 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)
})

Server-Side Metrics

{
  "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 Retention Policy

Data TypeHot StorageWarm StorageCold StorageArchive
Tick Data7 days90 days1 year5 years
OHLCV30 days1 year5 yearsUnlimited
Order Book24 hours30 days1 yearN/A
Funding30 days1 yearUnlimitedUnlimited
Analytics7 days90 days1 year5 years

Documentation Index

SectionDescription
Real-Time FeedsWebSocket streaming, connection management
Historical DataREST API, bulk downloads, data formats
Order BookL1/L2/L3 depth, snapshots, incremental updates
TradesTrade stream, tick data, aggregations
CandlesOHLCV data, timeframes, custom intervals
Funding RatesPerpetual funding, predictions, history
LiquidationsLiquidation events, large liquidations
AnalyticsOpen interest, volume, market statistics
Data ExportBulk download, formats, scheduling

SDK Support

LanguagePackageDocumentation
TypeScript@luxfi/dex-dataTypeScript SDK
Pythonlx-dex-dataPython SDK
Gogithub.com/luxfi/dex/pkg/dataGo SDK
Rustlx-dex-dataRust SDK
Javanetwork.lux.dex.dataJava SDK

Support