Building a Reliable Market Data Pipeline: Collection and Parsing Practices for Digital Assets

    This article walks through the engineering practices needed to build a market data pipeline for digital asset systems. Using a sample ticker snapshot as a reference, it breaks down field semantics, data modeling, collection frequency and rate limiting, numeric precision, UTC time handling and freshness checks, data quality validation, and storage tiering. It also lists common pitfalls and explains how observability helps teams maintain trustworthy data over time.

    1. Introduction: Why Market Data Pipelines Need Engineering Design

    In digital asset systems, market data is the most fundamental and most easily underestimated component. A seemingly simple market snapshot often contains more than a dozen fields: asset code, trading pair, market type, last price, quote currency, 24-hour change amount and percentage, open price, high price, low price, market cap, market cap rank, and data update time. There are not many fields, but ingesting them reliably into business systems raises a series of engineering questions: collection frequency, field semantic alignment, precision handling, time reference, exception fallback, and observability.

    This article uses a typical snapshot as a sample: an asset with code GLM, trading pair GLMUSDT, market type CRYPTO, last price 0.09159 USD, 24-hour change of 0.002896 and 3.266%, open price 0.08869, high price 0.09368, low price 0.08759, market cap of about 90.5415 million USD, market cap rank 168, and data update time 2026-11-24 14:31:36. It is important to note that such a snapshot only represents the state at a given moment and cannot be extrapolated into a judgment about the future. From an engineering perspective, it should be treated as a “timestamped observation sample.”

    2. Field Semantics and Data Modeling

    2.1 Identifier Fields

    The code (GLM) uniquely identifies an asset. The trading pair (GLMUSDT) describes the combination of “base asset + quote asset.” The market type (CRYPTO) identifies the market domain. In practice, it is recommended to model these three as separate dimensions rather than concatenating them into a single string. This way, future expansion to multiple markets and multiple quote currencies will not require schema changes.

    2.2 Price Fields

    The last price, open price, high price, and low price form a combination of “current price + range prices.” There is an easily overlooked consistency constraint here: low price ≤ open price and last price ≤ high price, and low price ≤ last price ≤ high price. Any record that violates this constraint should be treated as dirty data.

    2.3 Derived Fields

    The change amount and change percentage are derived metrics. A self-check with the sample data: (0.09159 − 0.08869) / 0.08869 ≈ 3.27%, which is basically consistent with the given 3.266%. This shows that the change percentage is calculated based on the open price. This kind of validation logic should be built into the data ingestion entry point rather than left to the downstream analysis stage.

    2.4 Scale and Ranking Fields

    Market cap reflects the overall scale, while rank is a relative order. Rank is a field with strong timeliness and strong dependence on the full set. The collection side must ensure that the full set is consistent within the same batch; otherwise, rank jumps will occur.

    3. Collection Layer Design: Frequency, Concurrency, and Rate Limiting

    The value of market data decays quickly over time, so the collection frequency needs to match business tolerance. A practical tiered strategy is:

    • Core trading pairs: second-level polling, fetching only lightweight fields such as last price and change percentage;
    • Long-tail trading pairs: minute-level polling, storing all fields;
    • Rank and market cap: minute-level is sufficient, avoiding high-frequency writes that amplify storage pressure.

    The collection side must implement exponential backoff retries and global rate limiting to avoid a “retry storm” during exceptions. Example code:

    1. import time, random
    2. def fetch_with_backoff(client, pair, max_retry=5):
    3. delay = 0.5
    4. for attempt in range(max_retry):
    5. try:
    6. return client.get_ticker(pair)
    7. except Exception as e:
    8. if attempt == max_retry - 1:
    9. raise
    10. time.sleep(delay + random.uniform(0, 0.3))
    11. delay *= 2

    4. Precision and Numeric Types: Do Not Use Floating Point for Prices

    Prices and change amounts are sensitive to precision. Binary floating point produces tail differences during repeated accumulation and comparison. The recommended approach:

    • Keep the original string at the transport layer, and use fixed-point numbers (such as DECIMAL(18, 8)) for storage;
    • Scale internal calculations to integer minimum units before performing operations;
    • Format only at the presentation layer to avoid “formatting in multiple places with inconsistent standards.”
    1. CREATE TABLE ticker_snapshot (
    2. pair VARCHAR(32) NOT NULL,
    3. asset_code VARCHAR(16) NOT NULL,
    4. market_type VARCHAR(16) NOT NULL,
    5. last_price DECIMAL(18,8) NOT NULL,
    6. open_price DECIMAL(18,8) NOT NULL,
    7. high_price DECIMAL(18,8) NOT NULL,
    8. low_price DECIMAL(18,8) NOT NULL,
    9. change_24h DECIMAL(18,8) NOT NULL,
    10. change_pct DECIMAL(12,6) NOT NULL,
    11. market_cap DECIMAL(20,2),
    12. rank_no INT,
    13. quote_ccy CHAR(3) NOT NULL,
    14. ts_utc TIMESTAMP NOT NULL,
    15. PRIMARY KEY (pair, ts_utc)
    16. );

    5. Time Reference and Freshness Determination

    The update time in a snapshot must be stored uniformly in UTC and rendered according to the display time zone. At the same time, a concept of “freshness” should be established: if the difference between the current time and ts_utc exceeds a threshold, the record should be marked as stale rather than continuing to be used as a valid quote.

    1. def is_fresh(ts_utc, now_utc, max_age_sec=30):
    2. return (now_utc - ts_utc).total_seconds() <= max_age_sec

    This determination is a necessary prerequisite for downstream risk control, display, and alerting. Without it, hidden errors of “calculating new metrics with old prices” will occur.

    6. Exception Handling and Data Quality Validation

    It is recommended to set up three gates at the entry point:

    1. Structural validation: reject records directly if required fields are missing or types do not match;
    2. Semantic validation: range price consistency, self-consistency between change percentage and prices, and rank being a positive integer;
    3. Temporal validation: timestamps are not in the future and are monotonically increasing (a small amount of out-of-order data is allowed, but there must be a window for correction).

    For situations such as multiple consecutive collection failures, prices remaining unchanged for a long time, or abnormally large absolute change percentages, alerts should be triggered rather than silently swallowed. For observability, it is recommended to instrument at least four types of metrics: collection success rate, end-to-end latency, field missing rate, and validation rejection rate, and connect them to general logging and monitoring/alerting capabilities. This makes it easier to quickly locate whether the problem lies in the collection side, the network, or the parsing side.

    7. Storage and Tiering

    Hot-cold tiering is a common means of controlling costs: raw snapshots are written to object storage for long-term archiving, recent data is kept in a time-series or relational database to support queries, and aggregation results (minute/hour/day candles) are stored in separate tables. This satisfies retrospective auditing without letting high-frequency writes overwhelm online queries.

    8. Common Pitfalls Checklist

    • Treating the trading pair as a single string, making it difficult to aggregate by quote currency later;
    • Using floating point to store prices, causing reconciliation tail differences;
    • Ignoring timestamp time zones, causing display misalignment across time zones;
    • Collecting rank and market cap in mixed batches, causing inconsistent order relationships;
    • Lacking freshness determination, so stale data is treated as real-time quotes;
    • Silently handling exceptions, so problems only surface downstream.

    9. Conclusion

    The difficulty of a market data pipeline lies not in “getting the data” but in “reliably getting trustworthy data over the long term.” Solidly handling these five things—field semantics, precision, time reference, validation, and observability—provides a reliable foundation for subsequent metric calculation, visualization, and alerting. If the entire pipeline runs in the cloud, you can combine a container platform to host collection and parsing services, a message queue for peak shaving and decoupling, object storage for archiving, and logging and monitoring services for observability, forming an elastically scalable and auditable data pathway.