Understanding Crypto Market Data Structures: From a Single Price Snapshot to Designing a General-Purpose Market Data System

    Crypto market data is the foundation of trading terminals, dashboards, quantitative analysis, and risk control systems. This article breaks down the fields of a typical market data snapshot—symbols, prices, price changes, and market cap—explains the calculation logic and common pitfalls (rolling 24-hour windows, division-by-zero, floating-point precision), and outlines a layered architecture for a robust market data system covering ingestion, computation, storage, and presentation, along with data quality and engineering best practices.

    1. Why Developers Should Take Market Data Seriously

    In digital asset systems, market data is one of the most fundamental and critical data types. Whether it’s a trading terminal, a data dashboard, quantitative analysis, or a risk-alerting system, everything rests on a unified, accurate, and latency-controllable market data layer.

    A typical market data snapshot contains the following fields (sample data, for structural illustration only):

    1. {
    2. "symbol": "XXXUSDT",
    3. "market_type": "CRYPTO",
    4. "last_price": 0.09019,
    5. "currency": "USD",
    6. "change_24h": 0.001798,
    7. "change_pct_24h": 2.034,
    8. "open": 0.08839,
    9. "high": 0.09268,
    10. "low": 0.08759,
    11. "market_cap": 89641800,
    12. "market_cap_rank": 168,
    13. "updated_at": "2026-11-24 13:23:36"
    14. }

    Let’s break down the meaning and technical considerations of each field.

    2. Semantics and Calculation Logic of Core Fields

    2.1 Identifier Fields: code, symbol, and market_type

    • code (token code): The shorthand name of a project’s token. It is usually unique within a single trading system, but name collisions do occur, so uniqueness checks should incorporate metadata such as the chain and contract address.
    • symbol (trading pair): A BASE_QUOTE combination representing a market priced in the quote currency. When parsing a trading pair, split on the delimiter rather than slicing by fixed length, so token codes of varying lengths are handled correctly.
    • market_type: Identifies the market category (e.g., crypto, stocks, forex). In multi-market aggregation systems, it is used to route data into different processing pipelines.

    2.2 Price Fields: Last Price, Open, High, and Low

    • Last price: The price of the most recent trade. It has the strictest real-time requirements and typically needs millisecond-level push delivery.
    • Open: The price at the start of the rolling 24-hour window. Note that crypto markets generally use a “rolling 24 hours” definition rather than a calendar-day open—a significant difference from traditional financial systems.
    • High/Low: The extremes within the rolling window. When implementing these, watch out for old data sliding out of the window; common approaches include maintaining a time series or using a monotonic queue.

    2.3 Price Change Fields

    The change amount and percentage are calculated as:

    1. change = last_price - open
    2. change_pct = change / open * 100

    In the example: (0.09019 - 0.08839) / 0.08839 ≈ 2.034%, which matches the given percentage. Be aware that when the open price is close to zero, there is a division-by-zero risk, and the code must guard against it.

    1. def calc_change_pct(last: float, open_: float) -> float:
    2. if open_ <= 0:
    3. return 0.0
    4. return (last - open_) / open_ * 100

    2.4 Market Cap Fields

    Market cap = circulating supply × last price, and the market cap rank reflects the asset’s relative size across the entire market. For display, values are usually formatted with localization in mind—for example, the frontend should dynamically select units (K/M/B) based on the user’s locale.

    3. General Architecture of a Market Data System

    A robust market data display system typically consists of the following layers:

    1. Data ingestion layer: Subscribe to real-time pushes via WebSocket, with REST polling as a fallback. Reconnection logic should implement exponential backoff and snapshot recovery.
    2. Computation layer: Maintain rolling-window statistics in memory (OHLC, price change, amplitude), paying careful attention to window boundary correctness.
    3. Storage layer: Keep hot data in an in-memory database and write historical candlesticks to a time-series store, partitioned by time for efficient aggregate queries.
    4. Presentation layer: Use colors and animations to indicate price direction; throttle numeric updates to prevent page jitter from high-frequency refreshes.
    1. // Example of throttling frontend price updates
    2. let pending = null;
    3. function onTick(price) {
    4. pending = price;
    5. }
    6. setInterval(() => {
    7. if (pending !== null) {
    8. render(pending);
    9. pending = null;
    10. }
    11. }, 300);

    4. Data Quality and Engineering Details

    • Timestamp alignment: Update times from different data sources may drift. When aggregating across sources, unify time zones and record latency metrics.
    • Precision handling: Never accumulate prices directly with floating-point arithmetic. Use fixed-point numbers or high-precision decimal types to avoid cumulative errors.
    • Outlier filtering: Wick data (price spikes) during extreme market conditions should be filtered with reasonable thresholds to prevent abnormal trades from contaminating high/low values.
    • Monitoring and alerting: Set up alert rules for feed latency, missing fields, and abnormal jumps in price change to safeguard data trustworthiness.

    5. Conclusion

    Market data may look like just a set of numbers, but behind it lie a series of engineering challenges: windowed computation, precision control, real-time delivery, and data quality. Mastering the precise semantics of these fields and the common implementation pitfalls is the first step toward building any digital asset market data system. In practice, developers should first establish a unified data contract (schema), then implement the computation and presentation logic layer by layer, ensuring the system remains maintainable and extensible.