Market Data Collection and Parsing for Digital Assets: A Practical Guide
This article walks through the practical challenges of collecting and parsing digital asset market data, using a sample ticker snapshot to expose common issues around field semantics, timestamp time zones, and missing or anomalous values. It covers a three-layer field model (identity, price, and statistics), precision handling with fixed-point or string values, UTC-based time semantics and stale-data detection, hard versus soft validation, a four-stage pipeline architecture, observability and cost control, and five frequent design mistakes to avoid. Readers will gain a clear blueprint for building a reliable market data foundation for indicators, backtesting, and risk control.
1. Starting from a Single Ticker Snapshot
In the development of digital asset systems, market data is the most fundamental and most easily underestimated component. Many teams focus their energy on trade matching and strategy backtesting, only to get bogged down early on by inconsistent field definitions, chaotic timestamp time zones, and poor handling of missing values and outliers. Let’s start with a sample snapshot used to illustrate the problems (the data is for structural demonstration only and is not a live quote):
{"symbol": "GLMUSDT","market_type": "CRYPTO","base_asset": "GLM","quote_asset": "USDT","last_price": 0.09359,"quote_volume_24h_change": 0.00009989,"change_percent_24h": 0.107,"open_price_24h": 0.09349,"high_price_24h": 0.09539,"low_price_24h": 0.09119,"market_cap_usd": 93733100,"market_cap_rank": 164,"quote_currency": "USD","updated_at": "2026-12-01T19:50:38"}
This record does not carry much information, yet it is already enough to expose the problems that most market data pipelines encounter: the quote currency of the trading pair does not match the quote currency of the price, it is unclear whether the change percentage is an absolute percentage or a decimal ratio, the update time lacks a time zone, and market cap and rank are aggregated statistics rather than tick-by-tick trades. Thinking these points through clearly will prevent repeated rework in the architecture design that follows.
2. Field Modeling: Unify Semantics First, Then Talk About Performance
The difficulty of market data lies not in write throughput but in semantic consistency. It is recommended to divide fields into three layers.
The first layer is the identity layer, including the trading pair, base asset, and quote asset, plus the market type. The market type must be distinguished explicitly, because different market types differ greatly in trading sessions, precision rules, and settlement methods. Mixing them in one table makes subsequent aggregation logic fragile.
The second layer is the price layer, containing the last price, open price, high price, and low price. Here you must define a clear precision strategy: prices and quantities should be carried as fixed-point numbers or strings to avoid the errors that binary floating point introduces during accumulation. An illustrative modeling approach is shown below:
from decimal import Decimalclass TickerSnapshot:def __init__(self, raw: dict):self.symbol = raw["symbol"]self.market_type = raw["market_type"]self.last = Decimal(str(raw["last_price"]))self.open = Decimal(str(raw["open_price_24h"]))self.high = Decimal(str(raw["high_price_24h"]))self.low = Decimal(str(raw["low_price_24h"]))def is_consistent(self) -> bool:return self.low <= self.last <= self.high
The third layer is the statistics layer, including market cap, market cap rank, and 24-hour change amount and change percentage. Data in this layer is aggregated upstream and typically updates less frequently than the price layer. Therefore it should not share the same storage and refresh cadence as tick-level or second-level data, which would otherwise cause a large number of ineffective writes.
3. Time Semantics: The Most Common Hidden Defect in Market Data Systems
The update time in the example carries no time zone information, which is a high-frequency problem when actually integrating third-party data sources. In engineering, two principles should be upheld: internally, always store time in UTC with a time zone, and convert to the user’s time zone only at the presentation layer; for upstream data missing a time zone, explicitly declare its assumed time zone at the ingestion layer and write it into metadata, rather than letting each downstream consumer guess.
Another easily overlooked point is determining “stale data.” A market data pipeline must be able to identify whether data has stopped updating. The basis for this judgment is not simply local time minus the latest time, but should combine the historical update-interval distribution of that trading pair and use a dynamic threshold to trigger alerts. A fixed threshold produces continuous false positives on low-frequency trading pairs and reacts sluggishly on high-frequency ones.
4. Data Validation and Outlier Handling
Validation should be divided into hard validation and soft validation. If hard validation fails, the record is discarded and counted into error metrics—for example, the high price being lower than the low price, a non-positive price, or a missing required identity field. Soft validation marks the record and lets it through, leaving the downstream to decide whether to use it—for example, when the change percentage deviates beyond tolerance from the result computed from the open price and last price.
Change percentage consistency check (illustrative)expected = (last - open) / open * 100if abs(expected - reported) > tolerance -> mark for review
It must be emphasized that aggregate fields such as market cap and rank are not suitable for strict self-consistency validation, because they depend on a whole-market scope and cannot be verified from a single record. A more appropriate approach for such fields is trend monitoring: when the rank jumps sharply within a short period, or market cap diverges from trading activity over the long term, trigger a manual review rather than an automatic discard.
5. Pipeline Architecture: Ingestion, Buffering, Computation, Serving
A practical layered architecture typically consists of four stages. The ingestion layer handles multi-source adaptation and protocol conversion, mapping fields from different upstreams to a unified model and completing unit and precision normalization here. The buffering layer uses a message queue for peak shaving and decoupling, so upstream jitter does not directly impact computation and storage. The computation layer splits into real-time and offline paths: the real-time path handles the last price and short-cycle indicators, while the offline path handles heavy aggregation tasks such as market cap and rank. The serving layer outputs data to strategies, dashboards, and risk control systems through interfaces, with unified rate limiting and caching.
For storage selection, hot-cold separation is a common practice: hot data retains the most recent several days for real-time queries, while warm and cold data lands in object storage and is archived by partition for easy backtracking and recomputation. Data flows automatically between hot and cold tiers through lifecycle policies, avoiding manual operations.
6. Observability and Cost Control
Monitoring for a market data system should cover at least four types of metrics: ingestion latency, parsing failure rate, data staleness duration, and end-to-end consistency deviation. Baidu AI Cloud’s monitoring and alerting capabilities can be used to set tiered thresholds on these metrics, separating “data has stopped updating” from “data quality has degraded” into different alert channels to avoid alert fatigue.
The key to cost control lies in sampling and aggregation tiers. Retaining all raw tick data in full over the long term is costly, so usually only the parts that need auditing are archived in full, while the rest is aggregated progressively by minute and by hour and then kept long term. A combination of log services and object storage can support this tiered retention while ensuring computability during backtracking.
7. Summary of Common Mistakes
First, using floating point directly for accumulating amounts and prices, where the error is amplified in long-cycle backtests. Second, mixing the statistics layer and the price layer in the same write path, causing wasted resources and mutual contamination of latency. Third, lacking time zone and precision metadata, making cross-source data impossible to align. Fourth, using a fixed threshold to judge data freshness, producing a large number of ineffective alerts. Fifth, treating aggregate fields as self-consistency-verifiable fields and mistakenly discarding normal data.
Handling these five points upfront in the design phase will noticeably improve the stability and maintainability of the market data pipeline, and only then will subsequent indicator computation, backtesting, and risk control have a reliable data foundation.
