Demystifying Real-Time Market Data Systems: Collection, Computation, and Display of Cryptocurrency Prices

    This article delves into the engineering framework behind real-time cryptocurrency market data systems. It covers the calculation logic of core metrics like rolling 24-hour percentage change, market capitalization, and rankings. Furthermore, it details the data processing pipeline from ingestion to distribution, alongside key engineering challenges such as data consistency, timestamp precision, and high-concurrency push mechanisms. Readers will gain practical insights into building robust and scalable market data platforms.

    1. Starting from a Market Snapshot

    In the cryptocurrency market, the market information for any trading pair consists of a set of structured fields. Taking a snapshot of a trading pair at a specific moment, typical fields include: ticker symbol, trading pair identifier, market type, latest trade price, quote currency, 24-hour change amount and percentage, daily open price, highest price, lowest price, circulating market cap, market cap ranking, and data update timestamp.

    Looking at a set of sample data: the latest price is $0.09109, with a 24-hour increase of $0.002397, a gain of approximately 2.703%, an open price of $0.0887, a period high of $0.09369, a low of $0.0876, a market cap of approximately $91.6165 million, a ranking of 166, and an update time of 2026-11-24 14:40:39.

    Although these fields seem simple, achieving real-time, accurate, and scalable computation and display in a production environment involves a rigorous engineering system. This article analyzes this system architecture.

    1. Core Metrics and Calculation Logic

    2.1 Percentage Change Calculation
    The 24-hour percentage change is the most fundamental yet easily misunderstood metric in a market system. The common calculation method is the “rolling window” approach: using the current moment as the endpoint and tracing back 24 hours as the starting point, taking the trade price at that starting point as the base price. The formula is:

    Percentage Change = (Latest Price - Price 24 Hours Ago) / Price 24 Hours Ago × 100%

    Verifying with the sample data: 0.002397 / (0.09109 - 0.002397) ≈ 2.703%, indicating that the system uses a rolling 24-hour base price rather than a fixed UTC midnight open price. This is an industry-standard practice that avoids discrepancies caused by time zone issues.

    2.2 Open, High, and Low Prices
    The open price here generally refers to “the first trade price of the day (based on UTC or the daily cutoff time set by the exchange),” while the highest and lowest prices have two definitions: one is the daily interval statistics, and the other is the 24-hour rolling interval. When designing the system, the definition must be explicitly declared; otherwise, discrepancies may occur during frontend display and data reconciliation.

    2.3 Market Cap and Ranking
    Market Cap = Circulating Supply × Latest Price. Defining the circulating supply is a key challenge: locked tokens, unreleased team tokens, and burned portions should be excluded, counting only the tradable quantity. Market cap ranking requires periodic recalculation across the entire market, typically updated in batches every minute via a scheduled task, which is sufficient for display requirements.

    1. Data Collection and Processing Pipeline

    A typical market data system pipeline is as follows:

    3.1 Ingestion Layer: Subscribes to trade streams and order book snapshots for various trading pairs via market data push interfaces (primarily WebSocket long connections, with REST polling as a fallback). The ingestion layer must handle reconnection, heartbeat keep-alive, message deduplication, and out-of-order correction.

    3.2 Computation Layer: Aggregates K-lines and statistical metrics in real-time based on an in-memory sliding window structure. The schematic logic is as follows:

    1. class TickerWindow:
    2. def __init__(self):
    3. self.trades = deque() # (timestamp, price, volume)
    4. def on_trade(self, ts, price, vol):
    5. self.trades.append((ts, price, vol))
    6. cutoff = ts - 24 * 3600
    7. while self.trades and self.trades[0][0] < cutoff:
    8. self.trades.popleft()
    9. def stats(self):
    10. prices = [p for _, p, _ in self.trades]
    11. base = prices[0]
    12. last = prices[-1]
    13. return {
    14. "last": last,
    15. "high": max(prices),
    16. "low": min(prices),
    17. "change_pct": (last - base) / base * 100,
    18. }

    3.3 Storage Layer: Hot data (latest price, rolling window statistics) is stored in an in-memory database to ensure low-latency read and write; historical K-lines and trade details are written to a time-series database to support time-range aggregation queries; slow-changing data like market cap and rankings are periodically batch-processed and persisted.

    3.4 Distribution Layer: Broadcasts computation results to frontend push services, risk control systems, quantitative interfaces, and other consumers via message queues, achieving single computation and multi-party reuse.

    1. Key Engineering Challenges

    4.1 Data Consistency: Prices from multiple data sources may deviate, requiring weighted or optimal selection strategies and circuit breaker mechanisms for abnormal jumps (e.g., instant threshold deviations) to prevent “wick” data from polluting statistical metrics.

    4.2 Timestamps and Precision: All prices should use high-precision fixed-point numbers (e.g., strings or fixed-point integers) to avoid floating-point errors; time should uniformly use UTC millisecond timestamps, with localization conversion handled at the display layer.

    4.3 High-Concurrency Push: Market data update frequencies are extremely high. Frontend pushes should adopt incremental updates and merged pushes (e.g., merging snapshots once per second) to prevent message storms.

    4.4 Observability: Monitor latency, packet loss rate, and window aggregation correctness at each pipeline stage. Regularly use independent batch processing tasks to reconcile and verify real-time computation results.

    1. Conclusion

    The value of a market data system lies not in displaying a few numbers, but in ensuring that every percentage change and every market cap statistic is robust and verifiable through rigorous metric definitions, reliable data pipelines, and high-performance computing architectures. Understanding these four core concepts—rolling windows, metric consistency, high-precision computation, and incremental push—provides the methodology for building such systems. Whether for market display, quantitative research, or data platform construction, these practices offer direct reference value.