Designing a Real-Time Digital Asset Market Data Collection, Processing, and Monitoring System
This article explains how to design a reliable, low-latency pipeline for digital asset market data. It covers field modeling, pull and push-based collection, data validation, metric calculation, layered storage, real-time and batch aggregation, and monitoring strategies for freshness, latency, quality, and business risks.
1. Background and Problem Definition
In the digital asset industry, market data is a core input for risk management, quantitative applications, and user-facing dashboards. A typical market snapshot may include the following fields: symbol, trading pair, market type, asset name, latest price, quote currency, 24-hour price change and percentage change, opening price, high, low, market capitalization, market cap rank, and update timestamp.
For example, a single snapshot might contain a latest price of 70.75 USD, a 24-hour change of -1.71, a percentage change of -2.357%, an opening price of 72.46, a high of 78.39, and a low of 70.03. These values may look simple, but presenting them accurately, consistently, and with low latency in production requires a complete data engineering pipeline. This article focuses on that pipeline.
2. Modeling Market Data Fields
A well-designed data model provides the foundation for the entire system. Market snapshots can be divided into three categories:
- Identity fields: Symbol, trading pair, market type, and asset name. These fields are relatively static and are suitable for dimension tables or caching.
- Market fields: Latest price, opening price, high, low, absolute change, percentage change, and quote currency. These values change frequently and form the primary time-series data.
- Metadata fields: Market capitalization, market cap rank, and update timestamp. Market capitalization and rank are updated less frequently, while the timestamp is used to verify freshness and support idempotent processing.
A structured data model may look like this:
{"symbol": "SOL","pair": "SOLUSDT","marketType": "CRYPTO","name": "Solana","price": 70.75,"currency": "USD","change24h": -1.71,"changePct24h": -0.02357,"open": 72.46,"high": 78.39,"low": 70.03,"marketCap": 42100000000,"rank": 7,"updatedAt": "2026-11-24T17:06:40Z"}
The storage layer should generally represent percentage changes as decimal values, such as -0.02357, and format them as percentages only at the presentation layer. This avoids inconsistent definitions and accidental repeated conversions.
3. Designing the Data Collection Layer
The collection layer retrieves or subscribes to market data from upstream sources. Two common patterns are used:
- Polling (pull): The system requests snapshot APIs at fixed intervals. This approach is simple to implement, but it introduces latency and may generate unnecessary requests. It is suitable for lower-frequency fields such as market capitalization and rank.
- Persistent subscriptions (push): The system receives incremental updates through a long-lived connection. This provides lower latency and is suitable for frequently changing values such as the latest price, high, and low.
For reliability, the collection layer should support:
- Reconnection with exponential backoff
- Local sequence numbers or timestamps for deduplication
- Rate limiting and circuit-breaker protection
Raw messages should preferably be written to a message queue before processing. This decouples collection from downstream processing and prevents downstream instability from propagating back to upstream data sources.
4. Data Cleaning and Metric Calculation
Raw market data may contain missing fields, out-of-order messages, or abnormal values. These issues should be handled consistently during stream processing:
- Timestamp validation: Use
updatedAtas the reference timestamp and discard messages older than the processed watermark. This helps maintain idempotent processing. - Outlier filtering: Apply reasonable boundaries to the latest price and remove clearly invalid data, such as a price of zero or a price jump that exceeds a predefined threshold.
- Derived metrics: Some metrics can be calculated from basic fields. The calculation method for absolute and percentage changes must be clearly defined:
# Calculate the change using the price from 24 hours earlier as the baselinechange = price - base_price # -1.71change_pct = change / base_price # -0.02357 ≈ -2.357%
The system must clearly define whether the baseline for percentage change is the price 24 hours earlier or the opening price for the current day. Otherwise, different modules may produce inconsistent results.
Market capitalization is generally derived from circulating supply multiplied by the latest price. Market cap rank is generated by sorting all assets by market capitalization, making it a global calculation that is better suited to periodic batch refreshes.
5. Storage Selection
Different fields have significantly different access patterns. A layered storage architecture is therefore recommended:
- Time-series database: Stores high-frequency metrics such as the latest price, high, and low. It supports time-window aggregations, including minute and hourly candlesticks, and provides the foundation for chart rendering and market-data replay.
- In-memory cache: Stores the latest snapshot for each trading pair and serves high-frequency frontend and API requests with millisecond-level response times.
- Relational database: Stores identity data, dimension data, and configuration.
- Object storage: Archives complete historical snapshots and raw messages at relatively low cost, supporting later offline analysis and auditing.
Using managed cloud services for time-series storage, caching, and object storage can significantly reduce operational overhead while allowing the system to scale as needed.
6. Computation and Aggregation
Market data applications typically require several types of aggregated views:
- Candlestick aggregation: Groups tick data into fixed windows and calculates open, high, low, and close values. In the example above, the opening price of 72.46, high of 78.39, and low of 70.03 may represent the aggregation results for a daily window.
- Leaderboard calculation: Sorts assets by dimensions such as market capitalization or percentage change to produce rankings.
- Statistical metrics: Metrics such as turnover and volatility can be calculated offline through batch processing.
Aggregations with strict real-time requirements should use stream processing, while global or computationally intensive tasks should use batch processing. Combining both approaches creates a Lambda-style architecture that balances timeliness and accuracy.
7. Monitoring and Alerting
Market data systems are highly sensitive to data freshness, so they require comprehensive monitoring and alerting:
- Freshness monitoring: Continuously compare the current time with
updatedAt. Trigger an alert when no update has been received within a defined threshold, such as 30 seconds, to prevent stale data from being displayed. - Pipeline latency monitoring: Record end-to-end latency from data collection to storage.
- Data quality monitoring: Periodically validate missing-field rates, outlier ratios, and field completeness.
- Business metric alerts: Send notifications when prices move sharply or percentage changes exceed predefined thresholds, supporting risk management and operations.
Cloud-based logging, monitoring, and alerting services can provide metric visualization, threshold-based notifications, and faster fault diagnosis.
8. Conclusion
A market snapshot may appear simple, but it depends on a complete data engineering chain that includes collection, cleaning, storage, computation, and monitoring. Three principles are particularly important:
- Keep the field model clear.
- Standardize the definitions and calculation methods for all metrics.
- Guarantee data freshness.
In production, using managed cloud services such as message queues, time-series databases, object storage, and monitoring platforms can reduce the cost of building and operating infrastructure while improving elasticity and reliability. This allows engineering teams to focus more of their effort on business metrics and data quality.
