Collecting and Parsing Crypto Market Data: A Practical Guide

    This article walks through the practical engineering decisions behind collecting and parsing crypto market data, using a sample spot snapshot as the starting point. It explains how to layer fields into price, statistics, and metadata groups, why fixed-point precision matters, how to handle time zones and collection latency, which data quality checks to run before storage, and how to combine polling with push in a two-tier pipeline. Storage and query recommendations are included, along with three core principles for separating raw facts from derived metrics, event time from ingestion time, and settlement assets from display units.

    1. Starting With a Single Market Snapshot

    When building a market dashboard, a quantitative backtesting system, or a risk alerting pipeline, the most fundamental and most underestimated step is collecting and parsing market data. Below is a typical spot market snapshot (fields have been generalized):

    1. Symbol: GLM
    2. Pair: GLMUSDT
    3. Market Type: CRYPTO
    4. Last Price: 0.09119
    5. Quote Currency: USD
    6. 24h Change: 0.002497
    7. 24h Change %: 2.815%
    8. Open Price: 0.08869
    9. High Price: 0.09368
    10. Low Price: 0.08759
    11. Market Cap: 90.5415M
    12. Market Cap Rank: 168
    13. Updated At: 2026-11-24 14:24:39

    This record carries a lot of information, but feeding it directly into a database or a downstream model will almost certainly cause problems. The issue is not the data itself, but that it mixes three categories of information with completely different semantics: price fields, statistics fields, and metadata fields. The first engineering step is to separate them.

    2. Field Semantics: Classify First, Model Second

    It is recommended to assign every market data field to one of three layers:

    • Price layer: last price, open price, high price, low price. These change frequently, share the same unit, and require precision control.
    • Statistics layer: 24h change, 24h change percentage, market cap, market cap rank. These update infrequently, are derived from other values, and depend on the statistical window.
    • Metadata layer: symbol, pair, market type, quote currency, updated-at time. These rarely change and serve as the primary key source for data joins and partitioning.

    The value of layering is that each layer can follow a different storage and update strategy. The price layer fits time-series or columnar storage, partitioned by time and sharded by symbol. The statistics layer updates infrequently and fits a general relational store or cache, using the symbol as the primary key for overwrite writes. The metadata layer is a dimension table and fits in-memory residency.

    A common mistake is storing derived fields (change and change percentage) as raw facts. There is a clear derivation relationship between them:

    1. Change = Last Price - Open Price
    2. Change % = Change / Open Price × 100%

    Plugging in the sample data: 0.09119 − 0.08869 = 0.00250, which differs slightly from the given 0.002497; 0.002497 / 0.08869 ≈ 2.815%, which matches the given value. This difference is not a data error but rounding error: the display layer typically keeps 5 decimal places, while internal calculations keep higher precision. The correct engineering practice is to persist only the raw prices and compute derived metrics at query time, or to explicitly record their precision and rounding rules, avoiding error accumulation when downstream systems perform further calculations.

    3. Precision and Units: The Underrated Pitfalls

    A decimal like 0.09119 will produce tail differences when stored as a binary floating-point value and accumulated heavily (for example, when computing turnover or weighted average price). The common industry practice is:

    1. During collection, parse the price string as a fixed-point number and scale it up uniformly to an integer for storage (for example, scale by 10^8 and store as long);
    2. Convert back to a decimal only for display and export;
    3. Explicitly declare the number of decimal places for each price field in the data dictionary.

    Illustrative code (pseudo-implementation, conveying the idea only):

    1. from decimal import Decimal
    2. SCALE = Decimal("1e8")
    3. def parse_price(raw: str) -> int:
    4. # Fixed-point conversion: string -> high-precision decimal -> integer
    5. return int(Decimal(raw) * SCALE)
    6. def format_price(v: int) -> str:
    7. return str(Decimal(v) / SCALE)

    The quote currency field deserves equal attention. In the sample, the pair is GLMUSDT while the quote currency is labeled USD. This is common in the industry: the pair suffix represents the settlement asset, while the display convention is often converted to US dollars. Mixing the two leads to inconsistent units when aggregating across symbols. The proper approach is to keep two separate fields, “pair settlement asset” and “display quote unit,” and explicitly convert before aggregation, never implicitly assuming the two are equal.

    4. Time Semantics: Time Zones, Frequency, and Latency

    Updated At: 2026-11-24 14:24:39 lacks time zone information, which is the most common hidden risk in market data. Recommendations:

    • Use timezone-aware UTC timestamps in the storage layer (such as Unix milliseconds);
    • Render in the user’s time zone in the display layer;
    • Attach two times to each record: event time and ingestion time. Their difference is the collection latency, one of the core data quality metrics.

    It is also important to distinguish a “snapshot” from a “candlestick.” A snapshot is the state at a given moment, while a candlestick is an interval aggregation result. The high and low prices in the sample belong to a 24-hour rolling window statistic, not a daily candle. The two must not be mixed, or backtest results will show systematic bias.

    5. Data Quality Validation Rules

    Before storage, at least five categories of validation are recommended:

    Validation Type Rule Example Action
    Range consistency Low ≤ Open/Last ≤ High Reject and alert
    Derivation consistency Deviation between change % and derived change < threshold Flag as suspicious, keep original value
    Monotonicity New record time > previous record time Drop out-of-order data
    Jump detection Adjacent last price change exceeds N standard deviations Move to a review queue
    Completeness Required fields non-empty, rank is a positive integer Reject

    The sample data passes these checks: 0.08759 ≤ 0.08869 and 0.09119 ≤ 0.09368, so the range holds; rank 168 is a positive integer; market cap and price are consistent in magnitude.

    6. Collection Architecture: Combining Polling and Push

    A production market data pipeline typically uses a two-tier structure:

    • Fast tier: poll the snapshot endpoint on a schedule, with intervals tiered by symbol liquidity (second-level for major symbols, minute-level for long-tail symbols), writing results to time-series storage;
    • Slow tier: scheduled jobs persist the statistics and dimension layers, performing full alignment and gap filling.

    Polling must handle incremental updates and deduplication: use (symbol, event time) as the unique key for idempotent writes to avoid duplicates from retries. The gap-filling task scans the timeline for gaps and decides whether to replay or mark as missing based on gap length. Fabricating data with interpolation is prohibited.

    For observability, instrument at least three metrics: collection success rate, collection latency percentiles, and validation rejection rate. An alert should fire when any metric goes out of bounds, which is far more effective than simply monitoring process liveness.

    7. Storage and Query Recommendations

    • Price layer: time-series or columnar storage, partitioned by time and sorted by symbol, with queries primarily filtering by time range and symbol;
    • Statistics layer: key-value or relational store with overwrite writes;
    • Dimension layer: in-memory cache plus local table dual-write.

    If data volume grows to the point where elastic scaling is needed, a combination of general cloud capabilities can be used: a message queue for collection buffering and peak shaving, object storage for cold data archiving, a container platform for stateless collection and cleaning tasks, and log and monitoring services for tracing and anomaly notification. This combination is a common industry approach; selection should be based on data scale, latency requirements, and cost model rather than chasing specific products.

    8. Summary

    A seemingly simple market snapshot expands into six engineering decision points: semantic layering, fixed-point precision, time semantics, quality validation, collection architecture, and storage selection. The core conclusion is a single sentence: separate raw facts from derived metrics, separate event time from ingestion time, and separate settlement assets from display quote units. Getting these three right lays the foundation for a stable and scalable market data pipeline, giving dashboards, backtesting, and risk control a trustworthy data foundation.