Digital Asset Market Data: Collection and Parsing in Practice

    This article walks through the engineering side of digital asset market data, from a real snapshot record to a production-ready pipeline. It explains why raw quotes are harder than they look, covering zero-value ambiguity, inconsistent units, and missing time zones. You will see a unified internal data model, five validation checks with sample Python code, collection strategies using polling and exponential backoff, a three-layer storage design, and observability practices that focus on data trustworthiness rather than process liveness. Common pitfalls and a concise summary are included to help you build reliable market data systems.

    1. Why Market Data Is Hard to Handle

    When building any system that analyzes digital assets, the first step is not the model but the data. Market data looks simple—price, change, high, low, market cap—yet in engineering practice it is the part most likely to break.

    The source material provides a typical market snapshot record: an asset with symbol GLM, trading pair GLMUSDT, market type CRYPTO, latest price 0.09359 USD, a 24-hour change of 0, a 24-hour change percentage of 0.000%, an open of 0.09359, a high of 0.09539, a low of 0.09119, a market cap of roughly 93.7331 million USD, a rank of 164, and an update time of 2026-12-01 19:52:38.

    This single record exposes at least three engineering problems:

    1. Zero-value ambiguity: A change amount and change percentage that are both 0 may reflect a genuinely quiet market, or they may be default fill values written after a collection failure.
    2. Inconsistent units: Price is quoted in USD, market cap is expressed in units of ten thousand, and rank is an integer index. The three fields differ in both precision and unit.
    3. Unclear time semantics: The update time is precise to the second but carries no time zone, which easily introduces an eight-hour offset when aggregating across time zones.

    2. A Unified Data Model: Fix Field Semantics First

    The first principle for handling market data is “define first, compute later.” Map every market data source onto the same internal model, and once field semantics are fixed they should no longer vary by source.

    1. {
    2. "symbol": "GLM",
    3. "pair": "GLMUSDT",
    4. "market_type": "CRYPTO",
    5. "price": 0.09359,
    6. "quote_currency": "USD",
    7. "change_24h": 0.0,
    8. "change_pct_24h": 0.0,
    9. "open_24h": 0.09359,
    10. "high_24h": 0.09539,
    11. "low_24h": 0.09119,
    12. "market_cap": 937331000,
    13. "rank": 164,
    14. "update_time": "2026-12-01T19:52:38+00:00"
    15. }

    Three changes matter here. Market cap is normalized to the smallest unit (the base currency amount) to avoid mixing ten-thousand and hundred-million scales. A time zone offset is added to the timestamp. Price and change percentage are unified as floats with explicit precision. With this in place, downstream consumers—whether building visualizations or running backtests—no longer need to care where the data came from.

    3. Data Quality Validation: Five Mandatory Gates

    Before data enters storage, there must be a validation layer. Run the following checks in order:

    • Range validation: The high must be greater than or equal to both the open and the low, and the low must not exceed the open. In the example, 0.09539 ≥ 0.09359 ≥ 0.09119, so it passes.
    • Zero-value validation: When the change amount and change percentage are both 0 but the high and low show a clear spread (about 4.5% in this case), flag the record as “suspected collection anomaly” rather than storing it as a real value.
    • Freshness validation: If the gap between the current time and the update time exceeds a threshold (for example, 5 minutes), treat the data as stale.
    • Rank sanity validation: The market cap rank should be a positive integer whose magnitude roughly matches the market cap.
    • Precision validation: When a price has too many decimal places, truncate it according to the trading pair rules to avoid accumulating floating-point error.

    Illustrative implementation:

    1. def validate(rec, now_ts, max_age=300):
    2. errs = []
    3. if not (rec["high_24h"] >= rec["open_24h"] >= rec["low_24h"]):
    4. errs.append("price_range_invalid")
    5. if rec["change_24h"] == 0 and rec["change_pct_24h"] == 0 \
    6. and (rec["high_24h"] - rec["low_24h"]) / rec["open_24h"] > 0.01:
    7. errs.append("suspicious_zero_change")
    8. if now_ts - rec["update_ts"] > max_age:
    9. errs.append("stale_data")
    10. return errs

    4. Collection Layer Design: Polling, Incremental Updates, and Backoff

    Market data collection typically uses one of two modes: scheduled polling and incremental push. Polling is simple to implement and suits snapshot data. Incremental push offers better real-time behavior but requires handling reconnection after disconnects.

    In practice, add exponential backoff retries so that a flaky data source does not trigger an avalanche:

    1. import time, random
    2. def fetch_with_backoff(fn, max_retry=5):
    3. for i in range(max_retry):
    4. try:
    5. return fn()
    6. except Exception:
    7. time.sleep(min(2 ** i + random.random(), 30))
    8. raise RuntimeError("fetch failed after retries")

    Also, record the source, time, and a digest of the raw payload for every collection run. This is the only reliable basis for investigating zero-value problems later.

    5. Storage and Computation: A Layered Approach

    A three-layer structure is recommended:

    1. Raw layer: Stores unprocessed raw snapshots, append-only, for replay and traceability.
    2. Cleaned layer: Stores standardized records that passed validation, partitioned by symbol and time.
    3. Aggregate layer: Precomputes minute-, hour-, and day-level open/high/low/close and spread so queries can read them directly.

    The value of the aggregate layer is moving repeated computation forward. Spread, for example, can be defined as (high - low) / open, roughly 4.5% in this case. If such a metric were computed on every query, cost would grow linearly with data volume.

    6. Deployment and Operations: Elasticity and Observability

    On Baidu AI Cloud, this kind of data pipeline can be built entirely from general-purpose capabilities: use a message queue to absorb collected market messages and smooth out traffic spikes, use object storage to keep raw payloads, use a container platform to run collection and cleaning tasks, use a logging service to centralize runtime logs, and use monitoring and alerting to set thresholds on three metrics: data freshness, validation failure rate, and collection latency.

    The key point is that monitoring should focus not on “whether the service is alive” but on “whether the data is trustworthy.” A pipeline whose process is healthy but which keeps writing zero values is far more dangerous than one that simply crashes.

    7. Common Pitfalls

    • Treating zero values as real values: This is the most common and most hidden mistake in market data systems.
    • Ignoring time zones: When aggregating across sources, time misalignment directly contaminates every period statistic.
    • Doing complex computation in the collection layer: The collection layer should only fetch and land data; leave computation to downstream layers.
    • Missing a raw layer: Once cleaning logic changes, historical data can no longer be recomputed.

    8. Summary

    The core of market data engineering is not scraping but four things: defining semantics, validating quality, layered storage, and observable operations. Solve the three problems from the example—zero change, mixed units, and missing time zone—at the entry point, and the analysis and visualization that follow can rest on a trustworthy foundation.