Practical Guide to Collecting and Parsing Digital Asset Market Data
This article walks through the engineering practices for building a digital asset market data pipeline, using a sample ticker snapshot to explain the data structure. It covers field modeling and type design, collection with polling and incremental watermarks, layered validation and cleaning, storage and query optimization, monitoring and observability, and a cloud deployment approach. Readers will learn how to keep market data consistent, stable, and traceable over time.
1. Start With a Single Market Snapshot
When building a market data system, the most basic input is usually a structured snapshot record. The sample below is for structural demonstration only:
{"symbol": "GLMUSDT","market_type": "CRYPTO","base_asset": "GLM","quote_asset": "USDT","last_price": 0.09129,"quote_currency": "USD","change_24h": 0.002597,"change_pct_24h": 2.928,"open_24h": 0.08869,"high_24h": 0.09368,"low_24h": 0.08759,"market_cap": 90541500,"rank": 168,"updated_at": "2026-11-24 14:26:36"}
This record contains four categories of information: instrument identity (trading pair and market type), price metrics (last, open, high, and low), derived metrics (24-hour change amount and percentage), and scale and ranking metrics (market cap and rank). In engineering terms, raw fields and derived fields should be stored in separate layers. Derived metrics can be recomputed from raw fields at any time, which avoids data inconsistency when upstream definitions change.
2. Field Modeling and Type Design
Rigorous type design is the first line of defense in a data pipeline. The recommendations are:
- Use high-precision decimal types for prices and change amounts. Do not use binary floating point for accumulation or comparison, to avoid precision drift.
- Use integers or fixed-point numbers for change percentages and ranks, with an explicit number of decimal places.
- Store time fields as timezone-aware timestamps, convert to UTC on ingestion, and render in the user’s timezone at the presentation layer.
- Add a
schema_versionfield to make it easier to handle compatibility when the upstream structure evolves.
An illustrative definition:
CREATE TABLE ticker_snapshot (symbol VARCHAR(32) NOT NULL,market_type VARCHAR(16) NOT NULL,last_price DECIMAL(18,8) NOT NULL,open_24h DECIMAL(18,8),high_24h DECIMAL(18,8),low_24h DECIMAL(18,8),change_pct DECIMAL(12,4),market_cap DECIMAL(20,2),rank INT,schema_version SMALLINT DEFAULT 1,updated_at TIMESTAMPTZ NOT NULL,PRIMARY KEY (symbol, updated_at));
3. Collection Layer: Polling, Increment, and Rate Limiting
Market data collection typically follows a “scheduled polling plus incremental writes” pattern. Key practices include:
- Use
updated_atas a watermark and pull only records newer than the watermark to reduce ineffective writes. - Apply token bucket or leaky bucket rate limiting to the collection frequency to avoid triggering upstream risk controls.
- Keep collection tasks stateless so they can scale horizontally; store the watermark in external storage so progress is not lost after a restart.
- Use exponential backoff for retries, with a maximum retry count and a circuit breaker threshold.
def fetch_increment(client, symbol, watermark):resp = client.get_ticker(symbol) # pseudocode, illustrative callif resp.updated_at <= watermark:return Nonereturn normalize(resp) # unify fields and types
4. Validation and Cleaning: Keep Dirty Data Out
Common market data anomalies include zero or negative prices, a high lower than the low, change metrics that are inconsistent with prices, timestamps that move backward, and duplicate records. Layered validation is recommended:
- Structural validation: reject records directly when required fields are missing or types do not match.
- Consistency validation:
low <= last <= high, andchange = last - openholds within a tolerance. - Time-series validation:
updated_atis monotonically increasing; data that moves backward goes to a quarantine area for manual review. - Business validation: flag sudden changes in market cap rank beyond a threshold instead of overwriting history directly.
Do not silently drop quarantined data. Write it to a separate quarantine table with alerting so issues remain traceable.
5. Storage and Query Optimization
On the write side, partition by time (by day or by hour) and use batch writes to improve throughput. On the query side, build a composite index on symbol + updated_at, and use materialized views or caching for frequently accessed instruments. Hot and cold tiering also matters: keep recent data in high-performance storage and archive historical data to object storage, using lifecycle policies to move it automatically, balancing cost and query experience.
6. Monitoring, Alerting, and Observability
The health of a market data pipeline needs quantifiable metrics: collection latency (the difference between the current time and the latest data time), write failure rate, validation rejection rate, and end-to-end freshness. Logging and monitoring services can trigger notifications when latency exceeds a threshold or the rejection rate spikes. Also retain raw payloads so they can be traced back when definitions are disputed.
7. Cloud Deployment Approach
In a cloud environment, collection tasks can be deployed on a container platform for elastic scaling, raw payloads can be written to object storage for long-term archiving, a message queue can handle peak shaving and decoupling, and compute tasks can consume the queue to perform cleaning and aggregation, finally writing results to a database and exposing a query interface. Keeping the entire pipeline stateless and replayable is key to stability.
8. Summary
The difficulty of market data is not “fetching a single record,” but staying stable over the long term, keeping definitions consistent, and making anomalies traceable. Getting these five things right—layered fields, rigorous types, upfront validation, watermark-based increments, and complete observability—lets you build a reusable market data foundation for later analysis and presentation.
