Pricing Global Large-Model Assets and Building a Real-Time Market Data System Architecture
This article breaks down the engineering behind a trustworthy real-time market data system, using the anatomy of a single quote snapshot as the starting point. It explains how to validate market data through structural, relational, and time-series checks; how to organize an ingestion, cleaning, storage, compute, serving, and alerting architecture around hot, warm, and cold data tiers; and how to feed structured market data into AI applications such as natural-language queries, anomaly attribution, and risk alerts. It also covers precision and rounding, timezone and trading calendar handling, latency labeling, caching consistency, observability, and capacity planning, with practical code examples for validation, money formatting, and tool calls. The key takeaway is that reliable, traceable, and explainable external data is the foundation for market-data-driven intelligent applications.
1. Background: What a Single Market Data Record Can Tell Us
Before discussing implementation, it helps to understand the fields in a raw record. A typical market data snapshot usually contains the instrument name, ticker symbol, exchange, quote currency, last price, price change, percent change, and quote timestamp. These fields look simple, but together they form the minimum usable unit of information in a financial data pipeline, and they are the input for every downstream calculation, display, and risk-control function.
It is important to be clear about what such a record represents. It reflects the trading outcome of a secondary-market instrument at a given moment, and it is not equivalent to a quantitative evaluation of model capability or technical metrics. Treating security prices directly as a measure of technical quality is one of the most common analytical mistakes. The correct approach is to treat market data as an external signal of market expectations and risk appetite, model it separately from internal metrics such as technical evaluations and benchmark tests, and then blend the two with weights at the decision layer.
From a data-quality perspective, this record highlights at least three categories of problems that need to be handled in engineering:
- Time semantics: Quote timestamps often differ from local receive times. You need to distinguish “quote event time” from “system ingestion time,” otherwise cross-timezone and cross-session scenarios will produce misalignment.
- Numerical consistency: There is a deterministic mathematical relationship between price change, percent change, and last price, which can serve as a hook for data validation.
- State completeness: Under non-trading hours, trading halts, and call auctions, the last price may stay unchanged while the percent change still refreshes, so trading state must be modeled explicitly.
2. Field-Level Parsing and Validation Rules
In a real data pipeline, no unvalidated market data should enter the business layer directly. It is recommended to run three layers of validation in the following order.
Layer 1: Structural validation. Confirm that required fields are present and correctly typed, and that the symbol/exchange combination matches the expected format. For example, a ticker symbol usually carries an exchange prefix, and the market field and currency field must corroborate each other; otherwise, it suggests the data sources have been mixed up.
Layer 2: Relational validation. Use the identity relationships among prices for cross-validation:
price change = last price - previous closepercent change% = price change / previous close * 100
From this, you can back out the previous close and compare it with an independently obtained previous close. If the deviation exceeds an allowable threshold (for example, one tick determined by the minimum quote unit), the record should be flagged as suspicious rather than dropped or used directly.
Layer 3: Time-series validation. Check whether timestamps are monotonically increasing, and detect duplicate pushes, out-of-order arrivals, and long periods without updates. A common strategy is to maintain a per-symbol watermark of the latest state, accept only records with newer timestamps, and trigger a backfill or alert when a silence period exceeds a threshold.
from dataclasses import dataclass@dataclassclass QuoteSnapshot:symbol: str # instrument symbolmarket: str # exchangecurrency: str # quote currencylast: float # last pricechange: float # price changechange_pct: float # percent change (as a percentage)ts: int # quote timestamp (milliseconds)def validate(q: QuoteSnapshot, prev_close: float, tick: float = 0.01) -> bool:if q.last <= 0 or prev_close <= 0:return Falseif abs((q.last - prev_close) - q.change) > tick:return Falseexpect_pct = q.change / prev_close * 100return abs(expect_pct - q.change_pct) <= tick
The value of this code is not in its complexity but in turning “data trustworthiness” into executable assertions. For any market-data-driven business, the first step should be to make sure bad data cannot penetrate downstream.
3. From Static Records to a Layered Real-Time Market Data Architecture
A single record is only a snapshot. What has real engineering value is a system that can continuously output trustworthy snapshots. A practical layered design usually includes the following layers.
Ingestion layer. Responsible for establishing connections to external data sources, handling protocol parsing, heartbeat keep-alive, reconnection, and multi-source redundancy. A key design point is “select the best among multiple sources”: different sources may have subtle differences on the same instrument, so you should assign weights by source credibility, latency, and historical accuracy, and retain the source identifier for traceability.
Cleansing and normalization layer. Performs the three layers of validation described above, unit unification (such as percent vs. decimal, currency precision), field alignment, and deduplication. Precision must be handled carefully here: price fields should use fixed-point or high-precision decimal types, and binary floating point should be avoided for direct currency arithmetic, otherwise tail discrepancies will appear during accumulation and display.
from decimal import Decimal, ROUND_HALF_UPdef to_money(v: str, scale: str = "0.01") -> Decimal:return Decimal(v).quantize(Decimal(scale), rounding=ROUND_HALF_UP)
Storage layer. It is recommended to organize data in three tiers: “hot, warm, and cold.” Hot data goes in an in-memory KV store to serve real-time queries and push; warm data is stored in a time-series database as minute-level and hour-level aggregated series to support candlestick charts and trend analysis; cold data is archived as raw messages in object storage for backtesting, auditing, and model training. The partition key is usually “symbol + time bucket” to balance point lookups and range scans.
Compute layer. Responsible for derived metrics, including average price, amplitude, volume-weighted indicators, volatility, and relative-strength-type indicators. This layer should be a stateless unified batch/stream computation, making horizontal scaling and recomputation easier.
Serving layer. Exposes three capabilities externally: latest-snapshot query, historical-series query, and change subscription push. For the push side, it is recommended to use a publish/subscribe message queue with a long-connection gateway, sharding subscriptions by symbol to avoid head-of-line blocking caused by a single connection carrying too many symbols.
Display and alerting layer. Provides dashboards and threshold alerts for business users, and programmable interfaces for developers. Alert rules should support four trigger conditions—“price out of bounds, percent change out of bounds, data silence, and rising validation failure rate”—and route by severity level.
4. Typical Scenario: How Market Data Enters AI Applications
When market data is combined with large-model capabilities, the three most common ways to put it into practice are:
- Intelligent Q&A: Users ask in natural language about the current state, range performance, or reasons for anomalies of an instrument. The system uses tool calls to convert natural language into structured queries, then organizes the results into a readable answer.
- Anomaly attribution assistance: Correlate market data series with public disclosures, industry indices, and sector performance, and output candidate explanatory factors for human review.
- Risk alerts: Automatically generate risk lists and remediation suggestions based on volatility, percent-change thresholds, and position concentration.
Whichever approach is used, two bottom lines must be upheld: first, do not use generative-model output directly as an investment basis; all numerical values should be based on structured query results, and the model is only responsible for explaining and organizing. Second, retain a traceable chain; every number cited in an answer should be traceable back to a specific market data record and query time.
A minimal tool-call example is as follows:
def get_snapshot(symbol: str) -> dict:"""Return the latest snapshot for the given symbol; all values come from the structured market data store."""row = hot_store.get(f"quote:{symbol}")if not row:return {"symbol": symbol, "status": "no_data"}return {"symbol": row["symbol"],"market": row["market"],"currency": row["currency"],"last": row["last"],"change": row["change"],"change_pct": row["change_pct"],"as_of": row["ts"], # explicit data timestamp to avoid misreading as real-time"trade_status": row["status"] # trading/closed/halted}
5. Engineering Practices and Common Pitfalls
1. Timezones and trading calendars. Overseas markets involve multiple trading sessions and holidays, so you cannot simply use local time to judge “whether the market is closed.” You should build in a trading calendar, convert timestamps to the exchange’s timezone before display, and clearly label the timezone and data latency in the interface.
2. Latency labeling cannot be omitted. Market data often has push or aggregation latency. The system must carry the data timestamp in the response structure, and the display layer should show explicit wording such as “data delayed by approximately X minutes” to avoid users mistaking a historical snapshot for a real-time price.
3. Unified precision and rounding strategy. The entire chain should use the same set of rounding rules, and final rounding should be done on the server side. Prohibit the frontend from recalculating and displaying again, otherwise a trust problem of “the same number being inconsistent across pages” will occur.
4. Caching and consistency. Hot instruments will be queried at high frequency. A short-TTL cache can be introduced to reduce backend pressure, but the cache key must include the data timestamp, or the real timestamp must be filled back into the response, to prevent stale data from being treated as new data.
5. Rate limiting and quotas. Access to external data sources should have quotas and backoff retries to avoid instantaneous retry storms. The same applies to external services, which also need rate limiting by caller to prevent individual clients from dragging down overall availability.
6. Compliance and explainability. When displaying financial information, disclaimers, data-source labeling, and usage-scope limitations should be built in, and model-generated content should be compliance-checked to avoid inducing statements.
6. Observability and Capacity Planning
A market data system is a typical “traffic spike + strong time-series” workload. Observability should cover four aspects: data freshness (lag of the latest record), validation failure rate (grouped by source and symbol), end-to-end push latency (from ingestion to client rendering), and interface error rate plus rate-limit trigger counts. The first two directly reflect data trustworthiness and are the core metrics most worth building first.
For capacity planning, it is recommended to estimate ingress bandwidth as “number of symbols × maximum updates per second × average message size,” and estimate push-side throughput as “number of subscription relationships × number of changes per second,” with redundancy reserved at two to three times the peak. On the storage side, tiering is based on the retention policy: hot data is retained for hours to days, warm data is retained for years to support long-cycle analysis, and cold data is archived long-term but can be restored on demand within minutes.
7. Conclusion
A seemingly simple market data record is backed by a complete engineering system of data collection, quality validation, time-series modeling, layered storage, real-time push, and compliance display. For developers and enterprise users, what truly needs to be mastered is not any single price figure, but how to keep external data trustworthy, traceable, and explainable when it enters the business system. If validation is moved forward, timestamps are made explicit, precision is unified, and latency is clearly labeled, market-data-driven intelligent applications will have a reliable foundation. If you need a faster path to implementation, you can first consider adopting standard cloud capabilities such as general-purpose stream computing, time-series storage, message queues, and monitoring/alerting to build the skeleton, and focus your effort on data-quality rules and business semantic modeling—this is the hard-to-replace core competency.
