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

    This article walks through the practical engineering of collecting and parsing digital asset market data. Starting from a sample spot ticker snapshot, it covers building a field dictionary with explicit types and precision, documenting derived metrics such as change, change percentage, and amplitude, defining data quality validation rules at the pipeline entry, and handling timestamps and time zones consistently. It closes with a four-layer pipeline architecture and three engineering disciplines for keeping market data reliable. Readers will find concrete formulas, validation rules, and a normalized JSON example they can apply directly.

    1. Reading Data Structure from a Single Ticker Snapshot

    When building any market data system, the most basic input is usually a structured snapshot record. Take a spot trading pair as an example. Its fields can be abstracted as: asset code, trading pair identifier, market type, latest traded price, quote currency, 24-hour change amount and change percentage, open price, high price, low price, market capitalization, market cap ranking, and data update time. Sample values are: last price 0.081, open price 0.0799, high price 0.08379, low price 0.0783, 24-hour change of about 0.001099, change of 1.375%, market cap of about 27.8749 million, rank 460, market type crypto asset, and update time 2026-11-24 13:13:38.

    This record carries a lot of information, but writing it directly into storage is not a good idea. The first engineering step is to build a field dictionary that specifies the type, precision, unit, and null semantics of each field. Price fields should be carried as high-precision fixed-point numbers or strings, avoiding binary floating point, which produces tail differences during accumulation and comparison. Market cap and ranking are derived metrics, so their statistical scope must be documented. Market type should be constrained as an enumeration to prevent values that cannot be classified later.

    2. Derived Metrics Must Have a Documented Calculation Basis

    In a market data system, the biggest source of disputes is not collection but calculation basis. If change percentage and amplitude are not fixed in documentation, different modules will produce different results.

    1. change = last - open # 24-hour change amount
    2. change_pct = change / open * 100 # change percentage (%)
    3. amplitude = (high - low) / open * 100

    Plugging in the sample data: change ≈ 0.0011, change_pct ≈ 1.38%, amplitude ≈ 7.57%. The amplitude is far larger than the change percentage, which shows that intraday volatility was significant and the close was near the high. Conclusions like this only hold when the calculation basis is unified. The recommendation is to push derived calculations down into a shared calculation layer, while the collection layer only stores data as-is, avoiding drift caused by duplicate implementations in multiple places.

    3. Data Quality Validation Rules

    Placing validation at the pipeline entry is the lowest-cost way to control dirty data. Basic rules that can be implemented include:

    • Range consistency: low ≤ open, last ≤ high, and low ≤ high;
    • Precision validation: the number of decimal places in prices must match the asset specification; anything beyond that is truncated or rejected;
    • Monotonicity validation: timestamps for the same asset must strictly increase; duplicate timestamps are overwritten idempotently;
    • Volatility threshold: when the change percentage within a unit of time exceeds the threshold, mark it as suspicious and route it to a review queue rather than discarding it outright;
    • Completeness validation: when a required field is missing, log it to the logging service and trigger an alert.

    Data that fails validation should not be silently discarded, but written to separate quarantine storage for traceability and rule iteration.

    4. Timestamp and Time Zone Handling

    The update time in the sample is precise to the second and carries no time zone, a common pitfall in practice. The standard approach is to convert to a standard format with a time zone on the collection side (such as UTC ISO8601), then render in the user’s time zone on the display side, while keeping the original time field to avoid irreversible conversion. Candlestick aggregation and change-percentage window calculations both depend on time alignment; once time zone handling is inconsistent, window boundaries develop a systematic offset.

    1. {
    2. "symbol": "OPENUSDT",
    3. "market": "CRYPTO",
    4. "ts_utc": "2026-11-24T13:13:38Z",
    5. "last": "0.081",
    6. "open24h": "0.0799",
    7. "high24h": "0.08379",
    8. "low24h": "0.0783"
    9. }

    5. General Architecture and Implementation Advice

    A maintainable market data pipeline is usually divided into four layers: the collection layer handles multi-source pulling with rate limiting and backoff; the transport layer uses a message queue for peak shaving and decoupling; the storage layer uses object storage to archive raw snapshots and relational or time-series storage for queries; the service layer provides aggregate queries and push delivery. A container platform hosts stateless compute tasks, while logging, monitoring, and alerting provide observability.

    With cost under control, the general-purpose object storage, message queue, container platform, and monitoring and alerting offerings on Baidu AI Cloud can be combined to build the layers above, achieving the same capabilities without binding to proprietary interfaces.

    Finally, three engineering disciplines matter most: first, raw data is immutable and derived results can be recomputed; second, all metric definitions are documented and versioned; third, externally sourced statistical fields such as ranking and market cap are annotated with their source and refresh cycle, so they are not treated as real-time ground truth. With these three in place, market data can support stable upstream applications.