Digital Asset Market Data Structures and Parsing: A Practical Guide
This article breaks down the fields in a typical crypto market data record, explains their business meaning, and provides a practical Python example for parsing and validation. It also covers storage and display considerations and best practices for unifying data definitions when aggregating from multiple sources.
In digital asset trading systems, market data is one of the most fundamental and critical types of information. Market display pages, quantitative strategy engines, risk control systems, and reporting systems all depend on an accurate understanding of market data fields and efficient processing. Using a typical market data record as an example, this article examines its field composition and business meaning, and presents a complete practical approach for programmatic parsing and display.
1. Breaking Down the Fields of a Market Data Record
A standard market data record usually contains the following core fields:
- Code and trading pair: For example,
OPENandOPENUSDT. The former is an asset identifier, while the latter represents the trading market formed by that asset and a quote currency (usually a stablecoin). Developers should note that the same asset code may have different prices under multiple trading pairs, and the trading pair is the smallest granularity for market data queries. - Market type:
CRYPTOindicates a digital asset market, distinguishing it from markets such as equities and foreign exchange. This helps multi-market aggregation systems route data to different processing logic. - Price fields: These include the latest price, open price, high price, and low price. In the example data, the latest price is 0.07971 USD, the open price is 0.07911, the high price is 0.08381, and the low price is 0.07831. The intraday amplitude can be calculated from the high and low prices:
(0.08381 - 0.07831) / 0.07911 ≈ 6.95%. This is an important indicator for measuring short-term volatility. - Change amount and change percentage: The change over the past 24 hours is 0.0005993, and the change percentage is 0.758%. Note that the denominator of the change percentage is usually the price 24 hours ago (or the open price), and different platforms may define it differently. When aggregating across sources, the definition must be unified.
- Market cap and ranking: The market cap is 27.8983 million USD, and the ranking is 455. Market cap generally equals circulating supply multiplied by the latest price, and ranking reflects the relative position of the asset’s size in the market.
- Update timestamp:
2026-11-24 17:10:29. Timestamps are an extremely error-prone part of consuming market data. Be sure to clarify the time zone (usually UTC or local time) and precision.
2. Code Practice for Data Parsing and Validation
In real-world engineering, market data is often delivered as JSON through APIs. Below is a structured parsing and validation example:
from dataclasses import dataclassfrom datetime import datetime@dataclassclass Ticker:symbol: str # Trading pair, such as OPENUSDTmarket_type: str # Market typelast_price: float # Latest priceopen_price: float # Open pricehigh: float # 24h high pricelow: float # 24h low pricechange_pct: float # 24h change percentagemarket_cap: float # Market capupdated_at: datetime # Update timedef parse_ticker(raw: dict) -> Ticker:# Basic validation: price fields must be positivefor key in ("last_price", "open_price", "high", "low"):if raw.get(key, 0) <= 0:raise ValueError(f"Invalid price field: {key}")# Logical validation: high price must not be lower than low priceif raw["high"] < raw["low"]:raise ValueError("High price is lower than low price; data anomaly")return Ticker(symbol=raw["symbol"],market_type=raw["market_type"],last_price=raw["last_price"],open_price=raw["open_price"],high=raw["high"],low=raw["low"],change_pct=raw["change_pct"],market_cap=raw["market_cap"],updated_at=datetime.fromisoformat(raw["updated_at"]),)
The validation logic may look simple, but it is indispensable in production environments. Common dirty data includes prices of zero or negative values, high prices lower than low prices, missing timestamps, and time zone confusion. It is recommended to complete both format validation and logical validation at the ingestion layer to prevent abnormal data from contaminating downstream calculations.
3. Recommendations for Market Data Storage and Display
At the storage layer, market data is characterized by frequent writes and time-based queries. A hot/cold separation strategy is commonly used: the latest snapshot is stored in an in-memory database or cache for real-time queries, while historical series are written to a time-series database to support candlestick aggregation and retrospective analysis. It is also recommended to create a composite index on trading pair and timestamp to speed up range queries.
At the display layer, several details require attention:
- Precision handling for small-cap assets. In the example, the price is 0.07971 and the change amount is 0.0005993. If such data is calculated directly with floating-point numbers, precision errors may occur. It is recommended to use fixed-point numbers or high-precision decimal types.
- Color semantics for gains and losses. Users in different regions have different conventions for red-up/green-down or green-up/red-down. Internationalized products should support configuration.
- Data freshness indicators. Pages should display the update time and provide a prominent notice for data that has not been updated for a long time, so that users do not make decisions based on outdated data.
4. Unifying Definitions During Cross-Source Aggregation
When a system needs to aggregate market data from multiple data sources, common issues include inconsistent calculation bases for change percentage, different circulating supply definitions for market cap, and mixed timestamp time zones. The engineering best practice is to define a unified internal data model at the ingestion layer, write an adapter for each data source, map external fields to internal standard fields, and record definition notes in metadata. This ensures that downstream consumers always perform calculations based on consistent semantics.
5. Conclusion
Market data may seem small, but it is the foundation of a trading system. Mastering field semantics, establishing strict validation mechanisms, designing reasonable storage and display solutions, and unifying multi-source data definitions are the four key steps for building a high-quality market data service. I hope the breakdown and example code in this article provide practical reference for your market data system development.
