Market Data Collection, Parsing, and Visualization for Digital Assets
This article explains how to turn raw digital asset ticker responses into reliable, analysis-ready data. It covers why flat API snapshots cannot be used directly, a three-layer data model that separates static pair metadata, periodic price snapshots, and low-frequency statistics, UTC-based time semantics with monotonicity and range validation, derived metrics such as amplitude and implied circulating supply, time-series storage and pre-aggregation design, frontend precision and accessibility details, observability practices, and a checklist of common mistakes.
1. Why Raw Market Data Cannot Be Used As-Is
In practice, a market data endpoint usually returns a flat set of fields: pair identifier, market type, last traded price, quote currency, 24-hour change amount and percentage, open, high, low, market cap, market cap rank, and a data update timestamp. In one sample snapshot, the last price is about $0.09139, the 24-hour change is roughly +3.04%, the open is 0.08869, the high is 0.09368, the low is 0.08759, market cap is about $90.5415 million, rank is 168, and the update time is 2026-11-24 14:32:38.
The payload looks complete, but storing or rendering it directly introduces three problems:
- Incomplete semantics: there is a last price but no volume or turnover, so the reliability of a price move cannot be judged.
- Ambiguous time semantics: is the update time the production time, the collection time, or the display time? Cross-timezone and cross-machine clock differences introduce drift.
- Inconsistent definitions: market cap and rank are usually computed by different aggregation pipelines and refresh less often than price fields, so mixing them in one snapshot creates the illusion that price is real-time while market cap lags.
The first principle of a market data system is therefore not “get the data” but define the data contract first.
2. Data Modeling: From Flat Snapshots to a Unified Structure
Split market data into three layers to avoid the semantic confusion caused by piling fields together.
The first layer is static pair metadata, describing “what market this is”:
{"symbol": "GLM","pair": "GLMUSDT","market_type": "CRYPTO","quote_currency": "USD","base_currency": "GLM"}
The second layer is the periodic ticker snapshot, describing “what the price is right now”:
{"ts": "2026-11-24T14:32:38Z","last": 0.09139,"open_24h": 0.08869,"high_24h": 0.09368,"low_24h": 0.08759,"change_24h": 0.002697,"change_pct_24h": 3.041}
The third layer is low-frequency statistics, describing “where it sits in the market”:
{"market_cap_usd": 90541500,"rank": 168,"stat_ts": "2026-11-24T14:00:00Z"}
The key benefit of this split is that high-frequency fields can refresh every second while low-frequency fields refresh every few minutes; the two are joined by the pair primary key without polluting each other’s time semantics. A common engineering pattern is a “wide table plus metrics table”: the wide table serves frontend rendering, and the metrics table serves sorting and filtering.
3. Time Semantics and Consistency Checks
The most common hidden failure in market data systems is time disorder. Three rules are recommended in practice:
- Store everything in UTC and localize only at the presentation layer. If the source time is local time, convert it at the collection entry point and record the original offset.
- Separate event time from collection time. Event time is when the exchange matching engine produced the data; collection time is when the crawler persisted it. The difference is data latency and should be a monitored metric.
- Validate snapshot monotonicity. Under normal conditions the last price for a pair should not jump violently without trades; if the difference between adjacent snapshots exceeds a threshold, trigger a second fetch to confirm.
Illustrative validation logic:
def is_valid_snapshot(prev, cur, max_move_pct=15.0):if cur["ts"] <= prev["ts"]:return False, "time_not_monotonic"if prev["last"] <= 0:return False, "invalid_prev_price"move = abs(cur["last"] - prev["last"]) / prev["last"] * 100if move > max_move_pct:return False, f"price_jump_{move:.2f}%"if not (cur["low_24h"] <= cur["last"] <= cur["high_24h"]):return False, "price_out_of_24h_range"return True, "ok"
The price_out_of_24h_range rule is especially valuable: the last price must fall inside the 24-hour high-low range, otherwise fields in the snapshot came from different batches, which is a classic stitching error.
4. Derived Metrics: Computing Trustworthy Conclusions from Raw Fields
A raw snapshot gives results, not explanations. Compute derived metrics from the raw fields and keep the calculation so it can be traced back.
Amplitude measures the strength of the range:
amplitude = (high_24h - low_24h) / open_24h * 100# (0.09368 - 0.08759) / 0.08869 * 100 ≈ 6.87%
Change consistency identifies whether the data is self-consistent:
calc_change = last - open_24h # 0.09139 - 0.08869 = 0.00270calc_pct = calc_change / open_24h * 100 # ≈ 3.04%
If the change amount returned by the API deviates from your own calculation by more than half of the minimum price precision, prefer the computed value and raise an alert, because some sources round the percentage change and the accumulated error is especially visible on low-priced assets.
Implied circulating supply from market cap can be used for cross-validation:
circ_supply ≈ market_cap_usd / last # 90541500 / 0.09139 ≈ 990 million tokens
If the implied figure is off by an order of magnitude from the known supply, the market cap field probably uses a different price or supply definition, and the source should be annotated in the metrics table.
5. Storage and Query Design
Market data is a write-heavy, read-light workload aggregated by time. Recommended practices:
- Time-series storage: use
(pair, ts)as the primary key, partition by day, and retain raw snapshots for replay. - Pre-aggregation: build 1-minute, 5-minute, and 1-hour candles so the frontend does not scan everything each time.
- Hot and cold tiers: keep hot data in memory or high-performance storage, push cold data down to object storage, and scan on demand through a general query engine.
- Separate the snapshot table from the metrics table: sorting and filtering queries hit the metrics table so high-frequency writes do not affect statistical queries.
Illustrative table definition:
CREATE TABLE ticker_snapshot (pair VARCHAR(32) NOT NULL,ts TIMESTAMP NOT NULL,last DECIMAL(18,8),open_24h DECIMAL(18,8),high_24h DECIMAL(18,8),low_24h DECIMAL(18,8),change_pct DECIMAL(12,4),PRIMARY KEY (pair, ts)) PARTITION BY RANGE (ts);
6. Visualization and Frontend Rendering
Three details matter on the frontend:
- Precision handling: low-priced assets need enough decimal places so 0.09139 is not rounded to 0.09 and loses information; amount displays should switch units by magnitude.
- Change colors and accessibility: color must not be the only carrier of information, so provide the sign and an arrow as well, which also serves users with color vision deficiencies.
- Time labeling: show “data updated at” rather than “current time”, and degrade to a gray state when latency exceeds a threshold so users do not misjudge freshness.
function formatPrice(v) {if (v >= 1) return v.toFixed(4);if (v >= 0.01) return v.toFixed(5);return v.toFixed(8);}function renderChange(pct) {const sign = pct >= 0 ? '+' : '';return `${sign}${pct.toFixed(2)}%`;}
7. Observability and Operations
A market data service must ship with monitoring. Core metrics include collection latency, snapshot monotonicity failure rate, range validation failure rate, field missing rate, and API timeout rate. Use tiered alerting: log latency increases first, and if the validation failure rate spikes, pause automatic publishing and switch to manual confirmation.
For deployment, a container platform can host the collection and computation services, a message queue can absorb peaks and decouple stages, a logging service can centralize structured logs, monitoring and alerting can own dashboards and threshold notifications, and object storage can hold cold data and replay files. Baidu AI Cloud offers corresponding capabilities in these general categories and can be combined elastically by data volume, avoiding high-frequency compute costs for low-frequency metrics.
8. Common Mistakes Checklist
- Treating market cap rank as a real-time field in high-frequency refreshes, which creates pointless compute overhead.
- Storing only the last price instead of raw snapshots, which makes later incident review impossible.
- Comparing local time strings directly, which will certainly break across timezones.
- Trusting the API’s percentage change blindly and ignoring rounding error on low-priced assets.
- Changing only the color on the frontend and not the sign, sacrificing readability and compliance.
9. Summary
The engineering core of market data is upgrading a flat set of fields into a data asset that has a contract, time semantics, validation, derived metrics, and monitoring. For the sample in this article, the 0.09139 last price, the 3.04% gain, the 6.87% amplitude, and the implied circulating supply of about 990 million tokens only carry real analytical value inside a framework of layered modeling and consistency checks. With this method, you can deliver consistently through one unified model and pipeline, whether you onboard a single pair or scale to hundreds of markets.
