Market Data Collection and Parsing for Digital Assets: A Practical Guide
This article walks through the practical engineering of collecting and parsing digital asset market data, using a single spot ticker record as the starting point. It explains how to group fields into identity, price, statistics, and metadata sets, how to handle time semantics, precision, and numeric types, and how to design a layered ingestion pipeline. It also covers dirty data governance, observability, and cost control, with code examples and a reference architecture built on general-purpose cloud capabilities from Baidu AI Cloud.
1. Reading Data Structure from a Single Ticker Record
The raw sample is a spot market ticker: the trading pair is GLMUSDT, the market type is CRYPTO, the quote currency is USD, the latest traded price is 0.09129, the 24-hour change is 0.002597 (2.928%), the open price is 0.08869, and the values fluctuate within a range near a high of 0.09368 and a low of 0.08759. The market cap is about 90.5415 million, the market cap rank is 168, and the data update time is 2026-11-24 14:30:36.
For developers, the value of this record is not any specific number but the typical modeling problem it exposes: a single ticker contains four semantically different field types at once—price, statistics, ranking, and metadata. If you put them all into one wide table, aggregation, replay, and alignment will become expensive later.
The recommended abstraction is to split the fields into four groups:
- Identity group: trading pair, market type, and quote currency, used for routing and partitioning;
- Price group: latest, open, high, and low prices, which share the same unit and can be normalized for precision together;
- Statistics group: change amount, change percentage, market cap, and rank, which are derived metrics that can be recomputed rather than only stored;
- Metadata group: data timestamp, ingestion time, and source batch, used for idempotency and traceability.
{"symbol": "GLMUSDT","market": "CRYPTO","quote_currency": "USD","price": {"last": 0.09129, "open": 0.08869, "high": 0.09368, "low": 0.08759},"stats": {"change_24h": 0.002597, "change_pct_24h": 2.928, "market_cap": 90541500, "rank": 168},"meta": {"event_time": "2026-11-24T14:30:36Z", "ingest_time": "2026-11-24T14:30:38Z"}}
2. Time Semantics: The Most Error-Prone Part
Most hidden defects in market data systems come from time. You need to distinguish at least three timestamps: when the market event occurred, when the platform generated the record, and when it was stored locally. The 2026-11-24 14:30:36 in the sample is a “data update time,” which should be treated as the event time in engineering, not the collection time.
There are three standard practices: convert everything to timezone-aware UTC for storage; keep the original string for auditing; and explicitly declare whether timestamps are in seconds or milliseconds to avoid downstream misinterpretation. A sample validation logic is shown below:
from datetime import datetime, timezonedef normalize(ts: str) -> datetime:dt = datetime.strptime(ts, "%Y-%m-%d %H:%M:%S")return dt.replace(tzinfo=timezone.utc)def is_fresh(event_time: datetime, now: datetime, max_lag_sec: int = 120) -> bool:return (now - event_time).total_seconds() <= max_lag_sec
The latency threshold should be set according to the business: display use cases can relax it to minutes, while risk control or trigger logic needs a tighter threshold, and overdue data should be tagged rather than discarded outright.
3. Precision and Numeric Types
Prices and change percentages must never be stored directly as binary floating point. A decimal like 0.09129 accumulates tail differences during floating-point addition, and the 24-hour change amount and change percentage can become inconsistent (0.09129 − 0.08869 = 0.0026, which differs from 0.002597 due to source-side rounding).
Engineering recommendations:
- Keep the raw string on the collection side, and store fixed-point numbers or scaled integers on ingestion (for example, scale uniformly by 1e8 and store as integers);
- Always recompute derived metrics from the raw prices, with an explicit rounding rule;
- Validate identities: change amount ≈ latest price − price 24 hours ago; change percentage ≈ change amount / base price × 100, with a tolerance of several times the minimum price unit.
SCALE = 10 ** 8def to_int(x: str) -> int: return int(round(float(x) * SCALE))def change_pct(last: int, base: int) -> float:return (last - base) / base * 100 if base else 0.0
4. Layered Design of the Collection Pipeline
A robust market data pipeline is usually divided into four layers that communicate only through explicit contracts:
- Ingest layer: scheduled or incremental pulling, carrying cursors and batch numbers to guarantee replayability;
- Parsing layer: field mapping, unit normalization, and schema validation, with failures routed to a dead-letter queue;
- Storage layer: hot data goes into memory or a time-series database, while cold data is archived to object storage in a columnar format;
- Service layer: exposes the latest snapshot and historical range queries externally, with data timestamps attached.
On Baidu AI Cloud, this architecture can be carried by general-purpose capabilities: a message queue for buffering and peak shaving, object storage for cold data archiving, a container platform for stateless parsing services, and logging plus monitoring and alerting for observability. All components interact through standard protocols to avoid tight coupling to a single implementation.
5. Anomaly and Dirty Data Governance
Common market data problems include timestamp regression, price jumps, a high price lower than the low price, change percentages inconsistent with prices, and missing market cap rank. The governance strategy should be “tag first, discard cautiously”:
if high < low: tag = "RANGE_INVALID"elif abs(pct - recomputed) > tol: tag = "STATS_MISMATCH"elif event_time < last_event_time: tag = "TIME_REGRESSION"
Tagged data goes into a quarantine area for offline review. This keeps the online pipeline stable without losing potential real extreme market moves.
6. Observability and Cost
Monitoring should cover at least four metrics: collection success rate, end-to-end latency, parsing failure rate, and storage write volume. Alerts should be tiered: latency over the threshold triggers a warning first, and only after consecutive failed cycles does it escalate to error, avoiding noise. On cost, keep raw messages for a short time and aggregated results for a long time; hot and cold tiering can significantly reduce overhead.
7. Summary
A seemingly simple ticker record expands into four semantic types—identity, price, statistics, and metadata—plus five engineering gates: unified time, precision control, a layered pipeline, dirty data governance, and observability. Turn this approach into reusable components and deploy it on Baidu AI Cloud by combining general-purpose cloud capabilities, and you can obtain a stable, auditable, and scalable market data foundation at relatively low cost.
