Designing Crypto Market Data Structures and Real-Time Dashboards from a Single Quote Snapshot
This article breaks down the architecture of cryptocurrency market data systems using a typical quote snapshot. It examines field composition, rolling windows for price statistics, consistency validation, volatility analysis, and essential engineering practices for caching, data distribution, and dashboard presentation.
1. Starting with a Market Snapshot
In digital asset trading systems, market data is one of the most frequently read and written types of business data. Let’s look at a typical quote record:
{"code": "GLM","pair": "GLMUSDT","market": "CRYPTO","last_price": 0.09359,"currency": "USD","change_24h": 0.00009989,"change_pct": 0.107,"open": 0.09349,"high": 0.09539,"low": 0.09119,"market_cap": 93733100,"market_cap_rank": 164,"updated_at": "2026-12-01 19:57:41"}
Although this record contains only a dozen fields, it covers the core elements of a market data system: asset identifiers, price systems, statistical windows, and derived metrics. Let’s break it down layer by layer.
2. Field Composition and Statistical Windows
Identifiers and Market Dimensionscode is the asset code, pair is the trading pair, and market represents the market type. When designing the system, it is recommended to model “asset–pair–market” as a three-level structure, because the same asset often exists in multiple pricing markets (e.g., priced in USD or other fiat currencies). The presentation layer must clearly define which pricing currency (currency) is the standard.
Price System and Rolling Window
The latest price, open price, high price, and low price are all defined within a “past 24 hours” rolling window, rather than a natural calendar day. Engineering-wise, there are two approaches:
- Calendar day approach: Resets at 00:00 every day. It is simple to implement but causes data jumps.
- Rolling window approach: Pushes forward 24 hours from the current moment. It is continuous and smooth, making it the standard solution for mainstream exchanges.
A typical implementation of a rolling window maintains a time-sorted event queue or uses sliding window aggregation. When trade records fall out of the window, the statistical values must be rolled back. Be careful to handle cross-timezone and timestamp precision issues.
Consistency Validation for Price Change
There is a deterministic mathematical relationship between the absolute price change and the percentage change:
change_pct = (last_price - open) / open * 100
Verifying with the example: (0.09359 − 0.09349) / 0.09349 ≈ 0.107%, which matches change_pct. In a production system, data validation rules should be enforced to prevent display contradictions caused by abnormal market data sources. For instance, include the following assertion when defining the interface contract:
def validate(snapshot):assert abs((snapshot.last_price - snapshot.open) / snapshot.open * 100- snapshot.change_pct) < epsilon
Market Cap and Ranking
Market cap is a derived metric, typically equal to circulating supply × latest price. It relies on cross-service data, requires asynchronous calculation and periodic updates, and must be timestamped. This prevents chronological confusion when mixed with real-time price data.
3. Hidden Signals in Data: A Volatility Perspective
From this snapshot, another detail is worth noting: the amplitude between the high (0.09539) and low (0.09119) is about 4.58%, while the 24-hour percentage change is only 0.107%. The significant difference indicates that the price experienced notable round-trip fluctuations intraday, ultimately closing near the opening price.
This “high amplitude, low net change” pattern highlights that a simple percentage change is insufficient to characterize market conditions. Common supplementary metrics used in engineering and data analysis include:
- Amplitude:
(high − low) / open - Price Position Indicator:
(last − low) / (high − low), measuring the relative position of the closing price within the intraday range. - Volatility Series: Calculating standard deviation based on minute-level data, used for risk control and adaptive adjustment of push frequencies.
4. Key Design Points for Market Data System Architecture
Data Collection and Distribution Pipeline
Market data is typically driven by matching engine events. After an aggregation gateway calculates the window statistics, the data is distributed to the presentation layer via a message queue. The push channel usually relies on WebSocket long connections, combined with subscribe/unsubscribe mechanisms to control bandwidth. Throttling the push frequency (e.g., merging snapshots every 200 milliseconds) is a common load-reduction technique.
Caching and Consistency
The latest price, frequently read by the frontend, should be stored in an in-memory cache, paired with the updated_at timestamp to provide “time-sensitive data”—historical pages or reconnected sessions should not display stale data. On the write side, a dual-write strategy of “overwrite latest price, persist historical price” is adopted. Historical data is used for generating K-line charts and retrospective analysis.
Presentation Layer Design
Typical components of a market data dashboard include price cards, change badges, ranking lists (by market cap or percentage change), and mini charts. In sorting scenarios, fields like market cap rank should be sourced from an independent ranking service to avoid full recalculation every time. Numerical formatting requires unified precision rules to prevent minor tokens from displaying as 0 due to precision loss:
function fmt(v) {return v >= 1 ? v.toFixed(2): v >= 0.01 ? v.toFixed(4): v.toPrecision(5);}
5. Conclusion
A seemingly simple market snapshot involves multiple engineering stages: statistical window selection, consistency validation, derived metric calculation, push pipeline design, and frontend presentation standards. Unifying field semantics, mathematical relationships, and system architecture is the key to building an accurate and reliable market data service. Hopefully, this breakdown provides a clear reference path for developers building market data-related systems.
