Market Data Pipeline Design for Digital Assets: Collection, Parsing, and Data Quality Practices
This article presents a vendor-neutral approach to building a market data pipeline for digital asset trading, quantitative research, and risk control. Using a typical ticker snapshot as a sample, it shows how to normalize fields into stable English keys, carry prices as strings with fixed-point decimal arithmetic, unify market cap units, and clarify timestamp timezone semantics. It then outlines a four-layer architecture (ingestion, parsing, buffering, storage and compute), includes sample parsing code with validation checks, and lists data quality rules covering range, derived consistency, rank validity, freshness, and deduplication. Finally, it covers hot/warm/cold storage tiering, observability metrics, and common pitfalls. The pipeline can run on general cloud capabilities such as container platforms, message queues, object storage, and log monitoring, including those offered by Baidu AI Cloud.
1. Introduction: Why Market Data Pipelines Need Engineering Design
In digital asset trading, quantitative research, and risk control, market data is the most fundamental and most sensitive input. A seemingly simple ticker snapshot contains fields such as symbol, trading pair, market type, last price, quote currency, 24-hour price change and change percentage, open price, high price, low price, market cap, market cap rank, and update time. There are not many fields, but feeding them reliably into downstream analytics, display, and decision systems requires handling a series of engineering problems: encoding conventions, time synchronization, precision control, outlier filtering, and duplicate removal.
This article uses a typical market snapshot as a sample and abstracts a general-purpose approach to market data ingestion and parsing. The approach does not depend on any vendor’s proprietary API. Instead, it focuses on widely accepted data modeling and stream processing practices, and can run on general cloud capabilities such as container services, message queues, object storage, and log monitoring.
2. Structured Parsing of the Sample Data
First, break the raw snapshot into structured fields for downstream modeling:
Symbol: GLMPair: GLMUSDTMarket type: CRYPTOName: GolemLast price: 0.08989Currency: USD24h change: 0.00169824h change rate: 1.925%Open price: 0.08819High price: 0.09268Low price: 0.08759Market cap: 89.6418 millionMarket cap rank: 168Update time: 2026-11-24 13:10:37
From an engineering perspective, these fields fall into four categories:
- Identity fields: symbol, name, pair, market type, currency. They uniquely determine which asset is quoted, in which market, and in what unit of account.
- Price fields: last price, open price, high price, low price. They reflect the price distribution at the current moment and over the statistics window.
- Statistics fields: price change, change rate, market cap, market cap rank. These are derived metrics, usually aggregated from raw trade data.
- Metadata fields: update time. It determines data freshness and alignability.
2.1 Normalized Field Modeling
Map the original keys to stable English keys so downstream systems do not break when labels are reworded:
{"symbol": "GLM","pair": "GLMUSDT","market_type": "CRYPTO","name": "Golem","last_price": "0.08989","quote_currency": "USD","change_24h": "0.001698","change_rate_24h": "1.925","open_price": "0.08819","high_price": "0.09268","low_price": "0.08759","market_cap": 89641800,"rank": 168,"update_time": "2026-11-24T13:10:37"}
Two decisions are critical here:
- Carry prices as strings. Digital asset prices often reach very small magnitudes (such as 0.08989). Storing and computing them as binary floating point introduces unpredictable rounding errors. The common industry practice is to transmit them as strings and store and compute them with fixed-point decimal types.
- Normalize market cap units. The raw data expresses market cap in units of ten thousand. It must be converted to a base unit such as dollars before storage; otherwise, cross-asset aggregation will produce magnitude errors.
2.2 Timezone Semantics of the Timestamp
The update time is the most easily overlooked field. Engineering practice must make three things explicit: whether the time is the collector’s local time or a unified timezone; whether precision is at the second or millisecond level; and whether collection delay exists. It is recommended to convert everything to ISO 8601 with a timezone inside the pipeline, and additionally record the “collection time” so the difference between the two measures end-to-end latency.
3. Layered Design of the Data Pipeline
A robust market data pipeline typically has four layers:
- Ingestion layer: scheduled polling or subscription-based push to pull raw snapshots. It needs timeout retries, rate-limit backoff, and resumable collection from checkpoints.
- Parsing layer: key mapping, unit normalization, type conversion, and format validation.
- Buffer layer: a message queue to absorb peaks and smooth traffic, allowing downstream consumers to scale independently.
- Storage and compute layer: hot data goes to memory or a time-series store, cold data is archived to object storage, and derived metrics are generated by stream computing jobs.
3.1 Sample Parsing Code
from decimal import Decimalfrom datetime import datetimedef parse_snapshot(raw: dict) -> dict:last = Decimal(raw["Last price"])open_ = Decimal(raw["Open price"])high = Decimal(raw["High price"])low = Decimal(raw["Low price"])# Basic consistency check: low <= open/last <= highif not (low <= last <= high and low <= open_ <= high):raise ValueError("Price range validation failed")# Consistency check between change and change ratechange = Decimal(raw["24h change"])if abs((last - open_) - change) > Decimal("0.0001"):raise ValueError("Change does not match open-to-last difference")return {"symbol": raw["Symbol"],"pair": raw["Pair"],"last_price": str(last),"change_rate": Decimal(raw["24h change rate"].rstrip("%")),"market_cap": int(Decimal(raw["Market cap"].replace("million", "")) * 1000000),"rank": int(raw["Market cap rank"]),"update_time": datetime.fromisoformat(raw["Update time"]),}
This code reflects two principles: use decimal types for financial numeric computation, and enforce strong validation at the entry point, keeping dirty data out of the pipeline instead of letting it cause hard-to-diagnose failures downstream.
4. Data Quality Validation Rules
Build the following rules into the parsing layer, and separately sample failed records to storage for traceability:
- Range validation: low price ≤ open price and last price ≤ high price.
- Derived consistency: last price minus open price should approximately equal the 24-hour change; change divided by open price should approximately equal the change rate.
- Rank validity: market cap rank is a positive integer and is monotonically consistent with market cap ordering globally.
- Freshness validation: if the update time is older than a threshold (such as a few minutes) relative to the current time, mark the record as stale.
- Duplicate detection: use “pair + update time” as an idempotency key to prevent the same snapshot from being counted multiple times in statistics.
5. Storage Selection and Hot/Cold Tiering
Market data is a typical “write-heavy, read-light, query by time range” workload:
- Hot tier: data from the last few hours goes into memory or a time-series database to support real-time dashboards and short-term strategies.
- Warm tier: data from recent months is stored in a columnar format for range aggregation.
- Cold tier: full history is archived to object storage with compression and partitioned directories, which is very low cost and convenient for audit and replay.
A partition key of “date + pair” is recommended, so backtests can scan only relevant partitions and significantly reduce wasted reads.
6. Monitoring, Alerting, and Observability
Market data pipeline failures often happen silently: data keeps updating, but the values have already become distorted. Three categories of metrics are therefore needed:
- Freshness metric: the difference between the latest record’s update time and the current time.
- Completeness metric: the ratio of the actual number of stored pairs to the expected number.
- Consistency metric: validation failure rate and number of unit normalization anomalies.
Combined with general log service and monitoring/alerting capabilities, notifications can be triggered when metrics exceed thresholds, and distributed tracing can help determine whether the issue is ingestion timeout, parsing failure, or downstream write blocking.
7. Common Pitfalls and Best Practices
- Do not use floating point for price arithmetic, especially when computing change rates and aggregating market caps.
- Do not trust upstream field names; always apply a key whitelist mapping and handle missing fields with fallbacks.
- Do not ignore timezones; when mixing data across markets, time misalignment distorts statistical definitions.
- Do not pull the full dataset at once; use incremental cursors and rate-limit backoff to reduce throttling risk.
- Retain raw payloads so parsing rules can be replayed after changes, avoiding irreversible data loss.
8. Conclusion
Behind a market snapshot lies a full set of engineering constraints around modeling, precision, freshness, and quality. By clearly separating the four field categories (identity, price, statistics, metadata), enforcing strong validation and unit normalization at the entry point, and backing it with tiered storage and observability, you can build a stable and reliable market data foundation. Building on this, general capabilities such as the container platform, message queue, object storage, and log monitoring offered by Baidu AI Cloud can help move quickly from prototype to production, letting you focus on strategy and business logic itself.
