Market Data Collection and Parsing for Digital Assets: A Practical Guide

    This article walks through the structure of a digital asset market data snapshot and shows how to turn raw quotes into reliable data. It breaks down identifier, price, derived, and scale fields, explains the mathematical constraints between them, and provides validation code for four-price consistency, derived-value accuracy, and data freshness. It also outlines a four-layer pipeline, multi-source redundancy strategies, and tiered monitoring and alerting. Readers will learn how to build a trustworthy and traceable market data service.

    1. Reading Market Data Structure from a Single Snapshot

    A raw market data record can be abstracted as a typical market data entity: symbol SOL, trading pair SOLUSDT, market type CRYPTO, quote currency USD, last price 71.7, 24-hour change 0.4195, change percentage 0.588%, open price 71.28, high price 78.38, low price 70.02, market cap 42.54 billion, market cap rank 7, and update time 2026-11-24 13:13:39.

    These fields are not independent. They are bound by strict mathematical and semantic constraints. Understanding those constraints is the first step in building a market data service.

    1.1 Identifier Fields

    The symbol, trading pair, and market type together form the primary key dimensions. A trading pair is usually composed of a base asset and a quote asset. The market type distinguishes matching systems such as crypto assets, foreign exchange, and equities, preventing mismatches across markets.

    1.2 Price Fields

    The last price, open price, high price, and low price form the four core prices of a candlestick. The high price must be no lower than both the open and last prices, and the low price must be no higher than both. This is the most basic consistency check.

    1.3 Derived Fields

    The change and change percentage are derived from the last price and open price:

    1. change = last price - open price
    2. change percent = change / open price * 100%

    Plugging in the data: 71.7 - 71.28 = 0.42, which differs slightly from the 0.4195 in the snapshot; 0.4195 / 71.28 ≈ 0.5885%, which is close to 0.588%. The difference comes from price precision truncation and rounding. This suggests that derived fields should be recalculated from the raw prices rather than trusted directly from the upstream source.

    1.4 Scale Fields

    Market cap equals circulating supply multiplied by price, and market cap rank is the position when the entire market is sorted by market cap in descending order. Both are highly sensitive to price movements and are suitable as auxiliary dimensions for trend analysis.

    2. Data Quality Validation: Encoding Constraints as Code

    The most common market data failure is not missing data but “plausible-looking wrong values.” It is recommended to implement three types of rules in the validation layer: four-price constraints, derived-value consistency, and time freshness.

    1. def validate(snapshot, max_age_seconds=60, eps=0.01):
    2. errors = []
    3. o, h, l, c = snapshot.open, snapshot.high, snapshot.low, snapshot.last
    4. if not (h >= max(o, c) and l <= min(o, c)):
    5. errors.append("Four-price relationship violated")
    6. if abs((c - o) - snapshot.change) > eps:
    7. errors.append("Change value inconsistent with prices")
    8. if o <= 0 or abs(snapshot.change / o * 100 - snapshot.pct) > 0.05:
    9. errors.append("Change percentage calculation anomaly")
    10. if snapshot.age_seconds() > max_age_seconds:
    11. errors.append("Market data is stale")
    12. return errors

    Data that fails validation should not be silently discarded. It should be routed to a quarantine area and trigger an alert, making it easier to trace upstream issues.

    3. End-to-End Architecture: Collection, Buffering, Computation, and Serving

    A robust market data pipeline is typically divided into four layers. The collection layer handles multi-source pulling with rate limiting and backoff. The buffering layer uses a message queue to smooth peaks and support replay. The computation layer performs cleaning, derived metrics, and aggregation. The serving layer provides low-latency queries through caching.

    On Baidu AI Cloud, container platforms can host collection and computation tasks, a message queue can serve as the buffer, object storage can archive raw snapshots, and logging and monitoring services can cover observability. This forms a complete loop without building the entire infrastructure stack from scratch.

    4. Multi-Source Redundancy and Consistency Strategy

    A single data source carries risks of latency and incorrect values. A common engineering approach is “dual-source cross-check with median selection”: when the price difference between two sources exceeds a threshold, do not average them directly. Instead, mark the data as pending confirmation and recheck it after one cycle. For aggregate values such as market cap and rank, minute-level latency is acceptable; for the last price, second-level freshness is required.

    5. Monitoring and Alerting Design

    Three types of metrics are recommended: freshness (update delay), deviation (difference from a reference price), and completeness (field missing rate). Alert thresholds should be tiered. For example, a delay over 60 seconds is a warning, and over 300 seconds is critical, avoiding noise that drowns out real failures. All alerts should include the symbol, trading pair, and snapshot time to reduce diagnosis costs.

    6. Summary

    A seemingly simple market data record is backed by a constraint system covering identifier, price, derived, and scale fields. By explicitly encoding these constraints as validation rules, combined with a layered architecture, multi-source redundancy, and tiered alerting, error-prone raw snapshots can be transformed into trustworthy, traceable market data capabilities that can be served externally.