Real-Time Stock Market Data Architecture: Collecting and Processing Live Quotes
Market data is a classic "high-throughput, low-latency, strongly time-ordered" data stream, and building a platform around it is a systems design problem rather than a simple integration task. This article walks through a vendor-agnostic architecture for a real-time stock quote platform: how to model quotes as idempotent time-series data with fixed-precision numbers, how to ingest multiple upstream feeds while absorbing opening-bell traffic spikes, how to use message queue partitioning and stream processing for ordering, deduplication and minute-bar aggregation, how to split hot and cold storage to balance cost against query latency, and how to expose quotes through stateless, horizontally scalable services backed by monitoring, data quality checks and disaster recovery design.
1. Introduction: The Core Challenges of a Real-Time Market Data System
In financial IT, market data is a classic “high-throughput, low-latency, strongly time-ordered” data stream. Take a single US-listed instrument as an example: one complete quote snapshot normally contains the name, ticker symbol, market, quote currency, last price, open price, previous close, intraday high, intraday low, and the update timestamp:
{"name": "Sample Instrument","symbol": "TICKER","market": "US","currency": "USD","price": 97.17,"open": 111.50,"prev_close": 83.00,"high": 115.10,"low": 92.72,"update_time": "2026-11-20T08:38:48"}
Those few fields look trivial, but behind them sits a full engineering stack. An upstream feed may push hundreds of thousands of updates per second, quotes must be cleaned, aggregated, and distributed within milliseconds, and the pipeline still has to guarantee that no data is lost, duplicated, or delivered out of order. This article abstracts a general architecture that is independent of any specific vendor.
2. Designing the Market Data Model
A sound data model is the foundation of a reliable market data system. The design should focus on the following points:
- Primary key and idempotency: Use “market + symbol” as the logical primary key, and compare
update_timeto decide which record is newer. This makes repeated pushes idempotent and prevents the same snapshot from being counted multiple times in statistics. - Time-series semantics: Prices are time-series data, so in addition to keeping the latest snapshot, you should retain the historical sequence for candlestick (K-line) aggregation, backtesting, and similar use cases.
- Numeric precision: Financial values must never be stored directly as floating-point numbers. Use fixed-point representations (for example, integers denominated in the smallest currency unit, such as cents) or a high-precision
Decimaltype to avoid accumulated rounding errors. - Layered modeling: Separate the “real-time snapshot layer” (latest price), the “minute aggregation layer” (minute OHLC), and the “daily aggregation layer” (open, high, low, close). Each layer serves a different query pattern.
A typical table definition looks like this:
CREATE TABLE quote_snapshot (symbol VARCHAR(16) NOT NULL,market VARCHAR(8) NOT NULL,price DECIMAL(18,4),open_price DECIMAL(18,4),prev_close DECIMAL(18,4),day_high DECIMAL(18,4),day_low DECIMAL(18,4),update_time TIMESTAMP,PRIMARY KEY (market, symbol));
3. Ingestion and Collection Layer
The ingestion layer connects to external market data sources and acts as the entry point of the system. In practice, collection is usually decoupled from processing:
- Multiple sources and redundancy: To improve availability, subscribe to several upstream feeds at the same time and use consistency checks to discard anomalies such as price jumps or missing fields. If one feed slows down or drops out, traffic can fail over to a backup source automatically.
- Backpressure and peak shaving: Volume spikes sharply the moment the market opens, and handling that surge directly in the ingestion layer easily leads to a backlog. A more robust approach is to write raw data into a message queue quickly and let downstream consumers drain it at their own pace, which shaves the peak.
- Protocol parsing and normalization: Field naming, encoding, and units differ from source to source, so the ingestion layer must normalize heterogeneous payloads into one internal data model and hide upstream differences from the rest of the system.
4. Message Queue and Stream Processing
The message queue is the buffer between ingestion and computation, and the hub of the whole system:
- Partitioning and parallelism: Partition by a hash of the ticker symbol. Quotes for the same instrument then always land in the same partition, which preserves time ordering naturally while still allowing consumer parallelism to scale out horizontally.
- Consumer groups and scaling: With a consumer group, multiple consumers process different partitions in parallel, and overall throughput grows close to linearly with the number of instances.
- Stream processing: Real-time cleaning, deduplication, minute K-line aggregation, and change-percentage calculation are all done inside the stream processing engine. The change percentage, for instance, is computed as:
Change (%) = (price - prev_close) / prev_close × 100%
Plugging in the sample data: (97.17 - 83.00) / 83.00 × 100% ≈ +17.07%, meaning the instrument is up roughly 17% for the day relative to the previous close.
5. Storage Design
Different access patterns call for different storage media:
- Hot data (latest snapshot): Write to an in-memory database or a high-concurrency key-value store to support millisecond-level real-time lookups.
- Warm/cold data (historical series): Append to distributed columnar storage or object storage, combining low cost with the ability to scan large volumes for analytics and backtesting.
- Hot-cold separation: A scheduled job archives historical data to low-cost storage and keeps only recent hot data on high-performance media, balancing cost against performance.
6. Serving and Presentation Layer
The serving layer exposes data to end users and business systems, typically deployed on a container platform with stateless horizontal scaling:
def get_quote(symbol: str, market: str) -> dict:key = f"{market}:{symbol}"snapshot = kv_store.get(key) # hot storage hitif snapshot is None:snapshot = cold_store.query(key) # fall back to cold storagereturn format_response(snapshot) # standardized response format
For high-frequency delivery, a long-lived connection or subscription-based push mechanism can stream quote increments to the frontend in real time. For bulk retrieval, provide paginated query APIs and add caching to reduce pressure on the database.
7. Monitoring, Alerting, and High Availability
Market data systems demand very high stability, so a complete observability stack is required:
- Core metric monitoring: Track ingestion delay, message queue backlog, consumption rate, API P99 latency, and data missing rate, and wire them into unified monitoring and alerting.
- Data quality checks: Set price-deviation thresholds and notify operations as soon as an abnormal jump occurs or a feed stops updating for an extended period.
- Logging and tracing: Collect runtime logs centrally through a logging service, and combine them with distributed tracing to quickly locate slow queries or consumption bottlenecks.
- Disaster recovery: Redundant multi-source ingestion, stateless and replayable computation, and multi-replica storage together keep the system serving through a single point of failure.
8. Summary
At its core, a mature real-time market data system is the coordination of six stages: collection, buffering, computation, storage, serving, and observability. The key technical points come down to this: build on a sound time-series data model, use a message queue for peak shaving and decoupling, perform real-time aggregation with stream processing, balance cost and performance with tiered hot/cold storage, and rely on thorough monitoring and alerting to keep the system stable. All of these design choices are decoupled from any particular vendor. Whether you build the platform in-house or lean on general-purpose capabilities such as object storage, message queues, container platforms, stream processing, and monitoring and alerting from a cloud provider, this blueprint is enough to deliver a low-latency, high-reliability market data platform.
