Real-Time Crypto Market Data: Collection, Validation, and Display Practices
This article walks through the engineering practices behind a reliable crypto market data pipeline, using a single ticker snapshot as the starting point. It explains how to model field semantics across identity, price, and statistics layers, how to centralize derived metrics with fixed-point arithmetic, how to unify timestamps in UTC and classify data freshness, and how to filter anomalies with range, jump, and consistency checks. It also covers a layered architecture for aggregation, caching, and push delivery, front-end concerns such as precision, jitter, and state, and a pre-launch checklist for building a trustworthy data service.
1. Start with a Single Market Snapshot
When building any market data application, the most fundamental and most frequently underestimated step is understanding exactly what “one market record” means. Below is a typical snapshot (values are for structure only):
{"symbol": "GLMUSDT","market_type": "CRYPTO","base_asset": "GLM","quote_asset": "USDT","last": 0.0937,"quote_currency": "USD","change_24h": 0.0001998,"change_rate_24h": 0.214,"open": 0.0935,"high": 0.0954,"low": 0.0912,"market_cap": 93998300,"rank": 164,"updated_at": "2026-12-01 19:23:40"}
This record is dense with information, but engineering requires clear answers to several questions: What is the price precision? Is the change rate calculated against the open price or the previous close? Is the market cap circulating or fully diluted? Which time zone does the update time belong to? Without a unified definition for these questions, every chart, ranking, and alert downstream will suffer from discrepancies that “look right but are actually wrong.”
2. Explicit Modeling of Field Semantics
It is advisable to split the market entity into three layers: identity, price, and statistics.
- Identity layer:
base_asset,quote_asset,market_type. The trading pair is formed by concatenating the base asset and quote asset, and the market type distinguishes asset classes to avoid incorrect cross-category aggregation. - Price layer:
last,open,high,low. All four must come from the same statistical window; otherwise the high/low will not be consistent with the last price. - Statistics layer:
change_24h,change_rate_24h,market_cap,rank. These are derived metrics that should be computed from raw data using fixed formulas, not collected independently.
A robust approach is to define a single entry point for derived calculations on the server:
def build_quote(raw: dict) -> dict:last = Decimal(str(raw["last"]))open_ = Decimal(str(raw["open"]))change = last - open_rate = (change / open_ * 100) if open_ else Decimal("0")return {"symbol": raw["base_asset"] + raw["quote_asset"],"last": last,"change_24h": change.quantize(Decimal("0.0001")),"change_rate_24h": rate.quantize(Decimal("0.001")),"high": Decimal(str(raw["high"])),"low": Decimal(str(raw["low"])),"updated_at": normalize_ts(raw["updated_at"]),}
The key point is to use decimal fixed-point types rather than binary floating point, avoiding tail differences when decimals like 0.0937 are accumulated and compared; and to centralize all derived calculations, eliminating the dual-definition problem of “computed once on the front end and once on the back end.”
3. Time Unification and Freshness Determination
The value of market data decays rapidly over time, so time handling is the top priority in the pipeline.
- Store uniformly as timezone-aware UTC time, and render in the user’s time zone at the display layer.
- Attach both a collection timestamp and a source timestamp to each record, making it easy to identify whether the issue is “source not updated” or “pipeline delay.”
- Define freshness thresholds: for example, mark as stale if not updated for over 30 seconds, and stop displaying with an unavailable notice after 5 minutes.
Example logic:
def freshness(server_ts, source_ts, now):lag = now - source_ts # source delayage = now - server_ts # pipeline delayif age > 300: return "stale"if lag > 30 or age > 30: return "delayed"return "fresh"
Treating “stale” as a first-class state rather than throwing an exception allows the front end to degrade gracefully instead of failing the entire page.
4. Anomaly and Data Quality Filtering
Low-priced assets are prone to sharp volatility and dirty data, so multiple layers of validation are needed:
- Range check: the last price must fall within
[low, high]; otherwise discard the record and increment a counter. - Jump check: when the change versus the previous record exceeds a set threshold, require two consecutive samples to confirm, avoiding false alerts triggered by a single anomaly.
- Consistency check: the change rate and price difference must be self-consistent; an error beyond tolerance is considered suspicious.
- Null and precision check: missing fields or precision exceeding defined digits go into a quarantine queue for offline investigation.
All intercepted data should be written to a logging service with monitoring alerts configured, forming an “observable data quality dashboard” rather than being silently discarded.
5. Aggregation, Caching, and Push Strategy
A market data service is typically a read-heavy, write-light, strongly real-time workload, and is architecturally suited to layering:
- The ingestion layer handles multi-source collection and normalization, outputting a unified structure.
- The compute layer maintains sliding windows and produces metrics such as open, high, low, and change rate.
- The cache layer stores the latest snapshot keyed by trading pair, with a short TTL and active invalidation.
- The push layer delivers incremental updates over long-lived connections, pushing only changed fields to reduce bandwidth and front-end re-rendering costs.
For historical lookback, normalized records can be written to object storage for archiving, with a message queue for peak shaving and decoupling, and stateless compute tasks hosted on a container platform for elastic scaling by load.
collect -> normalize -> validate -> window aggregate -> cache/push\-> quarantine & log -> quality dashboard
6. Front-End Display and Interaction Details
The display layer must handle three concerns: precision, jitter, and state.
- Precision: configure decimal places by asset type, and use a monospaced font for prices to avoid column width changes during updates.
- Jitter: use throttled refresh (e.g., coalesce once per second) and apply visual suppression to small changes.
- State: clearly distinguish “real-time,” “delayed,” and “stale” indicators so users know the data’s trustworthiness.
Up/down coloring should provide both symbols and text labels, accommodating accessibility and users with color vision differences.
7. Pre-Launch Checklist
- Does every derived metric have only one calculation entry point?
- Is time stored uniformly in UTC and displayed in local time?
- Are the three validations—range, jump, and consistency—in place?
- Is there a clear degradation path for stale data?
- Do the cache TTL and push frequency match the business real-time requirements?
- Is there a closed loop of metrics, logs, and alerts for data quality?
With this structure in place, the market data pipeline upgrades from “able to display numbers” to a “trustworthy data service,” with engineering safeguards in three areas—definition consistency, controllable timeliness, and graceful degradation—while leaving clear boundaries for future metric expansion and multi-market integration.
