Crypto Market Data Collection and Display: Engineering Practices
A reliable crypto market data service requires consistent quote definitions and coordinated collection, processing, storage, and presentation. This article covers quote snapshot fields, streaming and polling strategies, rolling-window calculations, tiered storage, frontend updates, and observability practices for keeping real-time market data accurate and usable.
1. Quote Snapshot Structure and Field Semantics
In crypto trading, a minimally useful quote snapshot typically includes the following fields:
- Asset identifiers: Asset symbol, trading pair—such as a spot pair quoted in a USD-denominated stablecoin—and market type, such as spot or derivatives.
- Prices: Latest traded price, 24-hour opening price, and the highest and lowest prices within the reporting window.
Price changes: Absolute price change and percentage change, calculated as:
Percentage change = (Latest price − Opening price) / Opening price × 100%Market size: Circulating market capitalization and market-cap rank.
- Metadata: Quote currency and data update timestamp.
For example, a major public-blockchain asset might move from 70.73 to 73.45 within a typical 24-hour window, reaching a high of 74.17 and a low of 70.09. Its percentage change would be approximately 3.86%, with a market capitalization of about $43.36 billion and a market-cap rank of seventh.
Although this snapshot contains only a dozen or so fields, each field has a specific time window and calculation basis. Engineering implementations must align these definitions to avoid inconsistent frontend and backend values or drifting metrics.
2. Designing the Data Collection Layer
Collection is the first stage of the market data pipeline. Common sources include public exchange APIs, real-time WebSocket feeds, and third-party data aggregators.
Three considerations are especially important:
- Combine streaming with polling. Use persistent streaming connections for latency-sensitive data, such as the latest price and individual trades. Poll less frequently changing metrics, such as market-cap rankings, on a schedule—for example, once per minute—to reduce resource consumption.
- Normalize timestamps. Convert timestamps from all sources to UTC or another consistent time zone. Store both event time and reception time to help investigate latency and out-of-order data.
- Handle failures and reconnections. Persistent connections need heartbeat checks, reconnection with exponential backoff, and backfilling for data missed during disconnections.
A simplified collection routine looks like this:
on_message(msg):quote = normalize(msg) # Map fields and normalize unitsquote.recv_ts = now()mq.publish(topic="quote.raw", quote)cache.set(f"quote:{quote.symbol}", quote, ttl=10)
3. Real-Time Processing and Metric Calculation
Once raw market data reaches the processing layer through a message queue, the system performs several core tasks.
Rolling-Window Statistics
The 24-hour high, low, and opening price are rolling-window statistics. A sliding window with incremental updates can maintain these values efficiently.
For maximum and minimum prices, maintain monotonic queues containing values from the current window. Add new data and remove expired data as the window advances, achieving approximately O(1) amortized update complexity.
Consistent Percentage Changes
The displayed percentage change must correspond exactly to the opening price in the snapshot.
Calculate the value once on the server and deliver it with the snapshot rather than allowing each client to calculate it independently. This keeps results consistent across clients.
Market Capitalization and Rankings
Market capitalization is typically calculated as:
Market capitalization = Circulating supply × Latest price
Because circulating supply changes relatively infrequently, it can be cached and refreshed periodically. A scheduled task can sort the full set of assets by market capitalization and write their rankings back to the cache.
4. Storage and Query Architecture
Market data has typical time-series characteristics: heavy write volume, time-range queries, and clear differences between frequently accessed and archival data. A tiered storage design separates these workloads:
- Hot data: Store the latest snapshots in an in-memory key-value cache for millisecond-level reads by market overview and asset listing pages.
- Warm data: Store recent candlestick data and minute-level aggregates in a time-series database or wide-column store to support historical chart queries.
- Cold data: Archive historical detail records in object storage for offline backtesting and audits.
5. Frontend Display Considerations
User-facing market data requires careful formatting and update behavior.
Number Formatting
Adjust price precision dynamically according to the price magnitude. Display market capitalization using compact units such as billions or trillions. Format percentage changes to two decimal places and apply consistent red/green indicators for price direction.
Update Frequency and Throttling
Throttle high-frequency frontend updates—for example, by combining updates into one render every 500 ms. This reduces excessive repainting and helps prevent interface stutter.
Stale Data Indicators
If the latest update is older than a defined threshold, such as 30 seconds, show a “Delayed” or “Paused” status. Continuing to display an old price without a warning can mislead users.
6. Reliability and Observability
Market data services have demanding availability requirements. Build observability around three areas:
- Operational metrics: Monitor and alert on message latency, consumer lag, cache hit rate, and API P99 response time.
- Data quality checks: Validate invariants such as
High price ≥ Latest price ≥ Low priceand verify that percentage changes are consistent with the opening price. Route anomalous records to a dead-letter queue for manual review. - Gradual rollout and graceful degradation: Introduce new metrics to a small share of traffic first. If a data source fails, fall back to the most recent valid snapshot and clearly label its status.
Conclusion
A seemingly simple crypto quote depends on coordinated engineering across collection, transport, computation, storage, and display.
Rolling-window statistics, tiered caching, timestamp management, and data quality validation are reusable patterns. Once these foundations are in place, similar architectures can be adapted to real-time market data for equities, foreign exchange, and commodities.
