Digital Asset Market Data: Collection, Parsing, and Monitoring Practices
This article walks through how to build a digital asset market data pipeline, using a sample ticker record to explain the standard field structure. It covers time-partitioned data modeling for high write volumes, a multi-source collection gateway with normalization and idempotent writes, the trade-off between real-time and batch ingestion, multi-layer data validation, and monitoring with cost optimization. Developers will learn the key practices for creating a stable, scalable, and maintainable market data system.
1. Reading Data Structure from a Market Snapshot
The source material provides a typical digital asset market record: the asset code is GLM, the trading pair is GLMUSDT, the market type is CRYPTO, the latest traded price is about 0.09129 USD, the 24-hour change is 0.002597 (2.928%), the open price is 0.08869, the high is 0.09368, the low is 0.08759, the market cap is about 90.5415 million USD, the market cap rank is 168, and there is an update timestamp precise to the second.
For developers, the value of this record is not any specific number but the fact that it reveals the standard field set of market data. We can abstract it into four categories:
- Identifiers: asset code, trading pair, and market type, which together form the primary key that uniquely identifies a ticker;
- Prices: latest price, open, high, and low, which make up the basis of OHLC;
- Derived fields: change amount and change percentage, calculated from prices and not to be treated as the single source of truth;
- Scale and metadata: market cap, market cap rank, quote currency, and update time.
A common mistake is to store “change percentage” as a raw field and use it in calculations. The rigorous approach is to persist only verifiable raw quantities (price, time, trading pair) and derive the metrics in the query or compute layer in real time, avoiding self-contradictory data when upstream conventions change.
2. Data Modeling: Designed for High-Frequency Writes
Market data is characterized by “many writes, few reads, aggregated by time.” Modeling should therefore prioritize time-based partitioning and compression.
CREATE TABLE market_tick (symbol VARCHAR(32) NOT NULL, -- Trading pairmarket_type VARCHAR(16) NOT NULL, -- Market typeprice DECIMAL(18,8) NOT NULL, -- Latest priceopen_price DECIMAL(18,8),high_price DECIMAL(18,8),low_price DECIMAL(18,8),quote_ccy VARCHAR(8),ts TIMESTAMP NOT NULL, -- Data timestampPRIMARY KEY (symbol, ts)) PARTITION BY RANGE (ts);
Key points:
- Use high-precision fixed-point numbers for prices instead of floating point to eliminate precision drift;
- Include time in the primary key to naturally support time-series append writes;
- Partition by time to enable hot/cold tiering, with historical data offloaded to object storage for archiving;
- Store volatile fields such as market cap and rank in a separate table to avoid polluting the time-series main table.
3. Collection Layer: Multi-Source Pulling and a Unified Gateway
Production environments should not rely on a single data source. The recommended approach is to build a “collection gateway” that normalizes different sources into an internal standard structure:
def normalize(raw: dict) -> dict:return {"symbol": raw["code"],"market_type": raw["marketType"],"price": float(raw["last"]),"open": float(raw["open"]),"high": float(raw["high"]),"low": float(raw["low"]),"ts": parse_ts(raw["updateTime"]),}
Design principles:
- Adapter pattern: one adapter per source, so adding a source does not change the core logic;
- Rate limiting and backoff: apply token-bucket rate limiting to upstream calls and use exponential backoff for retries on failure;
- Idempotent writes: use (symbol, ts) as the idempotency key so duplicate deliveries do not create dirty data;
- Message decoupling: buffer between collection and storage with a message queue to handle upstream jitter.
4. Scheduling and the Real-Time Trade-Off
Market updates happen at the second or even sub-second level. In engineering, this is usually split into two pipelines:
- Real-time pipeline: long-connection push, responsible for the latest price and order book changes, with low latency but complex implementation;
- Batch pipeline: scheduled polling (e.g., once per minute), responsible for filling in low-frequency fields such as OHLC and market cap.
The two pipelines are aligned by time windows and finally merged with a “batch as primary, real-time as auxiliary” strategy, ensuring data is traceable and reconcilable.
5. Quality Validation: Blocking Dirty Data Before Storage
Multi-layer validation is essential:
- Range validation: price must be greater than 0, and high ≥ latest price ≥ low;
- Jump validation: flag for manual confirmation when the change between two adjacent points exceeds a threshold (e.g., 20%);
- Time validation: timestamps must not go backward, and duplicate timestamps must be deduplicated;
- Consistency validation: the change amount should be self-consistent with the open and latest prices.
def valid(t: dict, threshold: float = 0.2) -> bool:if t["price"] <= 0: return Falseif not (t["high"] >= t["price"] >= t["low"]): return Falseif t["open"] and abs(t["price"] - t["open"]) / t["open"] > threshold:return Falsereturn True
6. Monitoring, Alerting, and Cost Optimization
Feed validation results into the monitoring and alerting system: collection latency, write failure rate, and the number of data gaps should all be core metrics. You can use general-purpose cloud logging and monitoring/alerting capabilities to collect metrics, display dashboards, and send threshold notifications.
For cost, the recommendations are:
- Keep hot data in the time-series database and periodically move warm/cold data to object storage;
- Run collection and compute tasks on a container platform with elastic scaling based on load;
- Cache high-frequency query results to reduce database pressure.
7. Conclusion
A seemingly simple market record is backed by a complete system of identifiers, prices, derived metrics, and metadata. As long as developers grasp the five key points—raw quantities first, time partitioning, idempotent writes, multi-layer validation, and pipeline separation—they can quickly build a stable, scalable, and maintainable digital asset market data pipeline on platforms such as Baidu AI Cloud, laying a solid foundation for downstream quantitative analysis, risk control, and visualization applications.
