Building a Real-Time Market Data Pipeline for Digital Assets: Ingestion, Computation, and Push Delivery
This article walks through the engineering behind a digital asset market data service, using a typical market snapshot as the starting point. It covers designing a unified data model with precise field semantics, building a hybrid collection layer with subscription, polling, backoff, and circuit breaking, defining derived metrics with strict formulas, tiered storage for hot, warm, and cold data, stable query and streaming APIs, and the observability and compliance practices needed to keep every number traceable, reproducible, and explainable. A production readiness checklist is included.
1. Starting from a Market Snapshot
A typical digital asset market page displays fields such as the trading pair, market type, asset name, latest price, quote currency, 24-hour change in absolute and percentage terms, opening price, high, low, market cap, market cap rank, and data update time. It may look like just a set of numbers, but from an engineering perspective it is a point-in-time snapshot, and behind it sit four questions that must be answered:
- Source and frequency: Who produces the snapshot, how often is it refreshed, and is the refresh delay perceptible?
- Semantic consistency: What is the baseline for percentage change, how is market cap calculated, and what determines ranking?
- Consistency guarantees: When multiple sources conflict, which one wins? How are out-of-order and duplicate data handled?
- Delivery model: Does the consumer pull or subscribe (push)? How does the system degrade on failure?
The core tension in a market data service is that upstream data changes continuously while downstream consumers require results that are explainable, reproducible, and traceable. Therefore, the first design step is not writing collection code but locking the “field semantics” into a contract.
2. A Unified Data Model: Define the Semantics First
Model the snapshot as an immutable structure and store all derived fields separately. This prevents “computed values overwriting raw values,” which would make backtracking impossible.
{"symbol": "XXX/USDT","market_type": "CRYPTO","base_asset": "XXX","quote_currency": "USDT","price": "0.09359","change_24h_abs": "0.00000","change_24h_pct": "0.000","open_24h": "0.09359","high_24h": "0.09539","low_24h": "0.09119","market_cap": "93733100","rank": 164,"source_ts": "2026-12-01T19:52:38Z","ingest_ts": "2026-12-01T19:52:41Z","seq": 88213}
Key design points:
- Transmit prices as strings or fixed-point decimals. Floating-point numbers can suffer
0.1 + 0.2style errors during cross-language, cross-platform serialization. Amount and price fields should use decimal fixed-point representation throughout, converting only at the presentation layer. - Separate
source_tsfromingest_ts. The former is when the upstream generated the data; the latter is when it was persisted locally. The difference is the end-to-end latency, the primary troubleshooting indicator. - Use
seqor a version number to detect out-of-order data. Network jitter can cause an older snapshot to arrive after a newer one. A monotonic sequence number or timestamp is required to “drop stale writes.” - Keep derived fields separate from raw fields. Percentage change, market cap, and rank can all be recomputed from raw fields, so changes to the derivation logic never require backfilling historical data.
3. Collection Layer: Polling, Push, and Backoff
Market data collection typically combines long-lived push subscriptions with scheduled polling as a fallback:
for each symbol in watchlist:task = poll_or_subscribe(symbol)on message(msg):if msg.seq <= last_seq[symbol]: dropraw = normalize(msg)derived = compute(raw)cache.set(symbol, derived, ttl=2s)mq.publish("quote.derived", derived)on error(e):backoff = min(base * 2^attempt, cap) + jittersleep(backoff); attempt += 1
Key considerations:
- Exponential backoff with jitter: Fixed-interval retries create synchronized request storms when the upstream is unstable; random jitter spreads out the load spikes.
- Circuit breaker with half-open probing: After consecutive failures exceed a threshold, suspend the subscription to avoid piling up invalid requests. During recovery, let a small number of probe requests through first.
- Rate limiting on both sides: A client-side token bucket controls request rate; server-side quotas per caller protect the backend. Both directions are protected.
- Subscription deduplication: When multiple tasks subscribe to the same trading pair, use consistent hashing or a registry to ensure a single instance handles it, avoiding duplicate billing and duplicate computation.
4. Computation Layer: Strict Definitions for Derived Metrics
Derived metrics must have their formulas written down explicitly, or different teams will produce different results.
- Percentage change:
pct = (price - open_24h) / open_24h. If the denominator is zero, return null rather than 0. - Amplitude:
(high_24h - low_24h) / low_24h, used for risk display. - Market cap:
price × circulating supply. If circulating supply is missing, mark the market cap as “unavailable” — never silently substitute total supply. - Ranking: Sort descending by market cap; document the scope (whole market vs. spot only) and the snapshot timestamp.
Computation tasks should be idempotent: the same input produces the same output, which makes replay and compensation straightforward.
5. Storage and Caching: Hot/Warm/Cold Tiering
- Hot data: Latest snapshots go into an in-memory cache. Set the TTL slightly longer than the collection interval. On a cache miss, fall back to the source with a mutex to prevent cache stampedes.
- Warm data: Near-real-time quotes go to a message queue and are persisted in parallel by consumers, smoothing out peaks.
- Cold data: Historical snapshots and minute-level aggregates go to time-series storage; raw payloads are archived in object storage for auditing and backtracking.
- Degradation chain: cache → read-only replica → static fallback snapshot (clearly labeled “data may be delayed”).
6. Service Layer: Query and Streaming
Expose only a stable contract externally; the internal implementation can be replaced:
GET /quotes?symbols=A,B&fields=price,change_24h_pctGET /quotes/{symbol}/history?interval=1m&from=&to=SUB /stream/quotes # incremental push, carries seq, clients can resume
For push delivery, combine incremental updates with periodic full-state reconciliation: incremental updates reduce bandwidth, while full snapshots repair state drift caused by dropped packets. When a client reconnects, it sends its last seq; the server either backfills the gap or forces a full refresh.
7. Observability, Security, and Compliance
Metrics to monitor include collection latency percentiles, field-missing rates, sequence-number regressions, computation duration, cache hit rate, and per-source availability and quota headroom. Logs should be structured and shipped to a logging service; metrics feed into alerting. Alert on tiers such as “latency increase / missing-field increase / source circuit breaker open.”
On the security side: API authentication and per-caller rate limiting, secrets managed through a key management service, minimal externally exposed fields, and end-to-end auditing. In addition, market data services should clearly state at the product level that they provide data only and do not constitute investment advice.
8. Production Readiness Checklist
- Field-semantics documentation reviewed and approved;
- Fixed-point precision and null-value semantics unified;
- Tests covering out-of-order, duplicate, and missing data;
- Backoff, circuit breaking, and degradation drilled;
- Streaming resume and full-state reconciliation verified;
- Monitoring, alerting, and on-call response in place.
9. Conclusion
The hard part of a market data service is not “fetching a price” — it is making every number traceable, reproducible, and explainable. Encode semantics into contracts, treat exceptions as normal, and build observability into the first release. That is what supports everything from a personal dashboard to an institution-scale data platform. For rapid deployment, run stateless collection and computation services on a container platform, use a message queue to absorb peaks, use object storage and time-series storage for cold data, and complete the operations loop with logging, monitoring, and alerting.
