Digital Asset Market Data: Collection, Parsing, and Engineering Practices

    This article walks through the engineering lifecycle of digital asset market data, starting from a single GLMUSDT quote snapshot. It explains how to define a schema contract, validate field consistency, handle timestamps and time zones, preserve numeric precision, and build a layered pipeline for collection, buffering, computation, and serving. It also covers freshness-focused monitoring, alerting, and common pitfalls, helping teams make market data trustworthy across dashboards, backtesting, and risk control.

    1. Starting Data Modeling from a Single Quote Snapshot

    The source material is a market snapshot for one asset at one point in time: asset code GLM, trading pair GLMUSDT, market type CRYPTO, quote currency USD, last traded price 0.09119, 24-hour change 0.002597 (2.931%), open price 0.08859, high 0.09269, low 0.08759, market cap of roughly USD 90.5415 million, rank 168, and update time 2026-11-24 14:21:36.

    This record is dense with information, but ingesting it directly creates risks: inconsistent field naming, ambiguous time semantics, undefined precision, and unclear definitions for derived metrics. The first engineering step is not writing a collection script, but defining a market data schema contract that fixes each field’s type, unit, precision, null strategy, and update frequency.

    1. {
    2. "symbol": "GLM",
    3. "pair": "GLMUSDT",
    4. "market_type": "CRYPTO",
    5. "quote_currency": "USD",
    6. "last_price": 0.09119,
    7. "change_24h": 0.002597,
    8. "change_pct_24h": 2.931,
    9. "open_24h": 0.08859,
    10. "high_24h": 0.09269,
    11. "low_24h": 0.08759,
    12. "market_cap_usd": 90541500,
    13. "rank": 168,
    14. "ts": "2026-11-24T14:21:36Z"
    15. }

    The value of a contract is that downstream systems—whether real-time dashboards, backtesting, or risk control—rely on the same semantic definition, avoiding the alignment cost of “three interpretations of one field.”

    2. Self-Consistency Checks for Field Semantics and Derived Metrics

    The most common problem with market data is not collection failure, but internal inconsistency. Using this example, three checks can be applied:

    1. Range check: low ≤ open/last ≤ high, meaning 0.08759 ≤ {0.08859, 0.09119} ≤ 0.09269, which holds.
    2. Change amount check: last price − price 24 hours ago = change amount. Back-calculating gives a price 24 hours ago of about 0.088593, very close to the open price of 0.08859. This shows that at this moment the “24-hour window” and “day open” nearly coincide, but their definitions must not be conflated.
    3. Change percentage check: change amount ÷ previous value ≈ 0.002597 ÷ 0.088593 ≈ 2.93%, consistent with the given 2.931%.
    1. def validate_quote(q, eps=1e-6):
    2. assert q["low_24h"] <= q["open_24h"] <= q["high_24h"] + eps
    3. assert q["low_24h"] <= q["last_price"] <= q["high_24h"] + eps
    4. prev = q["last_price"] - q["change_24h"]
    5. derived_pct = q["change_24h"] / prev * 100
    6. assert abs(derived_pct - q["change_pct_24h"]) < 0.01
    7. return True

    Moving validation ahead of ingestion intercepts “dirty snapshots” at the source and prevents contamination of downstream feature stores and training samples.

    3. Timestamps, Time Zones, and Update Frequency

    “Update time 2026-11-24 14:21:36” lacks time zone information, which is one of the most typical pitfalls in market data systems. A common convention is: on the collection side, always convert to ISO 8601 with a time zone (such as 2026-11-24T14:21:36Z); on the storage side, retain the original time zone offset; on the display side, render according to user preference.

    It is also necessary to distinguish three kinds of time: event time (trade time), data generation time (snapshot time), and ingestion time. Mixing them can introduce look-ahead bias in backtesting. In engineering, each record can carry dual time axes, event_ts and ingest_ts, and load testing should observe the end-to-end latency distribution rather than only the average.

    4. Precision, Fixed-Point Numbers, and Serialization Strategy

    Using floating-point numbers for price fields accumulates errors, especially during long-period aggregation (sums, compounding, volume-weighted average price). The recommended approach is: use strings to carry decimals at the transport layer, use fixed-point or scaled integers at the storage layer (for example, uniformly scaling by 1e8 and storing as int64), and format again at the display layer.

    1. 0.09119 -> "9119000000" (scaled by 1e8, int64)
    2. market cap 90.5415 million -> 905415000 (USD, integer)

    For serialization, high-frequency small messages are suited to compact binary or columnar formats, falling back to text JSON when cross-language debugging is needed. The core principle is: precision must not be lost through format conversion.

    5. End-to-End Architecture: Collection, Buffering, Computation, Serving

    A practical market data pipeline is usually divided into four layers:

    • Ingestion layer: multi-source collection and normalization, masking differences in definitions across data sources;
    • Buffering layer: a message queue for peak shaving and valley filling, ensuring downstream consumption can be replayed;
    • Computation layer: stream computing for real-time window metrics (24-hour high/low, change percentage), and batch processing to backfill historical gaps;
    • Serving layer: output via APIs or dashboards, with object storage for cold data archiving.

    On Baidu AI Cloud, this structure can map to a combination of general capabilities: a message queue handles buffering and decoupling, a container platform carries elastic scaling for collection and computation tasks, object storage holds historical snapshots and replay files, and log and monitoring services provide observability. All components interact over standard protocols, avoiding tight coupling to a single implementation.

    6. Availability and Monitoring/Alerting Design

    Availability metrics for a market data system should focus on “freshness” rather than only “liveness.” At least four signals are worth monitoring:

    1. Data freshness: alert when current time − latest snapshot time exceeds a threshold;
    2. Field completeness: a sudden rise in the proportion of missing key fields;
    3. Consistency deviation: counts of failed range checks and change-percentage checks;
    4. Latency percentiles: P95/P99 end-to-end latency, not the mean.
    1. alerts:
    2. - name: quote_stale
    3. expr: now() - last_quote_ts > 30s
    4. severity: critical
    5. - name: quote_inconsistent
    6. expr: increase(validate_fail_total[5m]) > 3
    7. severity: warning

    Alerts must be bound to clear runbooks; otherwise noise will quickly consume the attention of on-call engineers.

    7. Common Pitfalls and Engineering Recommendations

    • Pitfall 1: treating the 24-hour window as a calendar day. The two differ significantly at day boundaries and must be stated clearly in the contract.
    • Pitfall 2: treating market cap and rank as real-time exact values. Market cap depends on the definition of circulating supply, and rank depends on the full-network sample; both are better used as reference dimensions with an update time noted.
    • Pitfall 3: storing only the latest value. Without historical snapshots, lookbacks and reviews become impossible; tiered hot/cold storage is the most cost-effective option.
    • Pitfall 4: ignoring replay capability. Retaining a replayable window in the message buffering layer is infrastructure for troubleshooting and model iteration.

    8. Summary

    A seemingly simple quote snapshot expands into a complete engineering topic: data contracts, definition checks, time semantics, precision control, layered architecture, and observability. Making semantics and validation solid first, then discussing throughput and real-time performance, allows market data to be trusted across display, backtesting, and risk control. With the elasticity and observability components of general cloud capabilities, teams can focus on defining metrics and business logic instead of repeatedly building infrastructure.