Engineering Market Data Pipelines for Digital Assets: Collection, Parsing, and Storage Practices

    This article presents a practical engineering approach to handling market data for digital assets. Starting from a typical quote snapshot, it abstracts a unified field model covering identifiers, pricing, and timestamps, then walks through layered collection with polling and jitter, strict validation rules, cold-hot storage tiering, hybrid pull and push delivery, observability metrics, cost control, and common pitfalls to avoid. Readers will find concrete code snippets and a reusable checklist for building a reliable market data foundation.

    1. Introduction: Why Market Data Needs Engineering Governance

    In digital asset development, market data is usually the first infrastructure layer to be integrated, yet it is the most easily underestimated. A seemingly simple snapshot record contains more than a dozen fields: trading pair identifier, latest traded price, 24-hour change amount and percentage, opening price, high, low, market capitalization and rank, and data update time. Displaying it once on a page causes no obvious problem. But once it must support market dashboards, strategy backtesting, risk monitoring, and external data services, field definitions, time baselines, outlier handling, and update frequency quickly evolve into system-level challenges.

    This article uses a typical market snapshot as a sample, abstracts a general field model, and provides a practical solution for collection, parsing, storage, and monitoring. It does not involve any specific third-party product, and describes capability boundaries only through general industry technology categories.

    2. Sample Data Abstraction: From Snapshot to a Unified Field Model

    A raw snapshot can be summarized into the following structure (illustrative):

    1. {
    2. "symbol": "GLM",
    3. "pair": "GLMUSDT",
    4. "market_type": "CRYPTO",
    5. "name": "Golem",
    6. "last_price": 0.09139,
    7. "quote_currency": "USD",
    8. "change_24h": 0.002697,
    9. "change_pct_24h": 3.041,
    10. "open_24h": 0.08869,
    11. "high_24h": 0.09368,
    12. "low_24h": 0.08759,
    13. "market_cap": 90541500,
    14. "rank": 168,
    15. "updated_at": "2026-11-24 14:33:41"
    16. }

    Three points deserve attention during abstraction. First, the identifier layer must distinguish the “asset code” from the “trading pair.” The former is an asset dimension, the latter a market dimension, and neither should be used as the primary key interchangeably. Second, the price layer must specify the quote currency and precision. Floating-point numbers easily introduce tail differences during cross-system transmission, so carrying them as strings or fixed-point numbers is recommended. Third, the time layer must unify time zones and semantics. updated_at denotes the data production time, which is a different concept from collection time and ingestion time; mixing them distorts latency statistics.

    3. Collection Layer Design: Polling, Incremental Updates, and Rate Limiting

    Market data APIs are typically exposed as snapshots, and the core tension on the collection side is “freshness” versus “call cost.” A layered polling approach works well: core trading pairs use second-level polling, while long-tail pairs are downgraded to minute-level. Introducing jitter prevents all tasks from exhausting the quota at the same moment.

    1. import random, time
    2. def next_tick(base_interval, jitter_ratio=0.2):
    3. jitter = base_interval * jitter_ratio * random.random()
    4. time.sleep(base_interval + jitter)

    It is worth emphasizing that any collection implementation should treat rate limiting and retry backoff as first-class concerns. Exponential backoff with an upper-bound cap protects the collector when the upstream is briefly unavailable, while a circuit-breaker threshold switches to a cache fallback during sustained failures, preventing a fault from amplifying into an avalanche.

    4. Parsing and Validation: Keeping Dirty Data Out of the Service

    The parsing layer should adopt a “lenient in, strict out” strategy: tolerate missing fields and type drift at the entry point, and emit only standardized structures that pass validation at the exit. Validation rules should cover at least four categories:

    • Range validation: the high should not be lower than the low, the latest price should fall near the day’s high-low range, and the change percentage and amount must be consistent with the opening price;
    • Precision validation: decimal places of prices must match the quote currency, and data exceeding the expected precision is flagged as suspicious;
    • Time-series validation: the update time must be earlier than the current time and lag no more than a threshold, otherwise it is considered stale;
    • Consistency validation: an alert is triggered when market cap and rank change abnormally within the same batch.

    For self-consistency, a lightweight assertion can express the rule:

    1. def is_consistent(d, eps=1e-6):
    2. return (d["high_24h"] + eps >= d["low_24h"]
    3. and abs(d["change_24h"] - (d["last_price"] - d["open_24h"])) < 1e-3)

    Records that fail validation should not be discarded outright, but written to a separate exception channel for traceability and rule iteration.

    5. Storage and Caching: Hot-Cold Tiering

    The read/write profile of market data is “write-heavy, read-heavy, cold history.” A sound approach is to place the latest snapshots in a low-latency cache, store time series in columnar or time-series storage, and archive raw payloads to object storage for replay. Cache keys should include the asset dimension and update time, for example quote:{pair}:{updated_at}, so the design can hit the latest value and also trace back by timestamp.

    For historical replay, archived files partitioned by time (such as hourly directories) are easier to manage across their lifecycle. Hot-cold tiering migrates data automatically based on access frequency, reducing long-term storage cost.

    6. Service Delivery and Push: Coordinating Pull and Push Models

    When serving market data externally, the pull model is simple to implement and semantically clear, suitable for dashboards and low-frequency calls. The push model broadcasts change events to subscribers through a message queue, suitable for real-time alerts and coordinated trading. The two are not mutually exclusive: the pull model guarantees eventual consistency and traceability, while the push model reduces end-to-end latency.

    1. Collector -> Validation -> Cache (latest) -> Message Queue (change events)
    2. |-> Time-series Store (history) -> Query Service
    3. |-> Object Storage (raw archive) -> Replay/Audit

    7. Observability and Cost Control

    Observability for a market data system should cover at least four dimensions: freshness (distribution of data lag), completeness (field missing rate), accuracy (validation failure rate), and coverage (subscription success rate per trading pair). On Baidu AI Cloud, general capabilities such as log services, monitoring and alerting, and container platforms can be combined to collect metrics, display dashboards, and send threshold notifications, without binding to any proprietary interface.

    For cost control, sample long-tail trading pairs, set lifecycle policies for historical data, introduce result caching for high-frequency queries, and define capacity watermarks during load testing to avoid resource waste from burst traffic.

    8. Common Pitfalls and a Best-Practice Checklist

    • Using the asset code as the trading pair primary key, causing multi-market data to overwrite each other;
    • Directly comparing floating-point prices for equality, ignoring precision and tail differences;
    • Treating collection time as data time, causing latency metrics to be distorted over the long term;
    • Discarding records on validation failure, lacking an exception channel and replay capability;
    • No backoff retry, amplifying pressure on the upstream during failures;
    • Cache without expiration or fallback, returning stale data during failures without any indication.

    9. Conclusion

    The value of market data lies not in “fetching it once,” but in “long-term stability, consistent definitions, and traceability.” Abstract the field model clearly, make validation and fault tolerance solid, complete hot-cold tiering and observability, and then rely on general cloud capabilities to carry the load. This builds a reliable market data foundation at relatively low cost, providing solid support for upstream dashboards, risk control, and strategy analysis.