Building a Crypto Market Data System: Architecture and Real-Time Processing Practices

    Crypto market data underpins every digital-asset application, from quantitative trading and asset dashboards to risk management and compliance auditing. This article walks through how to build a reliable market data system. It covers snapshot data modeling with precise numeric types and clear time semantics, a push-first, polling-fallback ingestion strategy, hot/warm/cold storage tiers, stream-based real-time computation of derived metrics, snapshot and historical query APIs, and data quality monitoring. It also summarizes core practices: decoupling ingestion from computation with a message queue, prioritizing push over polling, and monitoring completeness, anomalies, and latency.

    1. Background: Market Data Is the Lifeblood of FinTech Systems

    Whether it is quantitative trading, an asset dashboard, or risk management and compliance auditing, any application built around digital assets depends on the same foundational capability: accurate, timely, and traceable market data. Quote data is unique in three respects:

    • High-frequency updates: Fields such as price, 24-hour change, and volume refresh continuously on a second-level or even millisecond-level basis.
    • Heterogeneous sources: The same trading pair may trade on multiple venues simultaneously, with different prices and liquidity at each.
    • Strong real-time requirements: Any delay directly affects trading decisions and risk control judgments.

    Building a reliable pipeline for data collection, cleansing, storage, and distribution is therefore a core technical challenge for any market data system.

    2. Modeling Market Data Fields

    A standard quote data structure usually consists of three parts: identification fields, price fields, and statistics. A snapshot of a trading pair can be modeled as follows:

    1. {
    2. "symbol": "XXXUSDT",
    3. "base_asset": "XXX",
    4. "quote_asset": "USDT",
    5. "market_type": "CRYPTO",
    6. "price": 1.32,
    7. "currency": "USD",
    8. "change_24h": 0.01468,
    9. "change_rate_24h": "1.129%",
    10. "open": 1.3,
    11. "high": 1.46,
    12. "low": 1.29,
    13. "market_cap": 350000000,
    14. "rank": 90,
    15. "updated_at": "2026-11-24 12:02:39"
    16. }

    Several modeling decisions deserve particular attention:

    • Numeric precision: Price fields should use fixed-point decimals or high-precision floating-point types. Ordinary floating-point types should be avoided to prevent precision loss. On-chain assets often have low unit prices, so storing them as strings or decimal fixed-point types is safer.
    • Time semantics: updated_at marks the time of the snapshot. It must be clearly defined as either the collection time at the market data source or the time the data is persisted in your system, since these are usually separated by a fixed delay along the pipeline.
    • Statistical definitions: Open price, high, low, and change rate are all rolling metrics computed over a specific time window (usually the past 24 hours). The model should preserve the window definition to avoid ambiguity.
    • Ranking fields: Global statistics such as market cap rank update infrequently and are expensive to compute. They should be decoupled from high-frequency price fields and refreshed separately.

    3. Data Collection and Ingestion Layer Design

    The ingestion layer determines whether the system can keep up with the market. In engineering practice, a hybrid “push-first, polling-fallback” strategy is commonly used. For sources that support real-time push, open a long-lived connection and subscribe to incremental updates. For sources that only expose snapshot endpoints, use tiered polling: poll major trading pairs frequently and long-tail pairs at a lower frequency. This balances timeliness against resource consumption.

    The ingestion layer must address three key engineering challenges:

    1. Rate limiting and backoff: Market data sources commonly enforce rate limits. The collector should implement token-bucket or sliding-window rate limiting, and use exponential backoff for retries on errors to prevent cascading failures.
    2. Multi-source aggregation: When the same trading pair is available from multiple sources, define aggregation rules (e.g., selecting the best bid/ask or computing a weighted reference price). Sources should also be assigned priority and confidence levels.
    3. Incremental updates and full-snapshot reconciliation: Incremental push ensures low latency, but periodic full snapshots should still be pulled to reconcile the data and prevent cumulative drift caused by missed increments.

    Raw data should first flow into a message queue for peak shaving and decoupling. This lets the downstream cleansing, storage, and computation modules scale independently without being blocked by ingestion jitter.

    4. Storage Selection and Query Optimization

    Quote data is a typical write-heavy, time-ordered workload, so storage selection should be driven by that profile:

    • Hot data (recent high-frequency snapshots): Time-series or in-memory storage is well suited, supporting fast queries by time range and trading pair for dashboards and real-time monitoring.
    • Warm data (historical quotes): Columnar storage or object storage archives balance query efficiency and cost, and object storage enables low-cost long-term retention.
    • Cold data (archived history): Used for retrospective analysis, model training, and compliance audits. Access is infrequent, so cost is the top priority.

    Quote queries almost always revolve around two dimensions: the trading pair and the time window. Build composite indexes or partition keys around both. For frequent queries such as the latest price or the day’s high and low, return results directly from pre-aggregated tables or a cache layer instead of scanning massive amounts of detail data in real time.

    5. Real-Time Computation and Derived Metrics

    Raw snapshots are only the starting point. The most valuable data often comes from metrics computed in real time from the underlying detail data. Common computation tasks include:

    • Rolling statistics: Metrics such as 24-hour change rate, volume, and high/low prices, which need to be updated continuously over a sliding window.
    • Volatility and trend indicators: Metrics such as moving averages and price amplitude, used by trading strategies and risk control.
    • Anomaly detection: Alerts triggered when price or volume breaks a threshold within a short period.

    Real-time computation is best handled with a stream processing paradigm: group the quote stream from the message queue by trading pair, aggregate it over time windows into results, and continuously write those results to storage. The following is a simplified example of stream aggregation:

    1. def aggregate_tick(window_data):
    2. """Aggregate the quote snapshots of a trading pair within a window."""
    3. prices = [tick["price"] for tick in window_data if tick["price"] > 0]
    4. if not prices:
    5. return None
    6. return {
    7. "open": prices[0],
    8. "high": max(prices),
    9. "low": min(prices),
    10. "last": prices[-1],
    11. "change_rate": round((prices[-1] - prices[0]) / prices[0] * 100, 3),
    12. "sample_size": len(prices),
    13. }

    In practice, you need to handle out-of-order and late-arriving data at window boundaries. Watermarks can be introduced to tolerate a degree of delay. Extreme out-of-order data can then be either discarded or compensated for under a defined strategy.

    6. Service Layer and API Design

    When exposing data externally, separate two types of APIs: a snapshot query API that returns the latest quote for a trading pair, and a historical range API that returns a series of quotes for a given time period. At the interface level, three things are essential:

    • Unified pagination and rate limiting, so that a single request cannot overwhelm the backend.
    • Clear data freshness information, with the collection time included in responses so callers can perceive latency.
    • A stable field contract that evolves through versioning, so downstream systems are not disrupted by field changes.

    For latency-sensitive quote dashboards, a long-lived push connection can be introduced between the server and clients. This changes “pulling” into “subscribing” and significantly reduces refresh latency.

    7. Monitoring, Alerting, and Data Quality Assurance

    What a quote system should fear most is not slowness but “silent errors” — missing data or abnormal prices that go unnoticed. An independent quality monitoring layer is therefore essential:

    • Completeness monitoring: Compare the expected number of samples per trading pair per minute with the number actually received to identify collection gaps.
    • Outlier detection: Intercept and flag prices outside a reasonable range (such as an abrupt jump of hundreds of times) to prevent them from contaminating downstream computation.
    • Latency monitoring: Track end-to-end latency from when a quote is produced at the source to when it becomes queryable in your system, and trigger alerts when it exceeds the threshold.
    • Consistency checks: Periodically compare multiple sources and internal aggregation results, and alert on any discrepancies.

    Generic cloud monitoring, alerting, and logging services can collect and visualize these metrics and apply threshold-based alerts, forming a closed feedback loop.

    8. Summary and Best Practices

    Building a reliable market data system comes down to a few core principles:

    1. Decouple ingestion from computation: Use a message queue for peak shaving so that each stage can scale independently.
    2. Tier storage by hot, warm, and cold: Choose storage media based on access frequency and cost targets.
    3. Prioritize precision and time semantics: Numeric precision and the time semantics of collection and computation must be strictly defined.
    4. Favor push over polling: In scenarios with high real-time requirements, subscription-based push is the mainstream choice.
    5. Make quality monitoring non-negotiable: Completeness, outlier, and latency monitoring underpin the trustworthiness of the system.

    Ultimately, the value of a market data system lies in whether it provides stable, low-latency, and traceable data to the business layer above it. Once developers understand the internal logic of collection, modeling, storage, computation, and service exposure, they can select and combine suitable general-purpose cloud capabilities to match their business scale. They can then evolve step by step toward a highly available, scalable market data platform.