Crypto Market Data Engineering: Field Modeling, Metric Definitions, and Real-Time Pipeline Design
This article walks through how to build a reliable crypto market data service, starting from field-level modeling of a ticker snapshot and moving through metric definitions, collection and cleaning, real-time computation, storage layering, API design, and data quality monitoring. It explains why the quote currency and timestamp conventions must be declared explicitly, how change percentage and 24-hour high/low values are actually defined across data sources, and how to handle late and out-of-order events with event-time windows and watermarks. Readers will find a sample ticker schema, a validation function, a query endpoint example, and a practical checklist of monitoring dimensions for freshness, completeness, consistency, and end-to-end latency.
1. What Market Data Really Is: A Structured Snapshot of Market State
Crypto market data is essentially a snapshot of the market state of a given trading instrument at a specific point in time. A typical ticker record usually carries the following groups of information:
- Identifier fields: the asset symbol, the trading pair name, and the market type (spot, futures, and so on);
- Price fields: last price, open, high, and low;
- Change fields: the 24-hour absolute change and percentage change;
- Scale fields: market capitalization and market cap rank;
- Metadata: the quote currency and the update timestamp.
For a typical spot ticker, the fields can be modeled as follows:
{"symbol": "ASSET/USDT","market_type": "CRYPTO","last_price": 0.09359,"quote_currency": "USD","change_24h": 0.0001998,"change_pct_24h": 0.00214,"open_24h": 0.09339,"high_24h": 0.09539,"low_24h": 0.09119,"market_cap": 93733100,"market_cap_rank": 164,"updated_at": "2026-12-01T19:59:41Z"}
The rigor of this modeling directly determines how trustworthy every downstream analysis will be. Two points deserve special attention. First, the quote currency must be declared explicitly, because the same asset priced in USD and in USDT can differ slightly. Second, timestamps must use a consistent timezone and precision, otherwise data from different sources will not line up.
2. Core Metric Definitions
In a market data system, the most common source of errors is not collection but metric definition. The definitions and calculation methods for the usual metrics are described below.
2.1 Absolute and Percentage Change
The common definition is:
absolute change = last price - price 24 hours agopercentage change = absolute change / price 24 hours ago
Different data sources define “the price 24 hours ago” differently: some use the most recent trade from 24 hours ago, while others use the open of a 24-hour rolling window. In engineering terms, the definition must be agreed with the upstream provider, otherwise the same instrument will show inconsistent percentage changes on different pages at the same moment. A practical approach is to keep a change_window field in the data model (for example 24h or 1h) and persist the original reference price alongside it, which makes auditing and replay straightforward.
2.2 24-Hour High and Low
The 24-hour high and low are usually the extreme traded prices within the window. Two things matter during implementation:
- Rolling window boundaries: when the window slides, expired data must be evicted efficiently, which can be done with time bucketing plus sliding aggregation;
- Abnormal trade filtering: trades that deviate extremely (possibly dirty data, or abnormal fills under very thin liquidity) should be filtered by a deviation or traded-volume threshold.
2.3 Market Cap and Market Cap Rank
Market cap is generally calculated as circulating supply multiplied by the last price. Because market cap changes continuously, the ranking changes with it. It is better to compute the ranking in a separate service that refreshes on a schedule in batches (for example once per minute) rather than recalculating it for every incoming ticker message. This controls computation cost and keeps the ranking consistent along the time dimension.
3. Data Collection and Cleaning Pipeline
A robust market data pipeline is usually divided into four layers: ingestion, cleaning, computation, and distribution.
3.1 Ingestion Layer
The ingestion layer connects to market data sources, typically over WebSocket or REST polling. Key design points:
- Multi-source redundancy: connect each trading pair to multiple upstreams with primary and failover switching, so a single source outage is not fatal;
- Rate limiting and backoff: respect the upstream rate limits and retry with exponential backoff;
- Heartbeat and reconnection: recover automatically after a connection drop, and backfill the snapshot data for the missing period.
3.2 Cleaning Layer
The cleaning layer is responsible for:
- Field type validation and unit conversion (for example, normalizing amounts to minimum-precision integers or standard decimals);
- Deduplication (idempotent on symbol + timestamp + sequence number);
- Anomaly detection: when the price deviates from the previous value beyond a threshold, flag the record for manual review instead of discarding it outright;
- Time alignment: normalize everything to UTC millisecond timestamps.
Illustrative validation logic:
def validate_tick(tick, last_price):if tick["last_price"] <= 0:return False, "invalid price"if last_price and abs(tick["last_price"] / last_price - 1) > 0.5:return True, "flagged: abnormal move"return True, "ok"
Note that flagged anomalies should be routed to a side channel for auditing and must not feed the real-time computation directly, which prevents them from polluting metrics such as the high and low.
4. Real-Time Computation and Storage Selection
4.1 Real-Time Computation
For windowed metrics such as percentage change and rolling high/low, the common approach is stream processing: partition by trading pair and aggregate over event-time windows (for example a 24-hour rolling window). Late and out-of-order data must be handled by configuring an allowed lateness and a watermark; data beyond that goes through a correction channel and is backfilled.
4.2 Storage
- Time-series storage: candlestick and tick snapshot data fits a time-series database or a wide-column store, partitioned by symbol + time;
- Hot cache: the latest ticker snapshot is written to an in-memory cache (a common key-value cache product), for high-frequency reads from market pages;
- Object storage: full historical data is archived to object storage at lower cost, for backtesting and research;
- Message queue: market events first enter a message queue and are then consumed by the computation and distribution services, which smooths peaks and decouples components.
5. API Design and Performance Optimization
A market data query API is a typical read-heavy, write-light, hotspot-concentrated scenario. Key design points:
- Batch queries: expose a multi-pair batch endpoint to reduce the number of requests;
- Incremental push: WebSocket pushes send only the changed fields, reducing bandwidth;
- Caching and fallback: serve the last price from cache; when the cache expires, fall back to the database snapshot and never return empty;
- Rate limiting protection: limit per IP and per user so crawlers cannot take the service down.
Endpoint example:
GET /api/market/tickers?symbols=ASSET_USDT,BTC_USDT
The response structure should align with the internal data model fields, so that a single metric never ends up with multiple definitions.
6. Monitoring, Alerting, and Data Quality
The availability of a market data system shows up directly as data quality. The following monitoring dimensions are recommended:
- Freshness monitoring: alert when the gap between the ticker update time and the current time exceeds a threshold (for example 30 seconds);
- Completeness monitoring: monitor the difference between the expected number of trading pairs and the number actually received;
- Consistency monitoring: alert when the price of the same trading pair differs across sources beyond a threshold;
- Metric sanity: flag records for review when the percentage change falls outside a reasonable range (for example beyond ±50% in a single day);
- End-to-end latency: monitor latency percentiles from the upstream event time to the point where the data is queryable downstream.
7. Summary
A market data system may look like it is only about “fetching prices”, but in real engineering it tests a combination of capabilities: definition rigor, data quality, real-time behavior, and auditability. The recommended path is to start from field modeling and make the calculation window and reference baseline of every metric explicit; add multi-source redundancy and idempotent deduplication on the collection side; use event-time windows and watermarks to handle out-of-order data on the computation side; layer storage into time-series, cache, and archive tiers; and finally safeguard production quality with freshness, completeness, and consistency monitoring. Following this approach, even starting from a single simple ticker snapshot, you can build a market data service that is both scalable and trustworthy.
