Real-Time Collection and Monitoring of Digital Asset Market Data
This article presents a practical architecture for building a stable, verifiable, and extensible digital asset market data pipeline. It covers data contract design, polling and streaming collection, retry and validation strategies, layered storage, rolling metric computation, service delivery, observability, and resilient deployment.
1. Problem Definition: From a Quote Snapshot to a Complete Data Pipeline
The original data is essentially a typical market quote snapshot. It includes a transaction identifier, trading pair, market type, asset name, latest price, quote currency, 24-hour change amount and percentage, opening price, high, low, market capitalization, market cap rank, and update time.
Although such a record appears simple, it exposes four fundamental challenges in production market data systems:
- Inconsistent definitions: Different data sources may use different starting points for the 24-hour window, market capitalization formulas, and ranking populations.
- Ambiguous time semantics: Whether
update_timerepresents the collection time, the source system’s generation time, or the database write time directly affects freshness calculations. - Precision and numeric types: Floating-point storage can introduce rounding errors over time. Fixed-point numbers or strings should be used to preserve the original precision of price-related fields.
- Uncontrolled data quality: Cases such as both change amount and change percentage being zero, or the high price being lower than the latest price, may be logically formatted but suspicious from a business perspective. These conditions require rule-based validation rather than manual inspection.
This article does not focus on any specific market data product. Instead, it abstracts the topic into a general engineering question: How can you build a stable, verifiable, and extensible digital asset market data pipeline?
2. Data Model: Define the Contract Before Writing Code
The first engineering task should not be building a collector. It should be defining a unified data contract. A quote snapshot can be divided into three parts: identity dimensions, numerical metrics, and metadata.
{"symbol": "ASSET_USD","market_type": "CRYPTO","asset_name": "Sample Asset","quote_currency": "USD","metrics": {"last": "0.093590","open_24h": "0.093590","high_24h": "0.095390","low_24h": "0.091190","change_24h": "0.000000","change_ratio_24h": "0.000000"},"derived": {"market_cap": "93733100","market_cap_rank": 164},"meta": {"source_ts": "2026-12-01T19:55:40Z","ingest_ts": "2026-12-01T19:56:02Z","schema_version": "v1"}}
Three design principles are especially important:
- Transmit numeric values as strings or fixed-point numbers to avoid serialization-related precision loss.
- Keep
source_tsandingest_tsseparate so that end-to-end latency can be calculated accurately. - Declare
schema_versionexplicitly to preserve compatibility for downstream consumers.
3. Collection: Polling, Streaming, and Backoff Strategies
Market data is generally collected in one of two ways. Polling is simple and controllable, making it suitable for snapshot-based metrics. Streaming provides lower latency but requires handling reconnections and sequence gaps.
In practice, a dual-channel architecture is recommended: use streaming as the primary channel and polling as a fallback. Apply rate limiting independently to each channel.
def fetch_snapshot(client, symbol, max_retry=5):for attempt in range(max_retry):try:raw = client.get_snapshot(symbol) # One request per call to avoid oversized batchesrecord = normalize(raw) # Normalize and validateif not validate(record):raise DataQualityError(record)return recordexcept (TimeoutError, RateLimitError) as e:sleep(backoff(attempt, base=0.5, cap=30, jitter=True))raise ExhaustedError(symbol)
Key practices include:
- Use exponential backoff with jitter to prevent retry storms.
- Make one request per symbol to reduce the risk of rate limiting.
- Perform only format and internal-consistency checks in the collection layer. Business-definition validation should be handled in the computation layer so that collectors remain lightweight.
4. Validation Rules: Turn Suspicious Data into Executable Assertions
Data quality checks must be expressed as explicit rules. Basic assertions may include the following:
- The latest price must fall between the high and low prices for the current day.
- The change amount should approximately equal the latest price minus the 24-hour opening price.
- The change percentage should match the change amount divided by the opening price within an acceptable tolerance.
- The market cap rank must be a positive integer, and its change over time should remain within a reasonable range.
- If the difference between
source_tsand the current time exceeds a configured threshold, the record should be considered stale.
Any failed assertion should be written to a dedicated “invalid data” or “dead-letter” channel instead of being silently discarded. Silent data loss is one of the most difficult failure modes to diagnose in a market data system.
5. Transport and Storage: Use Layered Persistence
A three-layer storage model is recommended:
- Hot layer: Use an in-memory cache to store the latest snapshot and support millisecond-level reads.
- Warm layer: Use a message queue to carry incremental changes and allow multiple downstream consumers to process them in parallel.
- Cold layer: Archive raw payloads in object storage using time-based partitions, enabling historical replay and troubleshooting.
Time-series data should be written to a dedicated time-series storage system. A unique constraint on (symbol, source_ts) naturally supports idempotent writes.
6. Computation and Service Layer
Derived metrics should be calculated in one centralized location to prevent definition drift across multiple implementations. For 24-hour metrics, use sliding-window aggregation instead of repeatedly recalculating over the entire dataset.
SELECT symbol,arg_max(last, source_ts) AS last_price,max(high) AS high_24h,min(low) AS low_24hFROM quotesWHERE source_ts >= now() - INTERVAL '24' HOURGROUP BY symbol;
The service layer should expose read-only APIs. Setting the cache expiration time slightly longer than the collection interval can significantly reduce backend pressure while maintaining data consistency.
7. Observability and Resilient Deployment
Monitoring and alerting should cover four categories of metrics:
- Data freshness and latency
- Assertion failure rate
- Collection success rate
- End-to-end processing time
Container platforms can host stateless collection and computation components. Horizontal scaling can then be used to handle traffic peaks caused by sharp market fluctuations.
A centralized logging service should collect structured logs so that incidents can be quickly investigated by symbol. General-purpose capabilities from Baidu AI Cloud, including object storage, message queues, container platforms, logging, and monitoring and alerting services, can serve as deployment options for this type of pipeline.
8. Common Mistakes
The most common mistakes are:
- Treating display precision as storage precision.
- Using local time for time-window calculations.
- Retrying without an upper limit.
- Scattering validation rules across multiple components.
- Failing to archive raw payloads, making incidents impossible to reproduce.
Avoiding these five issues is usually enough to provide the stability required by most digital asset market data scenarios.
