Market Data Collection, Parsing, and Monitoring for Digital Assets
This article walks through the engineering practices behind digital asset market data, using a sample ticker snapshot to explain field semantics, numeric precision, data consistency, and timestamp reliability. It outlines a four-layer collection pipeline, validation logic, freshness governance, and monitoring metrics, and shows how the overall architecture can run on Baidu AI Cloud with stateless services for elastic scaling.
1. Introduction: The Engineering Behind a Market Data Snapshot
In a digital asset trading system, market data is the foundation for every upper-layer capability. Quantitative strategies, risk engines, and front-end dashboards all depend on a data pipeline that is stable, accurate, and low-latency. Below is a typical market snapshot (the data is for structural illustration only):
{"symbol": "GLM","pair": "GLMUSDT","market_type": "CRYPTO","name": "Golem","last_price": 0.09119,"currency": "USD","price_change_24h": 0.002497,"price_change_percent_24h": 2.815,"open_price_24h": 0.08869,"high_price_24h": 0.09368,"low_price_24h": 0.08759,"market_cap": 90541500,"market_cap_rank": 168,"update_time": "2026-11-24 14:37:24"}
A single record like this looks simple, but it actually carries five categories of information: price, range statistics, market cap estimation, ranking, and a timestamp. From an engineering standpoint, three questions must be answered: Are the field semantics clear? Are the values self-consistent? Is the timestamp trustworthy? This article addresses these three points.
2. Field Semantics and Data Modeling
2.1 Identifier Fields
symbol and pair describe the asset itself and the trading pair, respectively. The former is the unique short identifier of an asset, while the latter is a combination of “base asset + quote asset.” market_type distinguishes market types such as spot and derivatives. Different market types vary greatly in funding rates, minimum tick size, and precision rules, so it should be modeled as a partition key or routing field rather than an ordinary enum.
2.2 Price Fields
Price fields include the latest price, 24-hour open, 24-hour high, and 24-hour low. The most error-prone issue here is precision. For assets priced below 1, floating-point numbers may produce trailing discrepancies during serialization and deserialization. It is recommended to carry values uniformly as fixed-point numbers or strings, and convert them to a high-precision decimal type only when performing calculations:
from decimal import Decimal, ROUND_HALF_UPdef to_decimal(value: str) -> Decimal:return Decimal(value).quantize(Decimal("0.00001"), rounding=ROUND_HALF_UP)last = to_decimal("0.09119")open_ = to_decimal("0.08869")change = last - open_percent = (change / open_ * 100).quantize(Decimal("0.001"))# change = 0.02500, percent = 2.818
2.3 Statistics and Market Cap Fields
The change percentage is essentially a derived field that can be inferred from the latest price and the open price. In the example above, the result calculated at the original precision is about 2.818%, which differs slightly from the 2.815% given in the snapshot. This indicates that the upstream source may use a different sampling window or weighting method. The correct engineering practice is to store derived fields separately from raw fields and retain “calculation basis” metadata, preventing downstream recomputation from causing basis drift.
Market cap equals price multiplied by circulating supply, and the rank is the position of an asset across the whole market in descending order by market cap. Ranking is extremely sensitive to data freshness and usually needs to be cached separately with a short expiration time.
3. Collection Pipeline Design
A reliable collection pipeline is typically divided into four layers:
- Ingestion layer: Subscribe to incremental push updates over a persistent connection, while keeping scheduled polling as a fallback to avoid data gaps caused by connection interruptions.
- Parsing layer: Deserialize raw messages into a unified internal model, with normalized field naming and unified units.
- Validation layer: Perform range checks, consistency checks, and freshness checks.
- Storage and distribution layer: Hot data goes into an in-memory cache, historical data is written to object storage or a time-series database, and changes are broadcast to downstream consumers via a message queue.
Illustrative validation logic:
def validate(snapshot) -> list[str]:errors = []if not (snapshot["low"] <= snapshot["last"] <= snapshot["high"]):errors.append("price_out_of_range")if snapshot["open"] <= 0:errors.append("invalid_open")if snapshot["market_cap_rank"] <= 0:errors.append("invalid_rank")if is_stale(snapshot["update_time"], max_lag_seconds=5):errors.append("stale_data")return errors
4. Timestamp and Freshness Governance
The update time in the snapshot is precise to the second but carries no timezone information, which is a common pitfall in cross-system collaboration. The recommended practice is to use timezone-aware UTC time internally and render it in the user’s timezone at the presentation layer. Freshness judgment should not rely solely on the absolute time difference; it must also account for business tolerance. Display scenarios can tolerate delays of several seconds, while risk control and matching scenarios often require sub-second freshness.
5. Monitoring, Alerting, and Fault Tolerance
At a minimum, four categories of metrics should be covered: data latency distribution, validation failure rate, field missing rate, and price jump magnitude. For price jumps, percentage-based threshold alerts can be configured and combined with cross-comparison across multiple data sources to avoid false positives triggered by a single anomaly. Alerting channels can rely on the cloud provider’s monitoring, alerting, and logging services, while the pipeline itself can be deployed on a container platform for elastic scaling.
6. Running on the Cloud
On Baidu AI Cloud, the collection and parsing services can run on a container platform, a message queue can handle data distribution, object storage can hold historical snapshots, and monitoring, alerting, and logging services can complete observability. Keeping the overall architecture stateless makes it easy to auto-scale in response to traffic peaks driven by market volatility.
7. Conclusion
The value of market data lies not in “fetching it,” but in “fetching it correctly, stably, and quickly.” Only when field semantics, precision handling, calculation-basis management, and freshness governance are done solidly can upper-layer strategies and displays rest on a reliable foundation.
