Collecting and Parsing Crypto Market Data: A Practical Engineering Guide
This article walks through the engineering practice of collecting and parsing digital asset market data, using a single ticker snapshot as the starting point. It covers how to model identifier, price, derived, and statistical fields, why fixed-point precision and consistency checks matter, how to tier updates across real-time, warm, and cold storage, and how to handle outages, out-of-order data, and replay. It also outlines observability metrics such as source-time lag and consistency pass rate for building an accurate and durable market data foundation.
1. Starting with a Single Ticker Snapshot
The raw material is a typical digital asset market record: the symbol is GLM, the trading pair is GLMUSDT, the market type is CRYPTO, and the quote currency is USD. The latest price is 0.09359, the 24-hour change is 0.00009989, or 0.107%, with an open of 0.09349, a high of 0.09539, and a low of 0.09119. Market capitalization is roughly 93.7331 million, the cap rank is 164, and the data timestamp is 2026-12-01 19:50:38.
For developers, the value of this record is not any specific number but the fact that it represents the minimal unit of market data. Every market data system, quantitative backtesting framework, or asset dashboard depends on high-frequency repeated input of a field set like this. So the first step in engineering is not writing code, but defining field semantics, precision, and timeliness boundaries clearly.
2. Field Modeling: Turning Display Data into Computable Data
Market data fields fall into roughly four categories, and each should be modeled differently:
- Identifiers: symbol, trading pair, market type. Used for correlation and routing, and should be part of a composite primary key.
- Prices: latest, open, high, and low. These are high-precision floating-point or fixed-point values, and string-based arithmetic is forbidden.
- Derived: 24-hour change and change percentage. These can be derived from prices, and on ingestion you should mark whether they are upstream-computed to avoid discrepancies from recomputation.
- Statistics: market cap and cap rank. These update less frequently than prices and are slow-changing dimensions.
A practical schema sketch:
CREATE TABLE ticker_snapshot (symbol VARCHAR(16) NOT NULL,pair VARCHAR(24) NOT NULL,market_type VARCHAR(16) NOT NULL,quote_ccy CHAR(3) NOT NULL,last_price DECIMAL(18,8) NOT NULL,open_price DECIMAL(18,8) NOT NULL,high_price DECIMAL(18,8) NOT NULL,low_price DECIMAL(18,8) NOT NULL,change_24h DECIMAL(18,8),change_pct DECIMAL(12,6),market_cap DECIMAL(20,2),cap_rank INT,source_ts TIMESTAMP NOT NULL,ingest_ts TIMESTAMP NOT NULL,PRIMARY KEY (pair, source_ts)) PARTITION BY RANGE (source_ts);
The key point is keeping both source_ts (the upstream-stamped time) and ingest_ts (the local receive time). The difference between them is a core indicator of pipeline health and the first place to investigate problems like “the market looks frozen.”
3. Precision and Consistency: The Most Underestimated Pitfall
In the sample above, the latest price 0.09359 and the open 0.09349 differ by only 0.0001, yet the change percentage is 0.107%. This shows that for low-priced assets the absolute spread is tiny while the relative move is not negligible. There are three hard constraints in engineering:
- Use fixed-point or integer scaling throughout, avoiding binary floating-point tail errors during accumulation and comparison.
- Keep a single authoritative source for change and change percentage, deriving the other on read, to prevent the two from contradicting each other.
- The high and low must satisfy the containment relation
low <= open,last <= high. Assert this before ingestion, and route anomalous data to an isolation table rather than discarding it outright.
from decimal import Decimaldef validate(row: dict) -> bool:low, high = Decimal(row["low_price"]), Decimal(row["high_price"])last = Decimal(row["last_price"])if not (low <= last <= high):return Falsederived = (last - Decimal(row["open_price"])) / Decimal(row["open_price"])return abs(derived * 100 - Decimal(row["change_pct"])) < Decimal("0.01")
4. Timeliness Tiering: Updating Different Fields at Different Cadences
Price fields change by the second, while market cap and rank change by the minute or even the hour. Refreshing everything at the same frequency wastes bandwidth and write capacity. The recommended approach is tiering:
- Real-time layer: latest price, the four prices, and change percentage, kept in memory or a time-series store with a short retention window.
- Warm layer: minute-level aggregates (candles, means, extremes) written to a time-series database for dashboards and alerting queries.
- Cold layer: full snapshots archived to object storage, partitioned by date, for backtesting and auditing.
Pairing hot/cold tiering with a message queue for peak shaving keeps upstream jitter from overwhelming downstream databases. Consumers should implement idempotent writes, deduplicating on (pair, source_ts) so that redelivery does not produce duplicate rows.
5. Reliability Design: Outages, Out-of-Order Data, and Replay
The three most common failures in a market data pipeline are stream interruptions, out-of-order data, and duplicates. Corresponding strategies:
- Outage detection: maintain a “last successful time” per symbol and trigger monitoring alerts when it exceeds a threshold.
- Out-of-order handling: filter with a watermark based on
source_ts, discarding records older than the current watermark or routing them to a side path. - Replay capability: the cold layer archive must be replayable by time range, and replay must share the same parsing and validation logic as the real-time path to avoid behavioral drift between two codebases.
On the cloud, you can combine a container platform to host stateless parsing services, a message queue for buffering, a time-series database for queries, object storage for archiving, and logging plus monitoring and alerting for observability. In these scenarios Baidu AI Cloud is typically supported by a general combination of “compute + storage + observability,” and the specific selection should be decided after load testing based on data scale and latency targets.
6. Observability and Quality Metrics
It is advisable to expose four metrics externally: ingestion rate, parse failure rate, source-time lag distribution, and validation rejection count. Among these, the P99 of “source-time lag” best reflects the real experience and is more diagnostically valuable than average latency. The quality dashboard should show both data completeness (the non-null ratio of fields) and consistency pass rate, and any one of them falling below baseline should be treated as a data incident rather than business fluctuation.
7. Summary
A seemingly simple ticker record expands into a complete engineering problem across five dimensions: identity, precision, timeliness, reliability, and observability. Define field semantics and time semantics clearly first, then use tiered storage and idempotent consumption to absorb high-frequency writes, and finally close the loop with lag and consistency metrics. Only then can you build a market data foundation that is both accurate and durable.
