Digital Asset Market Data: Collection, Validation, and Presentation Engineering

    This article outlines an engineering approach to digital asset market data pipelines. It explains core field semantics, compares polling and push collection, proposes a three-layer architecture, and details retry, validation, and cleaning rules with sample calculations and pseudocode. The focus is on separating data ingestion from the correct presentation of prices and percentage changes.

    1. Background: Why Market Data Needs Engineering Treatment

    A market page may look like just a few numbers, but behind it is a complete data pipeline. The data source generates quotes, the collection service pulls or receives the data, the processing program performs validation and calculation, and the presentation layer finally shows the result to users. If any link fails, users may see an incorrect price or a stale percentage change. Therefore, when building a market data service, it is necessary to distinguish between “getting the numbers” and “displaying the correct numbers.”

    This article uses a typical set of market fields as an example to explain field semantics, collection architecture, validation rules, derived metric calculation, timezone handling, caching strategies, and presentation conventions, with reusable pseudocode. The sample values in this article are only used to illustrate calculation methods and do not represent any real market state.

    2. Core Fields and Semantics

    A market data record usually contains the following information:

    Field Meaning Engineering consideration
    Last price The most recent trade or latest quote Record the timestamp and specify whether it is a trade price or a mid price
    Open price The price at the start of the statistical window Define the window explicitly: rolling 24 hours or calendar day
    High price / Low price Extremes within the statistical window Values change as the window slides and must be updated synchronously
    Change amount Last price minus the base price The base price must match the base used for percentage change
    Change percentage Change amount divided by the base price Use high-precision decimals and format only at the end
    Market capitalization Circulating supply multiplied by price Depends on circulating supply data; results may differ by source
    Market cap rank Position among comparable assets Fluctuates with market cap in real time but is usually updated less frequently
    Update time The time when the record was generated Must include timezone; otherwise timeliness cannot be judged

    Mathematical relationships between fields are the basis for validation. Using the sample data as an example: last price 0.09139 minus open price 0.08869 equals 0.00270, while the recorded change amount is 0.002697. The difference is about 0.000003 because the displayed price has been rounded, while the raw price has higher precision. Change amount divided by open price is about 3.041%, which matches the recorded change percentage. Therefore, validation must allow tolerance rather than requiring exact equality between fields.

    3. Collection Architecture

    There are two common collection methods.

    1. Polling: The service requests data from the source at fixed intervals. It is simple to implement but is subject to request frequency limits, and data delay exists between two requests.
    2. Push: The service receives updates actively pushed by the data source over a long connection. Latency is lower, but reconnect handling, out-of-order messages, and heartbeat detection are required.

    Regardless of the method used, it is recommended to divide the system into three layers. The access layer communicates with the data source and handles authentication, rate limiting, and retries. The processing layer handles parsing, validation, and calculation. The storage and distribution layer handles caching and external interfaces. With these three layers decoupled, the impact scope remains controllable when replacing a data source or adjusting calculation logic.

    The access layer must comply with the data source’s terms of use and rate limits. On request failure, use exponential backoff retries and set a maximum number of attempts to avoid amplifying traffic during an outage. Example pseudocode:

    1. function fetch_with_backoff(request, max_retries = 5):
    2. delay = 0.5 seconds
    3. for attempt in 1..max_retries:
    4. response = send(request)
    5. if response.ok:
    6. return response.body
    7. if response.status is not retryable:
    8. raise error
    9. sleep(delay + random_jitter)
    10. delay = min(delay * 2, 30 seconds)
    11. raise error("retry attempts exhausted")

    Adding random jitter prevents a large number of clients from retrying at the same moment and creating a request spike.

    4. Data Validation and Cleaning

    After data enters the processing layer, it should be validated before participating in calculations. Suggested rules include the following categories.

    • Completeness: Required fields such as last price, open price, and update time must not be empty.
    • Value range: Prices must be positive. When the change percentage exceeds a configured threshold, mark it for review instead of directly storing and displaying it.
    • Timeliness: When the update time is more than a threshold away from the current time, such as several minutes, mark the data as stale, and the frontend displays “data delayed.”