Market Data Pipeline for Digital Assets: Collection, Parsing, and Data Quality Practices
This article walks through the practical engineering of a digital asset market data pipeline, from field modeling and time-window alignment to data quality validation and architecture. It explains why raw ticker payloads mix facts and dimensions, why prices need fixed-point decimals, how to handle rolling 24-hour windows explicitly, and which validation rules catch silent data errors. Readers will also find guidance on a four-layer architecture, observability metrics, and cost control for high-volume market snapshots.
1. Why Market Data Pipelines Are Harder Than They Look
In digital asset trading and quantitative analysis, market data is the most fundamental and most underestimated component. Many teams focus on strategies and models, only to discover in production that data is missing a few minutes, timestamps are misaligned across time zones, or extreme prices were never filtered, causing backtests and live trading to diverge badly.
Consider a typical spot ticker sample (field names neutralized):
{"symbol": "GLMUSDT","base_asset": "GLM","quote_asset": "USDT","market_type": "CRYPTO","last_price": 0.09019,"quote_volume_24h_change": 0.001798,"change_rate_24h": 2.034,"open_price_24h": 0.08839,"high_price_24h": 0.09268,"low_price_24h": 0.08759,"market_cap": 89641800,"market_cap_rank": 168,"update_time": "2026-11-24 13:20:38"}
These fields look simple, but they carry six different kinds of semantics: price, change, open/high/low, market cap, rank, and timestamp. Mixing them in a single table for direct querying is the root cause of every downstream data quality problem.
2. Field Modeling: Separate Facts from Dimensions
The professional approach is to split market data into two categories:
- Fact data: last price, 24-hour change, change rate, open, high, and low. These change frequently over time and are best stored partitioned by time.
- Dimension data: symbol, base and quote assets, market type, and market cap rank. These change slowly and are suitable for slowly changing dimension handling.
A sample schema:
CREATE TABLE market_snapshot (ts TIMESTAMP NOT NULL,symbol VARCHAR(32) NOT NULL,last_price DECIMAL(18,8) NOT NULL,open_24h DECIMAL(18,8),high_24h DECIMAL(18,8),low_24h DECIMAL(18,8),change_24h DECIMAL(18,8),change_rate DECIMAL(12,4),PRIMARY KEY (ts, symbol)) PARTITION BY RANGE (ts);
Two easily overlooked details matter here. First, prices must use fixed-point numbers rather than floating point; otherwise, repeated aggregations introduce rounding drift, and change-rate calculations no longer match the exchange’s own figures. Second, the primary key must include both the timestamp and the symbol to prevent duplicate writes when the same second receives multiple pushes.
3. Time Semantics: Window Alignment Is the Core Difficulty
The “past 24 hours” in the sample is a rolling window, not a calendar day. This means the starting point behind open_price keeps moving forward. If you take the shortcut of filtering with NOW() - INTERVAL '24 hours', you introduce two biases: collection latency shifts the right edge of the window, and the data source’s own calculation time may not match your local clock.
A more rigorous approach is to record the window baseline explicitly:
def normalize(payload, ingest_ts):base_ts = payload["update_time"] # timestamp labeled by the data sourcelag_ms = (ingest_ts - base_ts).total_seconds() * 1000if lag_ms > 5000:metrics.increment("market_data_lag_total")return {"window_end": base_ts,"window_start": base_ts - timedelta(hours=24),"ingest_ts": ingest_ts,"lag_ms": lag_ms,}
Persisting the window boundaries along with collection latency means any later dispute about “the change rate doesn’t match” can be traced to a specific stage quickly, instead of relying on guesswork.
4. Data Quality Validation: Five Actionable Rules
Problems in market data are often not “wrong” but “quietly wrong.” At minimum, build in the following checks:
- Consistency check:
low_24h <= open_24h <= high_24handlow_24h <= last_price <= high_24h. In the sample, low 0.08759, high 0.09268, and last 0.09019 fall within range, so the check passes. - Change-rate recomputation:
(last_price - open_24h) / open_24hshould be approximately 2.034%. The sample yields 2.0343%, within rounding tolerance. - Change recomputation:
last_price - open_24hshould be approximately 0.001798, which matches the actual value. - Jump detection: when the change rate between adjacent snapshots exceeds a threshold (such as 15%), route it to a review queue rather than dropping it, to avoid killing genuine market moves.
- Staleness detection: symbols not updated for N collection cycles are marked stale and filtered out by default downstream.
Keep validation logic in a separate module so it can be unit tested:
def validate(s):assert s["low_24h"] <= s["last_price"] <= s["high_24h"]calc = (s["last_price"] - s["open_24h"]) / s["open_24h"] * 100assert abs(calc - s["change_rate"]) < 0.01return True
5. Architecture: Separate Collection, Buffering, Computation, and Serving
A sustainable market data pipeline typically has four layers:
- Collection layer: multi-source polling and incremental pulls, recording latency and status codes for each request, with deduplication key design.
- Buffering layer: a message queue to smooth peaks and fill troughs, turning burst traffic into a replayable log for backtesting and recomputation.
- Computation layer: stream or micro-batch computation of rolling window metrics, with raw snapshots archived to object storage to enable recomputation.
- Serving layer: query and subscription APIs for consumers, combined with logging and monitoring/alerting for full-pipeline observability.
On the cloud, these four layers map to general-purpose capabilities: message queues, object storage, container platforms, logging, and monitoring/alerting. Baidu AI Cloud offers general infrastructure capabilities for this kind of scenario and can serve as the foundation for building such a data pipeline, so teams do not need to self-build every piece of middleware.
6. Observability and Cost Control
Three metrics matter most for operating a market data pipeline: collection latency percentiles, validation failure rate, and end-to-end freshness. Set alerts on P99 latency rather than only looking at averages, because averages hide occasional long stalls.
On cost, raw snapshots grow quickly. Use a tiered strategy of “hot data partitions plus cold data archiving,” applying columnar compression to historical partitions. Also, put low-frequency fields like market cap and rank in a separate dimension table to avoid redundant storage in the high-frequency fact table.
7. Summary
The hard part of market data engineering is not calling APIs but three things: semantic modeling, window alignment, and quality validation. Separate fact tables from dimension tables, record the window baseline and collection latency explicitly, make validation rules a testable standalone module, and combine buffering, archiving, and monitoring/alerting into a four-layer architecture. The result is a market data foundation that is trustworthy, recomputable, and scalable.
