Digital Asset Real-Time Market Data Structures: A Developer's Guide
This article explores the data structures and engineering practices behind digital asset real-time market data. Starting from a typical market snapshot, it breaks down core fields including identifiers, price volatility, and market capitalization. It further provides practical guidelines on API design, data validation, caching strategies, and frontend display considerations to help developers build stable and reliable market data services.
1. Starting from a Market Snapshot
In digital asset trading systems, market data is the most fundamental and most frequently updated data type. Let’s take a typical market snapshot as an example:
- Symbol: GLM, Trading Pair: GLMUSDT, Market Type: CRYPTO
- Last Price: 0.09119 USD
- 24h Change Amount: 0.002497, Change Percentage: 2.815%
- Open Price: 0.08869, High Price: 0.09368, Low Price: 0.08759
- Market Cap: 90.5415 million USD, Market Cap Rank: 168
- Updated At: 2026-11-24 14:24:39
Although this data appears simple, it contains information across three dimensions: price, volatility, and market capitalization. Below, we will dissect its underlying logic and key engineering implementation points.
2. Technical Meaning of Core Fields
2.1 Identification Fields
- Symbol: The unique ticker of an asset, such as GLM.
- Pair: Composed of the base currency and the quote currency. GLMUSDT represents the GLM trading market priced in USDT. Pair naming is the key index for market data system routing, typically requiring a reverse mapping from
symbol -> pair list. - Market Type: CRYPTO is used to distinguish from other asset classes like stocks or forex. In multi-market aggregation systems, it is often used as the primary partition key.
2.2 Price and Volatility Fields
The 24-hour rolling window is the most commonly used statistical caliber. Its calculation logic is as follows:
Change Amount = Last Price - Price 24 hours ago (or Daily Open Price)Change Percentage = Change Amount / Reference Price × 100%
Verifying with our example: 0.09119 - 0.08869 = 0.0025, which basically matches the given 0.002497 (minor differences stem from precision truncation); 0.002497 / 0.08869 ≈ 2.815%, confirming the data is self-consistent.
Engineering Tip: Different data sources may define the reference price for the “24-hour change percentage” differently (rolling window start price vs. daily open price). When integrating multi-source data, you must unify the calculation caliber; otherwise, deviations will occur during aggregated display.
2.3 High and Low Prices
The 24h high (0.09368) and low (0.08759) form the so-called “amplitude interval”, where amplitude = (high - low) / low ≈ 6.95%. Combining the amplitude with the change percentage helps determine the trend pattern. In this example, the price closed in the upper-middle section of the range, indicating a moderate upward trend.
2.4 Market Cap and Ranking
Market Cap = Circulating Supply × Last Price, which is approximately 90.5415 million USD, with a rank of 168. Market cap ranking is a common basis for asset classification (large-cap/mid-cap/small-cap). It is typically recalculated periodically by independent background tasks and written to the cache, avoiding real-time full sorting within query interfaces.
3. General API Design for Market Data
For developers, integrating market data usually involves the following types of API interfaces:
- REST Snapshot API: Returns the current state in a single request, suitable for low-frequency queries and initial loading.
- WebSocket Subscription API: Pushes incremental updates from the server, suitable for real-time dashboards and trading strategies.
- Batch Query API: Returns multiple trading pairs at once, reducing the number of requests.
A typical snapshot response structure can be abstracted as follows:
{"symbol": "GLM","pair": "GLMUSDT","market": "CRYPTO","last_price": 0.09119,"change_24h": 0.002497,"change_pct_24h": 2.815,"open": 0.08869,"high_24h": 0.09368,"low_24h": 0.08759,"market_cap": 90541500,"market_cap_rank": 168,"updated_at": "2026-11-24T14:24:39Z"}
4. Best Practices for Integrating Market Data
4.1 Data Validation
Market data is extremely sensitive to accuracy. It is recommended to perform triple validation at the integration layer:
- Numerical Validity: Prices, highs, and lows must be positive;
low <= open/close <= high. - Time Freshness: Check the difference between
updated_atand the current time. If it exceeds a threshold, flag the data as stale and trigger an alert. - Change Consistency: Recalculate the change percentage using the formula and compare it with the field value. Log an exception if the deviation exceeds the threshold.
Example validation logic:
def validate(tick):assert tick["low_24h"] <= tick["last_price"] <= tick["high_24h"]expected = (tick["last_price"] - tick["open"]) / tick["open"] * 100if abs(expected - tick["change_pct_24h"]) > 0.5:log.warning(f"change_pct mismatch: {tick['symbol']}")age = now() - parse(tick["updated_at"])if age > MAX_STALE_SECONDS:mark_stale(tick["symbol"])
4.2 Caching and Update Strategies
Market data involves heavy read and write traffic. A layered architecture is recommended:
- Hotspot Layer: In-memory cache (such as an in-process Map or distributed cache) storing the latest snapshot, with a TTL set to a few seconds.
- Subscription Layer: A WebSocket client maintains the subscription list and atomically updates the hotspot layer upon receiving pushes.
- Persistence Layer: Saves historical K-lines at a minute granularity to a database for retrospective analysis and chart rendering.
4.3 Display Layer Considerations
- Price precision should adhere to the asset’s minimum tick size to avoid misleading users through frontend rounding.
- The change percentage display should use distinct color coding for positive/negative values and clearly label the statistical window (e.g., “24H”).
- Market cap and rank are low-frequency fields. They can be updated independently of price pushes to reduce bandwidth consumption.
5. Conclusion
Behind a single market snapshot lies the complete pipeline of an identification system, price statistics, market cap calculation, and data freshness management. When building market data-related systems, developers should focus on: a unified calculation caliber for changes, strict data validation, a layered caching architecture, and frontend precision specifications. Mastering these general practices allows you to build stable and reliable market data services, regardless of the asset class or data source.
