Collecting and Parsing Digital Asset Market Data: A Practical Guide

    This article walks through the engineering practices for collecting and parsing digital asset market data, using a sample ticker snapshot as the starting point. It covers field semantics and type design, high-precision price storage, symbol splitting, consistency validation, timestamp normalization, collection scheduling with polling and backoff, hot/warm/cold storage tiers, observability and alerting, and a checklist of common pitfalls. The goal is a stable, scalable, and observable market data pipeline built on a trustworthy data foundation.

    1. Starting from a Single Ticker Snapshot

    When building a market dashboard, a quantitative backtest, or a risk monitoring module, the first step is often not writing a strategy but fully understanding what a “single market data record” actually contains. Below is a typical public ticker snapshot (timestamped 2026-11-24 14:34:37):

    1. Symbol: GLM
    2. Pair: GLMUSDT
    3. Market Type: CRYPTO
    4. Name: Golem
    5. Last Price: 0.09109
    6. Quote Currency: USD
    7. 24h Change Amount: 0.002397
    8. 24h Change Percent: 2.703%
    9. Open Price: 0.08869
    10. High Price: 0.09368
    11. Low Price: 0.08759
    12. Market Cap: 90.5415 Million
    13. Market Cap Rank: 168

    This record is dense with information, but the fields carry a number of implicit engineering constraints. If you push it straight into a database or feed it to a frontend, you will inevitably run into precision loss, timezone misalignment, and inconsistent market cap definitions. Let’s break it down layer by layer.

    2. Field Semantics and Type Design

    2.1 Price Fields: Always Use High-Precision Types

    The last price, open price, high price, and low price are essentially fixed-point decimals and must never be carried by binary floating point. A value like 0.09109 will exhibit tail differences under floating point, and once accumulated the error is amplified, distorting backtest results. There are three common engineering approaches:

    • Use a fixed-point type at the database layer (such as DECIMAL(20,8)), keeping enough decimal places;
    • Carry the decimal text as a string at the transport layer, avoiding errors introduced by JSON number parsing;
    • Use a high-precision decimal library or fixed-point integers at the compute layer (multiply the price by 10^8 and operate on integers).

    An illustrative table schema:

    1. CREATE TABLE ticker_snapshot (
    2. symbol VARCHAR(32) NOT NULL,
    3. base_asset VARCHAR(16) NOT NULL,
    4. quote_asset VARCHAR(16) NOT NULL,
    5. market_type VARCHAR(16) NOT NULL,
    6. last_price DECIMAL(20,8) NOT NULL,
    7. open_price DECIMAL(20,8) NOT NULL,
    8. high_price DECIMAL(20,8) NOT NULL,
    9. low_price DECIMAL(20,8) NOT NULL,
    10. change_amount DECIMAL(20,8) NOT NULL,
    11. change_pct DECIMAL(12,4) NOT NULL,
    12. market_cap DECIMAL(24,2),
    13. cap_rank INT,
    14. snapshot_at TIMESTAMPTZ NOT NULL,
    15. PRIMARY KEY (symbol, snapshot_at)
    16. );

    2.2 Trading Pair and Market Type: Split, Don’t Concatenate

    GLMUSDT is the concatenation of “base asset + quote asset.” Using it directly as a primary key will leave you stuck when you later add new quote currencies. The correct approach is to split it into two columns, base_asset and quote_asset, keeping the pair string only as a display field. market_type identifies the market category (such as crypto spot, derivatives, etc.); it determines differences in the subsequent fee model, price constraints, and risk control rules, and must be modeled explicitly rather than left to convention.

    2.3 Change Amount and Change Percent: Consistency Check

    The change amount and change percent are not independent pieces of information; they satisfy:

    1. change_amount ≈ last_price - open_price
    2. change_pct ≈ change_amount / open_price * 100

    Plugging in the sample: 0.09109 − 0.08869 = 0.00240, which is consistent with the given 0.002397 within rounding error; 0.002397 / 0.08869 ≈ 2.703%, which also matches. This means the data pipeline can add a cheap but effective consistency assertion to keep dirty upstream data out of the database:

    1. def validate(row, eps=1e-6):
    2. assert abs(row.high - row.low) >= 0
    3. assert row.low - eps <= row.last <= row.high + eps
    4. assert row.low - eps <= row.open <= row.high + eps
    5. assert abs((row.last - row.open) - row.change) < 1e-4
    6. assert abs(row.change / row.open * 100 - row.change_pct) < 0.01

    At the same time, note that the high of 0.09368 and the low of 0.08759 form an amplitude of about 6.9%, far larger than the 2.7% close gain—this suggests that “bullish” is only an interval conclusion, and volatility risk must be measured separately.

    2.4 Market Cap and Rank: The Definition Must Be Written into Metadata

    A market cap of about 90.5415 million and a rank of 168—these aggregate metrics are extremely sensitive to definition: is it circulating market cap or fully diluted market cap? Is the quote currency USD or the local currency? Is the ranking across the whole market or spot only? Engineering-wise, the definition should travel with the data as field metadata; otherwise cross-source comparisons will run into the serious problem of “same name, different meaning.”

    2.5 Timestamps: Normalize to a Timezone-Aware Format

    2026-11-24 14:34:37 lacks timezone information and is one of the most common hidden hazards in a data pipeline. The standard practice is to use timezone-aware timestamps internally (stored in UTC, rendered in the display layer’s timezone) and to keep both the original collection time and the data generation time, making it easier to troubleshoot latency.

    3. Collection Layer Design: Polling, Incremental Updates, and Rate Limiting

    Market data is usually obtained through public interfaces in two forms: snapshots or incremental streams. The engineering key points:

    1. Tiered polling intervals: mainstream pairs can be polled every 1–3 seconds, long-tail pairs every 10–30 seconds, driven by a config table rather than hardcoding.
    2. Incremental first: prefer incremental push, and backfill with a snapshot after disconnection, avoiding repeated full pulls.
    3. Backoff retry: use exponential backoff with jitter for rate limiting and network jitter to prevent retry storms.
    4. Cursor persistence: persist the “last successfully processed time/sequence” to the database, and resume from the cursor after restart to guarantee no duplicates and no gaps.
    1. import time, random
    2. def poll_with_backoff(fetch, max_retry=6):
    3. delay = 1.0
    4. for attempt in range(max_retry):
    5. try:
    6. return fetch()
    7. except Exception as e:
    8. time.sleep(delay + random.uniform(0, 0.3))
    9. delay = min(delay * 2, 30)
    10. raise RuntimeError("Market data fetch failed repeatedly")

    4. Storage and Compute: Hot/Warm/Cold Tiering

    • Hot data: tick snapshots from the last few hours kept in memory or a time-series store, serving the real-time dashboard;
    • Warm data: minute-level and hour-level aggregates written to columnar storage, serving backtests and reports;
    • Cold data: raw snapshots archived to object storage, read back on demand to control costs.

    When aggregating, stick to the order “validate first, aggregate second, persist last” to avoid dirty data polluting all downstream windows. K-line synthesis needs explicit boundary rules (left-closed, right-open, aligned to the collection time); otherwise cross-window double counting will occur.

    5. Observability and Alerting

    The failure of a market data pipeline is often “silent”: the interface does not error, but the data freezes at a certain moment. You must establish four categories of metrics:

    • Freshness: the elapsed time since the latest snapshot; alert when it exceeds a threshold;
    • Completeness: whether the record count per pair drops sharply;
    • Consistency: the failure rate of the price and change validations mentioned above;
    • Latency: the distribution of time from collection to persistence.

    You can leverage a cloud provider’s general-purpose logging service and monitoring/alerting capabilities to handle metric collection, dashboard display, and threshold notifications, without building the entire stack yourself. If you need elastic compute to handle peak pulls and recomputation, you can use a container platform together with a message queue for peak shaving and decoupling.

    6. Common Pitfalls Checklist

    1. Storing prices as floating point, causing backtest tail differences;
    2. Not splitting the trading pair, leading to a full rework when adding quote currencies;
    3. Timestamps without a timezone, causing cross-day aggregation misalignment;
    4. Unclear market cap definition, leading to wrong conclusions in cross-source comparisons;
    5. Only looking at change percent without amplitude, underestimating risk;
    6. No freshness monitoring, so data stops updating for days without anyone noticing;
    7. Retrying without backoff, falling into an avalanche after being rate limited.

    7. Summary

    A seemingly simple ticker snapshot involves at least five areas in engineering: type design, consistency validation, collection scheduling, hot/warm/cold tiering, and observability. Doing these three things solidly—field semantics, definition metadata, and time standards—gives the subsequent dashboard, backtest, and risk control a trustworthy data foundation. The above are common industry practices and can be implemented with Baidu AI Cloud’s general-purpose storage, container, and monitoring capabilities to form a stable, scalable, and observable market data pipeline.