Collecting and Parsing Digital Asset Market Data: A Practical Guide

    This article walks through the practical design of a digital asset market data pipeline, starting from a single spot market snapshot. It explains how to separate identifier, price, derived, and statistical fields, normalize numbers with fixed-point arithmetic, enforce recomputable derived metrics, standardize timestamps to UTC, and make units explicit. It also covers collection layer design for no loss, no duplication, and no reordering, validation and dead-letter handling, layered storage and pre-aggregation, and observability plus cost control. The goal is a deterministic, operable system as data volume grows.

    1. Reading Data Structure from a Single Market Snapshot

    When building a market data system, the first step is not writing code. It is translating “what is shown on the page” into “a structure that can be computed.” Below is a typical spot market snapshot (sample data):

    1. Symbol: GLM
    2. Pair: GLMUSDT
    3. Market type: CRYPTO
    4. Last price: 0.09129
    5. Quote currency: USD
    6. 24h change: 0.002597
    7. 24h change %: 2.928%
    8. Open price: 0.08869
    9. High price: 0.09368
    10. Low price: 0.08759
    11. Market cap: 90.5415 million
    12. Market cap rank: 168
    13. Updated at: 2026-11-24 14:27:38

    This record looks simple, but it actually contains four categories of information with completely different semantics. Mixing them together is the root cause of nearly all downstream data quality problems:

    1. Identifier fields: symbol, pair, and market type. They answer “whose data is this” and should be part of the primary key or partition key.
    2. Price fields: last price, open price, high price, and low price. They describe the price distribution within a time window. Note that the high and low must belong to the same window as the open price.
    3. Derived fields: change amount and change percentage. They are not raw observations but results computed from the last price and open price. They should not be stored as independent facts; they should be recomputable.
    4. Statistical fields: market cap and market cap rank. They depend on circulating supply estimates and a full-market ranking, usually update less frequently than price, and behave like “slowly changing dimensions.”

    Separating derived fields from raw fields is the most overlooked yet highest-return design principle in a market data system. Once change percentage is stored as a fact, any later change in methodology makes historical data incomparable.

    2. Field Normalization: Making Data Computable

    2.1 Use fixed-point numbers, not floating point

    Price fields involve precision-sensitive comparisons and accumulation. Binary floating point introduces tail differences after repeated operations. The common engineering practice is to carry the decimal representation as a string in the transport layer, and use fixed-point numbers or scaled integers in the storage and compute layers (for example, scale uniformly to 8 decimal places and store as integers).

    1. from decimal import Decimal
    2. def to_scaled_int(raw: str, scale: int = 8) -> int:
    3. """Convert a decimal string to a scaled integer to avoid floating-point error"""
    4. return int((Decimal(raw) * (10 ** scale)).to_integral_value())
    5. price = to_scaled_int("0.09129") # 9129000
    6. open_px = to_scaled_int("0.08869") # 8869000
    7. delta = price - open_px # 260000, corresponding to 0.0026

    2.2 Change percentage must be recomputable

    Run a consistency check with the sample data: (0.09129 - 0.08869) / 0.08869 ≈ 2.93%, which matches the reported 2.928% within rounding error. This shows the field can be derived from the price fields. The engineering recommendation is: keep the originally reported value on ingestion, compute a local value at the same time, and flag the record as suspicious when the deviation exceeds a threshold, instead of overwriting it directly.

    2.3 Standardize timestamps to timezone-aware UTC

    A string like 2026-11-24 14:27:38 without a timezone is a common pitfall in cross-system collaboration. The standard practice is to convert to a timezone-aware time immediately at the collection end, store everything in UTC, and render in the user’s timezone at the presentation layer. It is also important to distinguish three time semantics: the source generation time, the collection receive time, and the ingestion time. Recording all three is what lets you locate which stage the delay occurred in.

    2.4 Make units and dimensions explicit

    “Market cap 90.5415 million” is a display-oriented expression that carries a dimension. For machine processing, it should be converted to a definite unit (for example, an integer in base units denominated in USD). Every monetary field must explicitly declare its dimension and precision in the schema to prevent misuse downstream.

    3. Collection Layer Design: Stability First

    Market data collection is a typical “high-frequency, small-payload, latency-sensitive” scenario. The design should revolve around three goals: no loss, no duplication, and no reordering.

    • No loss: use incremental cursor-based pulls, persist the cursor to external storage, and resume from the last position after a process restart; use at-least-once delivery semantics at critical points.
    • No duplication: construct a business primary key market_type + symbol + window_start for each record, combined with idempotent writes, so repeated delivery does not produce duplicate rows.
    • No reordering: sort by the source time, handle “late-arriving data” on ingestion, allow late updates within a limited window to overwrite old values, and route anything beyond the window to a side table for manual review.

    Pull frequency must match the update frequency of each field. Price fields change by the second, while statistical fields like market cap rank change by the minute or slower. Pulling everything at the same frequency wastes a large amount of bandwidth and quota. A workable strategy is layered scheduling: the high-frequency layer fetches only the price four-tuple, the low-frequency layer fills in the statistical fields, and the read side merges them into a view by primary key.

    4. Validation and Exception Handling

    Before data enters the compute pipeline, a set of cheap but effective rules must be in place:

    1. Range constraints: low price ≤ open price and last price ≤ high price; reject ingestion on violation.
    2. Jump detection: when the change in last price between two adjacent records exceeds a configured threshold, mark it as pending confirmation and do not let it participate in metric computation directly.
    3. Staleness detection: when the gap between the current time and the source time exceeds the tolerance limit, treat it as stale data and clearly flag it in the frontend and for downstream consumers, to avoid using a stale price as a real-time price.
    4. Completeness checks: records with empty primary key fields, missing dimensions, or precision beyond limits go directly to a dead-letter queue instead of being silently dropped.

    The dead-letter queue is a key component of this system. It separates “bad data” from the main flow while preserving traceable evidence, making it easier to trace problems back to the collection end.

    5. Layered Storage and Compute

    A practical layered structure looks like this:

    • Ingestion layer: handles protocol adaptation, rate limiting, authentication, and retention of raw payloads (can land in object storage, partitioned by time for easy replay).
    • Messaging layer: uses a message queue for peak shaving and decoupling, partitioned by symbol hash to guarantee local ordering per symbol.
    • Detail layer: columnar storage keeps per-trade/per-window market data, partitioned by date and symbol, supporting efficient scans by time range.
    • Aggregation layer: precomputes common windows (1 minute, 5 minutes, 1 hour, 1 day) to avoid repeated detail scans at query time.
    • Service layer: exposes a unified query interface that clearly distinguishes three semantics: real-time price, snapshot price, and historical price.

    Derived metrics are computed uniformly in the aggregation layer, with the compute logic decoupled from the collection logic. This way, a methodology change only requires re-running the aggregation, not re-collecting the data.

    6. Observability and Cost Control

    The operational difficulty of a market data system is that “the data looks normal, but it is actually already delayed.” Monitoring must therefore cover the data itself, not just process liveness:

    • Collection latency distribution (P50/P95/P99), not just the average;
    • Data freshness and missing rate per symbol;
    • Validation rejection rate and dead-letter queue backlog;
    • Consistency deviation between derived fields and raw fields.

    These metrics can be wired into monitoring and alerting with tiered thresholds to avoid alert storms. On cost control, set a shorter lifecycle for raw payloads and retain aggregation results long-term, forming a hot/cold tier; reduce storage and traffic overhead through batch writes and compression encoding.

    7. Summary

    Behind a single market snapshot is a full semantic layering of “identifier–price–derived–statistical.” The focus of engineering implementation is not the scraping itself, but: using fixed-point numbers to guarantee precision, using the recomputable principle to constrain derived fields, using a unified timezone to remove ambiguity, using idempotency and a dead-letter queue to guarantee data quality, and using layered storage plus pre-aggregation to support query performance. Once this skeleton is in place, adding monitoring, alerting, and hot/cold tiering keeps the system deterministic and operable as data volume grows.