Engineering Digital Asset Market Data: Collection, Validation, and Real-Time Display
This article presents a practical engineering approach to handling digital asset market data, covering snapshot field modeling, a layered collection pipeline with backpressure control, three-tier consistency validation, two-level caching, and monitoring with replayability. It shows how to turn one-off price snapshots into a verifiable, traceable, and scalable data flow that can support downstream analysis and decision-making.
1. Why Market Data Needs Engineering Governance
In digital asset trading and quantitative analysis, market data is the most fundamental and most sensitive input. A seemingly simple snapshot record usually contains fields such as the trading pair identifier, latest traded price, open price, high price, low price, change amount, change percentage, market capitalization, and update time.
For example, one captured snapshot showed the pair GLMUSDT with a latest price of 0.09359 USD, a 24-hour change amount and change percentage of both 0, an open price equal to the latest price, a high of 0.09539, a low of 0.09119, a market cap of roughly USD 93.7331 million, a market cap rank of 164, and an update time of 2026-12-01 19:52:38.
If this kind of data stays only at the presentation layer, its value is limited. What really determines system quality is collection frequency, field consistency, anomaly detection, and traceability. Engineering teams need to turn a one-off snapshot into a data stream that can be consumed continuously.
2. Field Modeling: Breaking Snapshots into Verifiable Structures
It is recommended to model a market snapshot in three layers:
- Identity layer: asset code, trading pair, market type (e.g., CRYPTO), and quote currency.
- Price layer: latest price, open price, high price, low price, change amount, and change percentage.
- Statistics layer: market capitalization, market cap rank, and data update time.
An illustrative structure looks like this:
{"symbol": "GLM","pair": "GLMUSDT","market": "CRYPTO","quote_currency": "USD","price": {"last": 0.09359,"open": 0.09359,"high": 0.09539,"low": 0.09119,"change": 0.0,"change_pct": 0.0},"stats": {"market_cap": 93733100,"rank": 164},"ts": "2026-12-01T19:52:38Z"}
The key benefit of this modeling is that fields become verifiable, versionable, and alignable across sources. For instance, the high price must be greater than or equal to both the latest and open prices, while the low price must be less than or equal to both. The change percentage and change amount should satisfy change_pct ≈ change / open × 100%. When the change is 0 but the high and low still show a range, it suggests the statistics window and the price sampling window may be inconsistent; such a record should be flagged as “pending confirmation” rather than written directly to storage.
3. Collection Pipeline: Layered Decoupling and Backpressure Control
A layered architecture of “collector — message queue — compute layer — storage layer — display layer” is recommended. The collector is only responsible for pulling data and writing raw records to disk, without complex computation. The message queue handles peak shaving and decoupling. The compute layer performs cleaning and metric aggregation. The storage layer separates hot data from cold data. The display layer reads only validated data.
Backpressure control becomes especially important during traffic spikes. You can set a queue backlog threshold; once it is exceeded, reduce the collection frequency of non-critical assets and prioritize high market cap, high rank assets. Illustrative logic:
def should_sample(item, backlog):if backlog > 10000:return item["stats"]["rank"] <= 200return True
Baidu AI Cloud’s message queue, object storage, and logging services can serve as general-purpose infrastructure for this pipeline, but specific parameters should be based on actual load testing results, avoiding preset performance metrics that have not been confirmed.
4. Consistency Validation: Turning “Looks Right” into “Provably Right”
Validation should be divided into three levels:
- Structural validation: reject records directly if fields are missing, types are wrong, or time formats are invalid.
- Business validation: check price ranges, the change percentage formula, and the reasonableness of market cap and rank.
- Time-series validation: check whether price jumps between adjacent snapshots of the same pair exceed a threshold, and whether timestamps are monotonic.
For timestamps, it is recommended to use UTC consistently and retain millisecond precision. If the collection side and the display side handle time zones inconsistently, it can create the illusion of “same update time but different values.” For the zero-change scenario, the sampling window length should be recorded additionally; otherwise it is impossible to tell whether it is a genuine flat market or stalled data.
5. Caching and Refresh Strategy
Market data display is latency-sensitive, but reading storage directly at high frequency amplifies cost. A two-level cache can be used: a local in-memory cache holds the most recent validated snapshot, while a distributed cache holds a shared view across instances. An “event-driven plus scheduled fallback” refresh strategy is recommended: a new snapshot updates the cache immediately after passing validation; at the same time, a fixed-period forced re-fetch from the source prevents permanent staleness caused by lost messages.
on_valid_snapshot(s):local_cache.put(s.pair, s)if s.ts > shared_cache.get(s.pair).ts:shared_cache.put(s.pair, s)
6. Monitoring, Alerting, and Traceability
Monitoring should cover at least four categories of metrics: collection latency, validation failure rate, queue backlog, and cache hit rate. Alerts should be tiered to avoid noise. All raw snapshots should be written to object storage and partitioned by time, making replay and recomputation easy. When market cap rank or price anomalies occur, the view at that time can be reconstructed from the raw snapshots to determine whether the issue lies in the source data or the computation logic.
7. Conclusion
The core of a market data system is not “getting a price,” but establishing a verifiable, traceable, and scalable data contract. Through field modeling, layered collection, three-tier validation, two-level caching, and full-pipeline monitoring, teams can build a stable and reliable market data service on general-purpose cloud infrastructure such as Baidu AI Cloud, providing a solid foundation for subsequent analysis and decision-making.
