Engineering Digital Asset Market Data: Collection, Validation, and Visualization
This article walks through the engineering practices for handling digital asset market data, from snapshot modeling and precision handling to validation, layered storage, and visualization. It explains how to design a stable three-layer data model, detect anomalies such as zero-change snapshots, stale updates, and out-of-range values, and build an observable pipeline using message queues, container platforms, object storage, logging, and monitoring. Developers will learn how to turn raw market snapshots into reliable, computable, and observable data assets.
1. Why Market Data Needs Engineering Governance
In digital asset business systems, market data is often the most fundamental and most underestimated component. A seemingly simple snapshot usually contains more than a dozen fields: trading symbol, market type, latest price, quote currency, 24-hour change amount and percentage, open, high, low, market cap, market cap rank, and update time. There are not many fields, but they directly drive the price curves, market cap rankings, and change rankings in the presentation layer, as well as risk control and alerting logic in the backend.
Consider a typical snapshot (the data is only used to illustrate the structure):
{"symbol": "GLM","pair": "GLMUSDT","market": "CRYPTO","name": "Golem","last": 0.09359,"quote_currency": "USD","change_24h": 0,"change_pct_24h": 0.000,"open": 0.09359,"high": 0.09539,"low": 0.09119,"market_cap": 93733100,"rank": 164,"updated_at": "2026-12-01 19:56:40"}
Several engineering signals stand out in this data: the latest price is exactly equal to the open price, the change amount and change percentage are both zero, and there is roughly a 4.6% range between the high and the low. This means “zero change” does not equal “no movement”; rather, the reference baseline changed within the collection window, or the data has not refreshed yet. If a downstream system interprets a zero change percentage as “the market is static,” it will produce clear misdirection in charts and rankings.
2. Data Model Design: Turning Snapshots into Computable Structures
The first step in engineering is to define a stable data model. It is recommended to split a market snapshot into three layers:
- Identity layer: trading symbol, trading pair, market type, name, quote currency. This layer is basically immutable and suitable as a primary key and cache key.
- Numeric layer: latest price, open, high, low, change amount, change percentage, market cap. This layer needs unified precision and units.
- Metadata layer: market cap rank, data update time, collection time, data source batch number. This layer is used to judge freshness and consistency.
A common pitfall is precision handling. Price fields should use fixed-point numbers or strings to avoid tail differences caused by binary floating point during accumulation and comparison; change percentage is best stored as a decimal (0.0463 means 4.63%) and multiplied by 100 for formatting in the presentation layer. Example code:
from decimal import Decimal, ROUND_HALF_UPdef normalize(raw: dict) -> dict:price = Decimal(str(raw["last"]))return {"symbol": raw["symbol"],"pair": raw["pair"],"last": price.quantize(Decimal("0.00001"), ROUND_HALF_UP),"change_pct": Decimal(str(raw["change_pct_24h"])) / Decimal("100"),"high": Decimal(str(raw["high"])),"low": Decimal(str(raw["low"])),"updated_at": raw["updated_at"],}
3. Validation and Anomaly Detection: Zero Change, Stale Updates, and Out-of-Range Values
Data quality determines the trustworthiness of upper-layer business. At least four types of validation are recommended:
- Range validation: low ≤ last ≤ high; the open price should fall within the day’s range. In the example above, the open equals the last price, which is a legal but noteworthy state.
- Consistency validation: the change amount should satisfy
change = last - openwith the last price and open, and the change percentage should satisfychange_pct = change / open. If the three contradict each other, the data comes from different batches. - Freshness validation: subtract the update time from the current time; if it exceeds a threshold (for example, 60 seconds), mark it as stale, and the presentation layer should degrade to “delayed data.”
- Zero-value semantic validation: when the change amount and change percentage are both zero but the range is non-zero, mark it as “baseline switch / not refreshed” rather than “market static.”
def is_stale(updated_at, now, threshold_seconds=60):return (now - updated_at).total_seconds() > threshold_secondsdef is_suspect(d):return d["change_24h"] == 0 and d["high"] != d["low"]
4. Collection and Storage: Layered Caching and Batch Writes
On the collection side, a “scheduled pull + incremental comparison” pattern is recommended. Scheduled tasks fetch full snapshots at fixed intervals, first perform a hash comparison against the previous version in memory, and only write to the database when the numeric layer changes, which can significantly reduce write pressure. Storage is divided into hot, warm, and cold layers: hot data is kept in memory or a high-performance cache for real-time queries; warm data is written to a time-series database or relational table, retaining minute-level granularity; cold data is archived to object storage for offline backtesting and auditing.
On Baidu AI Cloud, this architecture can be fully implemented with general-purpose capabilities: use a message queue to decouple and buffer between collection and processing, use a container platform to host collection and computation tasks, use object storage for cold data archiving, use a logging service to record collection batches and anomaly details, and use monitoring and alerting to notify about stale and out-of-range conditions in real time. The key is to make the “collect—validate—store—present” pipeline observable, with metrics at every stage.
5. Visualization and Alerting: Making Anomalies Visible
The presentation layer needs to distinguish three states: normal, delayed, and abnormal. The normal state displays price and change percentage; the delayed state annotates data lag next to the timestamp; the abnormal state hides the change percentage or shows a placeholder to avoid misdirection. On charts, it is recommended to plot both the latest price and the high-low range, using shading to represent the range, so that the “zero change but 4.6% range” case in the example is recognizable at a glance.
On the alerting side, three types of rules are recommended: stale alerts (update time exceeds threshold), out-of-range alerts (price breaks the day’s high or low, or validation fails), and spike alerts (change percentage between adjacent sampling points exceeds a set threshold). Rules should support silence windows and aggregation to avoid alert storms caused by jitter.
6. Summary
The value of market data lies not in “getting a snapshot,” but in turning the snapshot into a trustworthy, computable, and observable data asset. Through clear data layering, strict field validation, accurate understanding of boundary semantics such as zero change, and a combination of layered storage and visualization alerting, developers can build a stable market data service. Applying this approach to general capabilities such as object storage, message queues, container platforms, logging services, and monitoring and alerting on Baidu AI Cloud completes the loop from collection to presentation without relying on any proprietary interfaces.
