Real-Time Market Data Architecture for Digital Assets: Design and Implementation
How to design a digital-asset market data system that stays accurate and low-latency: a consistent snapshot model, normalized ingestion, decimal-based derived metrics, layered storage, high availability, and snapshot versus subscription APIs.
1. Starting from a Market Snapshot
In digital-asset markets, a quote snapshot usually includes a symbol (for example, OPEN), a trading pair (for example, OPENUSDT), a market type, a name, the latest price, a quote currency, the 24-hour change amount and percentage, the open, high, and low, market capitalization, market-cap rank, and an update time. The fields look simple, but keeping them accurate and consistent while updating thousands of pairs at second- or millisecond-level intervals requires a complete engineering system.
This article does not discuss the investment value of any specific asset. It uses this data shape as a sample to explain how a market data system should be designed and implemented.
2. A Normalized Data Model
The first step is a single data model. Field names, units, and precision must stay consistent inside the system so downstream services do not keep translating incompatible formats. A typical structure looks like this:
{"symbol": "OPEN","pair": "OPENUSDT","marketType": "CRYPTO","name": "Sample asset","price": "0.07991","currency": "USD","changeAmount24h": "0.0007991","changePercent24h": "1.010","open": "0.07911","high": "0.08381","low": "0.07831","marketCap": "27898300","marketCapRank": 455,"updateTime": "2026-11-24T17:07:29Z"}
A few engineering conventions matter:
- Represent prices as strings or fixed-point decimals. Floating-point types introduce precision errors during accumulation and comparison. Financial systems should use a high-precision decimal type (such as
BigDecimal) or an integer in the smallest unit. - Use a standard timestamp with an explicit time zone. Local time is ambiguous across regions. UTC with a clear offset is the safer choice.
- Separate derived fields from raw fields. Change amount, change percentage, and market-cap rank are calculated values. Their calculation rules and the reference time they depend on should be explicit.
3. Collection and Ingestion
Market data usually comes from multiple upstream sources. To avoid being locked to one provider, the collection layer should expose a unified ingestion interface and normalize different push or pull protocols into an internal standard format.
Two access patterns are common:
- Long-lived push connections. These fit high-frequency latest prices and order-book data. Latency is low, but the system must handle reconnects, heartbeats, and out-of-order messages.
- Scheduled pulls. These fit lower-frequency aggregates such as market cap and rank. They are simpler to implement, but request rate must be controlled so upstream rate limits are not triggered.
The ingestion layer should also deduplicate and validate. For repeated snapshots of the same pair, keep the one with the latest timestamp. Quotes that look clearly abnormal—for example, a large deviation from the recent average—should be flagged and sent through a manual or rule-based review so bad data does not pollute downstream systems.
4. Real-Time Calculation and Derived Metrics
After a raw quote enters the system, many derived metrics must be computed in real time. For percentage change, the core logic is the difference between the current price and a base price, divided by that base price:
from decimal import Decimaldef change_percent(current: Decimal, base: Decimal) -> Decimal:if base == 0:return Decimal("0")return (current - base) / base * Decimal("100")# Example: open 0.07911, latest price 0.07991pct = change_percent(Decimal("0.07991"), Decimal("0.07911"))# Result is about 1.011%
The critical point is a clear definition of the base price. A 24-hour change uses the rolling price from 24 hours earlier, not the calendar-day open. An intraday change uses that day’s open. Mixing these definitions is one of the most common defects in market data systems.
Market-cap rank is a global ordering problem. Market cap equals circulating supply multiplied by the latest price, and rank requires comparison across all assets. When there are many assets and prices keep moving, incremental ordered structures—such as a skip list, or batch reordering over a time window—can balance freshness against compute cost better than a full sort on every update.
5. Data Pipeline and Storage Tiers
A scalable market data system usually stores data in layers:
- Hot tier: An in-memory cache or in-memory database holds the latest prices and order books so high-frequency queries hit memory and stay in the millisecond range.
- Time-series tier: Tick- or second-level historical prices go into time-series storage to support candlesticks, technical indicators, and replay.
- Archive tier: Long-horizon history that is rarely read moves to object storage, partitioned by date, to reduce cost.
On the data path, a message queue decouples collection, calculation, and distribution. The collection layer only writes to the queue, and the calculation layer consumes at its own capacity, so a stall in one stage does not directly overload the upstream source. General-purpose message queues, object storage, container platforms, and logging and monitoring from Baidu AI Cloud can be used to stand up infrastructure with elastic scaling and observability, so effort stays on business logic rather than low-level operations.
6. High Availability and Consistency
A market data system needs both availability and correctness. In practice that means:
- Stateless multi-instance design. Compute and API nodes do not keep local state, which makes horizontal scaling and failover straightforward.
- Idempotency and ordering. Messages carry a monotonically increasing sequence number or timestamp. Consumers drop stale data so the result shown is the latest snapshot.
- Degradation. If one source is unavailable, the system should switch to a backup source, or show the last valid value with a clear delay marker, instead of returning an error or a blank field.
- End-to-end monitoring. Set alert thresholds for collection latency, queue backlog, calculation time, and API success rate, and use logging and monitoring alerts to catch failures quickly.
7. Presentation and API Design
External APIs should separate snapshot queries from real-time subscriptions. A snapshot fits the first page load; a subscription fits a board that keeps refreshing. Subscription pushes can be incremental and send only fields that changed, which reduces bandwidth.
The presentation layer also needs careful number formatting: prices should keep the precision defined for each asset, up and down moves should be distinguished by color, and large figures such as market cap should use localized units. These details directly affect how much users trust the data.
8. Summary
Behind one market snapshot is a full chain: data modeling, ingestion, real-time calculation, tiered storage, high availability, and presentation. The hard part is not any single feature. It is keeping definitions consistent and latency low in a high-concurrency stream that never stops changing. Solid field definitions, explicit base-price rules, and fault tolerance and degradation are what keep the system stable as scale grows.
