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

    This article walks through the engineering workflow for collecting, validating, storing, computing, and alerting on digital asset market data, using a single GLMUSDT snapshot as the reference example. It covers a three-layer field model, logical consistency assertions, precision and rounding handling, polling versus push collection strategies, hot/warm/cold storage tiering, idempotent writes, rule-based anomaly detection with tiered alerts, and observability metrics for long-term data governance.

    1. Starting from a Single Market Snapshot

    In digital asset application development, market data is usually the first data source to integrate, and it often looks simple but turns out to be complex in practice. The reference material provides a typical snapshot record: symbol code GLM, trading pair GLMUSDT, market type CRYPTO, quote currency USD, last price 0.09099, 24-hour change 0.002297 and change percentage 2.590%, open price 0.0887, high 0.09369, low 0.0876, market capitalization of roughly 91.6165 million, market cap rank 166, and update time 2026-11-24 14:38:35.

    This record is information-dense, and several implicit relationships between fields require engineering treatment. This article does not discuss any specific trading platform or product. Instead, it abstracts the snapshot into a generic market data object and explains how to collect, validate, store, compute, and alert on it.

    2. Field Semantics and Consistency Validation

    2.1 Field Layers

    Fields can be organized into three layers:

    • Identity layer: symbol code, trading pair, market type, quote currency;
    • Price layer: last price, open price, high price, low price, change amount, change percentage;
    • Statistics layer: market capitalization, market cap rank, update time.

    Layering lets validation rules be reused per layer. The identity layer handles enum and format checks, the price layer handles range and logic checks, and the statistics layer handles freshness and magnitude checks.

    2.2 Logical Consistency Rules

    The price layer has strong constraints that can be written directly as assertions:

    1. low <= open <= high
    2. low <= last <= high
    3. change_amount ≈ last - price_24h_ago
    4. change_pct ≈ change_amount / price_24h_ago × 100%

    Substituting the current snapshot: 0.0876 ≤ 0.0887 ≤ 0.09369 holds; 0.0876 ≤ 0.09099 ≤ 0.09369 holds. Back-calculating from the 2.590% change percentage and the 0.002297 change amount gives a price 24 hours ago of about 0.0887, which is very close to the open price, indicating the data is self-consistent. This kind of back-calculation check can intercept a large amount of dirty data before ingestion.

    2.3 Precision and Rounding

    Price fields should be carried as fixed-point numbers or strings to avoid tail differences when binary floating point values are accumulated or compared. Rounding should be applied uniformly at the presentation layer, for example keeping 5 decimal places for prices and 3 decimal places for change percentages, to prevent hard-to-diagnose issues such as the same value rendering differently across pages.

    3. Collection Pipeline Design

    3.1 Polling vs. Push

    Market data has two typical paths: scheduled polling and incremental push. Polling is simple to implement and idempotent, making it suitable for minute-level scenarios. Push has low latency but requires handling reconnection and message deduplication. In practice, a hybrid model of “push primary, polling fallback” is common, using polling results to fill gaps in the push stream.

    3.2 Scheduling and Frequency

    A second-level timestamp such as 14:38:35 shows the data itself supports second-level refresh. Collection frequency should match downstream needs: every 5–10 seconds for display, once per second for risk control and alerting, and minute-level aggregation for historical archiving. Too high a frequency amplifies rate-limiting and cost pressure; too low a frequency loses timeliness.

    3.3 Sample Collection Code

    1. import time
    2. def should_fetch(last_ts, now_ts, interval=5):
    3. """Throttle check: whether the interval has elapsed since the last successful collection"""
    4. return (now_ts - last_ts) >= interval
    5. def normalize(raw):
    6. """Unify field naming and types; convert prices to fixed-point strings"""
    7. return {
    8. "symbol": raw["code"],
    9. "pair": raw["pair"],
    10. "market": raw["market_type"].lower(),
    11. "quote": raw["currency"].upper(),
    12. "last": f"{float(raw['last']):.5f}",
    13. "open": f"{float(raw['open']):.5f}",
    14. "high": f"{float(raw['high']):.5f}",
    15. "low": f"{float(raw['low']):.5f}",
    16. "change_pct": round(float(raw["change_pct"]), 3),
    17. "ts": raw["update_time"],
    18. }

    4. Storage and Computation

    4.1 Hot/Cold Tiering

    Market data is write-heavy, read-light, and strongly time-oriented, which suits hot/cold tiering: hot data lives in low-latency key-value storage to support real-time dashboards; warm data is aggregated by minute and written to a time-series database; cold data is archived in columnar format to object storage for replay and training. Tiering keeps both cost structure and query performance under control.

    4.2 Aggregation Definitions

    Market capitalization and rank are statistics-layer metrics whose definitions change frequently, so they must be decoupled from the price layer. Record a definition version and computation time for each metric to avoid disputes such as the same symbol showing different market caps on different pages. Rank metrics should also record the sample scope, otherwise cross-period comparisons are meaningless.

    4.3 Idempotent Writes

    Using “symbol + trading pair + update time” as the primary key for idempotent writes naturally resists duplicate pushes. Duplicate data will not pollute change-percentage calculations, and replay logic is simplified.

    5. Anomaly Detection and Alerting

    5.1 Rule-Based Detection

    • Out-of-range detection: the last price falls outside the day’s high-low range;
    • Jump detection: the absolute change percentage between two adjacent samples exceeds a threshold;
    • Stagnation detection: the update time stops advancing for a long period;
    • Magnitude detection: market capitalization or volume jumps by an order of magnitude.

    5.2 Tiered Alerts

    Three levels are recommended: info level logs a record; warning level triggers a message queue notification; critical level pages on-call staff. Alerts need a deduplication window and convergence strategy to avoid alert storms during sharp market swings. General-purpose log services and monitoring/alerting capabilities from cloud providers can close the loop across collection, dashboards, and notifications.

    5.3 Sample Rules

    1. rules:
    2. - name: price_out_of_range
    3. expr: last < low or last > high
    4. level: warn
    5. - name: stale_update
    6. expr: now - update_ts > 60s
    7. level: critical
    8. - name: jump_guard
    9. expr: abs(change_pct - prev_change_pct) > 15
    10. level: warn

    6. Observability and Governance

    Continuously track four core metrics: collection success rate, end-to-end latency, validation failure rate, and field missing rate. Validation failure samples should be sampled and retained to make it easier to trace upstream definition changes. Also build a field dictionary that specifies the unit, precision, time zone, and definition version of each field; use a standard format with time zone for all timestamps to avoid cross-time-zone display discrepancies.

    7. Conclusion

    A seemingly simple market snapshot requires semantic layering, consistency validation, precision governance, hot/cold storage, idempotent writes, and tiered alerting before it becomes a production-grade data pipeline. Moving validation earlier, fixing definitions, and converging alerts are what keep market data trustworthy across display, risk control, and archiving scenarios. Building on general-purpose capabilities such as Baidu AI Cloud’s container platform, message queues, time-series storage, and monitoring/alerting lets teams focus on definitions and rules rather than repeatedly rebuilding infrastructure.