Digital Asset Market Data Services: Collection, Calculation, and Presentation Practices
This article explains how to build reliable digital asset market data services that collect continuous market events, calculate consistent metrics, and serve multiple read models. It covers service boundaries, metric contracts, precision and time semantics, event deduplication and clock handling, storage and read paths, quality checks, access control, and schema evolution. Readers will learn how to turn a market page from a simple price display into a service that can explain where a price came from, when it became stale, and how it can be recomputed.
A market page may look like a simple list of prices, but behind it are continuously arriving market events, strict metric definitions, and read models for different audiences. Making information such as code, trading pair, market type, name, latest price, quote currency, 24-hour change amount and ratio, open price, high price, low price, market cap, rank, and update time into a reliable service is not about piling up fields. The key is consistent time, consistent precision, consistent exception handling, and an explainable calculation process.
Define the Service Boundaries First
A market data service usually supports three types of scenarios. Trading terminals need a latest price with second-level or even lower latency. Research and risk control need traceable window highs, lows, and changes. Ranking and screening need slower-moving derived metrics such as market cap and rank. These scenarios have different consistency requirements, so it is not appropriate to force them through a single synchronous pipeline.
A practical approach is to divide the data into three layers. The first layer is raw events: trades, best bid and offer, mark price, or index price. Both source time and receive time must be retained. The second layer is the standard snapshot: the latest state organized under a unified trading pair key. The third layer is the presentation read model: results already rounded to display precision, with change direction and update time. The raw layer is immutable, while the presentation layer can be rebuilt. When a metric definition changes, historical events do not need to be rewritten.
Do not use only a short code as the trading pair key. Short codes may conflict, and the base asset, quote asset, and market type should also be stored. Market type should at least distinguish spot from derivatives, because the meaning of “latest price” may differ. For spot, it often refers to the most recent trade; for derivatives, a mark price may also exist. The external interface should clearly state which price is being returned and avoid mixing different semantics in the same field.
Write Metric Definitions into the Contract
The 24-hour change amount is generally defined as the latest price minus a reference price. The reference price is often the closest trade price before the 24-hour point, or the open price of that rolling window. These two definitions produce different results, so one must be fixed in the interface documentation. The change ratio is the change amount divided by the reference price. When the reference price is zero or missing, the change ratio should return a null value and record the reason rather than forcing zero.
Open, high, and low prices must declare their window. A calendar-day window and a rolling 24-hour window cannot be mixed. High and low prices should come from valid trades within the window, not from abnormal spikes that have not been cleaned. If the business needs to exclude clearly erroneous quotes, filtering rules should be defined first. For example, if the price deviates from the mid price by more than an agreed threshold, it can enter a quarantine queue and be reviewed manually or by rules before a decision is made on whether to include it in the range.
Market cap is usually circulating supply or total supply multiplied by a selected price. Supply comes from on-chain data or project disclosures and updates much less frequently than price. Rank is the position by market cap at a point in time and changes as other assets change. Therefore, rank must carry a batch number or calculation time and cannot be treated as an intrinsic attribute of an asset. When displaying update time, distinguish event occurrence time, ingestion time, and calculation time. If the time users see is clearly behind, provide the delay in seconds instead of only refreshing a timestamp that looks new.
For precision, use decimal fixed-point numbers for prices rather than binary floating point for accounting-grade calculations. Internal calculations should retain more decimal places than the display precision, and external output should then be truncated or rounded according to asset rules. Ensure that the change amount and change ratio are derived from the same set of unrounded intermediate values, avoiding rounding contradictions such as a positive change amount with a negative change ratio.
An illustrative calculation can be written as:
change_amount = last_price - reference_pricechange_ratio = change_amount / reference_pricewindow_high = max(valid_trade_prices in window)window_low = min(valid_trade_prices in window)
The definitions of reference_price, window, and valid_trade belong to the interface contract, not to temporary decisions in the presentation layer.
Collection, Deduplication, and Clocks
The collection side faces disconnects, duplicates, out-of-order events, and silence. Each event should carry a source sequence number or trade identifier. Duplicate deliveries are removed by identifier. Out-of-order events are reordered by event time, but an acceptable out-of-order window must be set. Late data beyond that window should only correct history. It should not retroactively change the “latest price at the time” that has already been published and used for trading decisions; instead, append a correction record.
Clocks cannot trust a single source. Collection machines should use unified time synchronization, and events should record both source time and local receive time. If source time is too far ahead of local time, or does not advance for a long period, an alert should be raised and the source should be paused from being marked as real-time. When multiple sources exist, define a primary source and a validation source. The primary source drives the latest price, while the validation source is used only to compare deviation. If deviation persists beyond a threshold, degrade to “price pending confirmation” rather than silently switching sources and causing a price jump.
Silence is also a failure. If a trading pair has no new events for more than an agreed number of seconds during its expected active period, the presentation layer should retain the last valid price but clearly mark the delay. It must not disguise an old price as one that has just been updated.
Storage and Read Paths
Raw events are suitable for append-only writes, partitioned by trading pair and time, and retained for enough days to support recalculation. The latest snapshot is suitable for a key-value or in-memory structure, with the trading pair as the key and the full state plus version number as the value. Window highs and lows do not need to scan all trades every time; sliding-window aggregation can be used. When a new trade arrives, update the window statistics; when an expired trade leaves the window, roll back its contribution. Window statistics must be rebuildable from raw events for daily reconciliation.
A recommended read path is snapshot plus incremental updates. Full snapshots are generated at a fixed interval, and increments are pushed through ordered messages. Clients start from a snapshot version and consume increments. If the version is discontinuous, they fetch the snapshot again. This supports both list pages and detail pages and avoids every reader hitting calculation tasks directly.
Caches should carry versions and expiration times. Market cap, supply, and rank can be cached longer than the latest price, but the response should return the as_of time for each. Binding slow-moving and fast-moving variables into one inseparable object amplifies writes whenever any field updates. Splitting them and assembling them in the presentation layer makes cost easier to control.
Quality, Access, and Evolution
Before launch, use historical segments for replay. Given the same set of trades, repeated calculations should produce the same open, high, low, close, and change. Then construct cases for gaps, duplicates, out-of-order events, zero prices, and extreme deviation. Monitoring should at least include source latency, event gaps, deduplication rate, price deviation, snapshot rebuild time, push backlog, and API error rate. Alert thresholds should be layered by trading pair activity; low-activity assets cannot use the second-level standard of highly active assets.
External interfaces should have access tiers. Public market data can be cached. If accounts, orders, or positions are involved later, they must be isolated from the public read model and protected with authentication and rate limiting. If the market data service itself does not provide order placement, its responses should not imply that direct execution is possible.
For evolution, follow the principle of adding fields without changing semantics. If the definition of the change reference price must change, publish it as a new field or new version and keep the old field for a clear deprecation period. Write all definition changes into a changelog and retain recomputation jobs so that research teams can backfill using the new definition rather than only changing the current page.
When deployed in the cloud, collection and computation can run on a container platform, events can be buffered through a message queue, and raw data can enter appendable object storage or time-series storage. Latency and backlog should be handled by monitoring and alerting. These are general capabilities. When selecting implementations, focus on delivery semantics, retention period, replay capability, and fault isolation rather than hardcoding implementation details into business code.
Once field definitions, time semantics, abnormal quotes, and read model versions are treated as first-class citizens, a market page moves from “showing prices” to “explaining where a price came from, when it becomes invalid, and how it can be recomputed.” This is the engineering foundation that trading, research, and ranking scenarios can share.
