Market Data Collection and Parsing for Digital Assets: A Practical Guide
This article walks through the engineering work behind collecting and parsing digital asset market data, using a single spot ticker snapshot as the starting point. It covers field modeling and data contracts, strongly typed ticker structures, the difference between event time, collection time, and ingestion time, layered data quality validation, polling with watermarks for incremental collection, two-tier storage with recomputable derived metrics, and observability and cost control. Readers will get a practical blueprint for building a trustworthy and scalable market data pipeline.
1. Starting From a Single Ticker Snapshot
When building a market data application, the first problem to solve is not the UI but how to model the data and establish trust in it. Below is a typical spot market snapshot (fields organized for clarity):
Symbol: GLMUSDTMarket Type: CRYPTOBase Asset: GLMLast Price: 0.09359Quote Currency: USD24h Change: +0.0000998924h Change %: +0.107%Open: 0.09349High: 0.09539Low: 0.09119Market Cap: ~93.7331MMarket Cap Rank: 164Event Time: 2026-12-01 20:01:40
This record is small, yet it covers almost every element a market data system must handle: instrument definition, price dimensions, interval statistics, valuation metrics, and a time reference. Treating it as a minimal viable sample and layering validation and pipeline capabilities onto it is the safest way to move forward.
2. Field Modeling: Turning Display Language Into a Data Contract
The biggest trap in market data fields is that everything “looks like a price” while the semantics are completely different. Model them in four groups:
- Instrument info: base asset, quote asset, symbol, market type. The symbol is one of the primary keys, and the market type (spot, derivatives, etc.) determines which fields apply. The two should be jointly unique.
- Point prices: last, open, high, low. They must satisfy
low <= open/last <= high. This is the cheapest and most effective first validation. - Interval statistics: 24h change and 24h change percentage. They should satisfy
change % ≈ change / (last - change). A mismatch beyond tolerance suggests the data was stitched together from snapshots taken at different times. - Valuation and ranking: market cap and rank. Market cap is usually circulating supply multiplied by price, making it a derived metric that should not be the single source of truth.
In implementation, use strongly typed structs and avoid passing numbers around as strings in the business layer:
type Ticker struct {Symbol string // e.g. GLMUSDTMarketType string // market typeBase string // base assetQuote string // quote currencyLast float64 // last priceOpen24H float64 // 24h openHigh24H float64Low24H float64ChangeAbs float64 // absolute changeChangePct float64 // percentage changeQuoteVol float64 // quote volume (optional)EventTime int64 // event time, Unix milliseconds}
Note that prices should be stored as fixed-point or high-precision decimal types. Binary floating point produces visible errors after repeated aggregation. The float64 above is for illustration only; in production, switch to a decimal-style implementation.
3. Time Semantics: The Detail That Causes the Most Incidents
The “update time” in a snapshot is the time reference for the entire pipeline. Three concepts must be distinguished:
- Event time: the actual moment the trade or statistic occurred;
- Collection time: when the local fetch completed;
- Ingestion time: when the record was written to storage.
Mixing them leads to “out-of-order overwrites” when backfilling. The practical rule: sort and deduplicate by event time, measure pipeline latency by collection time, and use ingestion time only for auditing. Store everything in UTC and localize only at the presentation layer, so cross-timezone teams do not misdiagnose data as “a few hours late.”
latency = collection time - event timeif latency > threshold (e.g. 5s), emit an alert metric instead of dropping the data
4. Data Quality Validation: Layered Defense
Place validation at different points in the pipeline to build depth:
- Ingestion layer: reject records with missing fields, wrong types, or negative values, and log a digest of the raw payload for traceability;
- Rule layer: high/low containment, consistency between change and change percentage, and reasonable magnitude between market cap and price;
- Time-series layer: event time for the same symbol must be monotonically increasing; a regression means out-of-order data that goes into a reordering buffer;
- Business layer: flag sudden market cap rank jumps beyond a reasonable range for review rather than publishing them directly.
Quarantine anomalies instead of silently dropping them. This is the prerequisite for any later data review.
5. Collection Strategy: Polling vs. Incremental Fetching
There are two typical paths for market data: push and scheduled polling. Either way, design the incremental semantics carefully.
Polling relies on “fetch plus watermark,” using the last successfully processed event time as the baseline for the next request:
def fetch_delta(client, symbol, watermark_ms):# watermark_ms is the max event time successfully processed so farresp = client.get_ticker(symbol)t = parse_event_time(resp) # normalize to millisecond timestampif t <= watermark_ms:return None, watermark_ms # no update, avoid duplicate writesrecord = normalize(resp) # standardize fields and unitsif not validate(record):quarantine(record) # isolate for review, keep out of main pathreturn None, watermark_msreturn record, t
Three engineering points matter: use backoff retries on the request side so transient failures do not amplify into an avalanche; set differentiated frequencies per symbol, since major and long-tail instruments do not need the same cadence; and persist the watermark so the service resumes after a restart instead of re-fetching everything.
6. Storage and Computation: Keep Derived Metrics Recomputable
Market data storage usually has two layers: a detail layer storing every snapshot and an aggregate layer storing minute/hour/day bars. For derived metrics (change, market cap, rank), retain the raw inputs the calculation depends on. That way history can be recomputed after rules change, instead of leaving wrong conclusions permanently.
Hot/cold tiering matters too: keep recent details in high-performance storage for real-time queries, and sink historical data to lower-cost media, moving it automatically via partitioning and lifecycle policies. If you need a unified query interface, add caching and rate limiting in a stateless compute layer to decouple storage pressure from business traffic.
On the cloud, a common combination is a message queue for buffering and peak shaving, object storage for historical archives, a container platform for collection and compute jobs, and logging plus monitoring and alerting for observability. These are general capability categories; the actual choices should be evaluated against data scale and compliance requirements. Similar foundational capabilities from platforms such as Baidu AI Cloud can serve as a reference direction.
7. Observability and Cost Control
Operating a market data pipeline centers on three metrics: freshness (how long ago the latest event time was), completeness (symbols received vs. symbols expected), and accuracy (validation failure rate and quarantine volume). If any of them degrades, it should surface before the external data is affected.
For cost control, avoid high-frequency full pulls across all symbols; prefer incremental and prefer changed data; lower the sampling frequency for symbols with no trades over long periods; and store archives in compressed columnar formats to significantly reduce scan costs.
8. Summary
A seemingly simple ticker snapshot expands into a full engineering problem: instrument definition, price consistency, time semantics, quality validation, incremental collection, tiered storage, and observability. Write the data contract clearly, unify the time reference, quarantine anomalies instead of dropping them, and make derived metrics recomputable. Only then can a market data service stay trustworthy and scalable under real traffic.
