Collecting and Parsing Digital Asset Market Data: A Practical Guide

    This article walks through the engineering practice of collecting and parsing digital asset market data. Using a typical market snapshot as a sample, it presents a neutral data model and a reusable processing pipeline, covering multi-source collection with a primary and fallback channel, five categories of validation that must be intercepted, hot and cold storage with incremental synchronization, and monitoring and alerting for observability. The goal is to show how to build a stable, low-latency, and traceable market data ingestion layer in your own system.

    1. Introduction: Why Market Data Engineering Is Harder Than It Looks

    In digital asset trading, quantitative research, and risk control systems, market data is the most fundamental and most easily underestimated component. A seemingly simple market snapshot actually contains more than a dozen fields: symbol identifier, trading pair, market type, last price, quote currency, 24-hour change amount and change percentage, open price, high price, low price, market cap, market cap ranking, and data update time. There are not many fields, but turning them into a stable, low-latency, and traceable service requires handling a series of engineering problems: time alignment, precision loss, abnormal jumps, duplicate pushes, and reconnection after disconnects.

    This article uses a typical snapshot as a sample, abstracts a general data model and processing pipeline, discusses how to build a market data ingestion layer in your own system, and provides a reusable validation and alerting design.

    2. Neutral Modeling of the Sample Data

    The raw sample can be summarized into the following structure (field names are generalized):

    1. {
    2. "symbol": "GLM",
    3. "pair": "GLMUSDT",
    4. "market_type": "CRYPTO",
    5. "name": "Golem",
    6. "last_price": 0.09359,
    7. "quote_currency": "USD",
    8. "change_24h": 0,
    9. "change_pct_24h": 0.000,
    10. "open_price": 0.09359,
    11. "high_price": 0.09539,
    12. "low_price": 0.09119,
    13. "market_cap": 93733100,
    14. "rank": 164,
    15. "update_time": "2026-12-01 19:56:40"
    16. }

    Three points need attention when modeling. First, prices must use a high-precision decimal type rather than floating point; otherwise, errors will accumulate in very small price ranges (such as the 0.09 magnitude). Second, the change percentage and change amount should retain their original precision and be stored separately, to avoid introducing bias through secondary calculation. Third, the update time must carry timezone semantics; it is recommended to uniformly convert to UTC for storage, and the presentation layer renders it according to the user’s timezone.

    3. Collection Layer Design: Multi-Source Access and Priority

    Market data sources are usually divided into push-based and polling-based types. Push-based has low latency but high requirements on connection stability; polling-based is simple to implement but has gaps. In engineering, it is recommended to run dual channels in parallel: the primary channel subscribes to incremental pushes, and the backup channel pulls snapshots at a fixed interval as a fallback.

    1. async def fetch_snapshot(client, pair):
    2. resp = await client.get("/snapshot", params={"pair": pair})
    3. resp.raise_for_status()
    4. return normalize(resp.json())
    5. def normalize(raw):
    6. return {
    7. "pair": raw["pair"].upper(),
    8. "last": Decimal(str(raw["last_price"])),
    9. "ts": parse_utc(raw["update_time"]),
    10. }

    The normalization function is the first gate for all subsequent logic. Be sure to complete field renaming, unit unification, and time standardization here, to prevent dirty data from spreading downstream.

    4. Data Validation: Five Categories of Anomalies That Must Be Intercepted

    1. Time inversion: the new data’s update time is earlier than the time already stored; discard it directly.
    2. Price out of bounds: the last price is not within the day’s high-low range;判定为异常 (judged as anomalous).
    3. Self-contradictory change: the sign of the change percentage is inconsistent with the sign of the change amount; re-fetch is required.
    4. Precision overflow: the number of decimal places exceeds a preset threshold; truncate according to rules and count with metrics.
    5. Missing fields: when a key field is empty, enter the degradation flow, use the last valid value, and mark it as stale.

    Validation rules should be configurable, making it easy to adjust thresholds differently per trading pair.

    5. Storage and Incremental Synchronization

    Hot data is stored in a time-series structure for the most recent several days; warm and cold data is archived to object storage. Writes use batch merging to avoid the pressure of persisting record by record. Incremental synchronization uses the update time as a watermark, combined with an idempotent write key (trading pair + timestamp) to prevent duplicates.

    1. INSERT INTO tick (pair, ts, last, high, low)
    2. VALUES (:pair, :ts, :last, :high, :low)
    3. ON CONFLICT (pair, ts) DO UPDATE SET last = EXCLUDED.last;

    6. Monitoring, Alerting, and Observability

    It is recommended to build dashboards for four categories of metrics: collection latency, validation failure rate, disconnect count, and stale data ratio. Alerts are triggered when the daily decline or volatility exceeds a threshold, or when data is stale beyond a set number of seconds. Logs, metrics, and distributed tracing are handled by log services and monitoring and alerting capabilities; containerized deployment can leverage a container platform for elastic scaling.

    7. Conclusion

    The core of market data ingestion is not API calls, but data contracts and anomaly governance. Making the four stages—modeling, validation, storage, and alerting—solid provides a trustworthy foundation for upper-layer price display, metric calculation, and strategy backtesting. If further hosting is needed, the entire pipeline can be deployed on the relevant general capabilities of Baidu AI Cloud to reduce operational burden.