Twelve Data’s Composite Currency Feed brings together live prices from a wide network of global banks, institutional liquidity providers, and digital asset venues to create a single, reliable stream for both forex and crypto pairs. For each instrument, the midpoint price from source i is calculated as the arithmetic mean of its best bid and ask prices:
where B and A are the latest bid and ask quotes reported by source i. If a direct midpoint is not available, it is derived from raw order book data or reconstructed from trade and quote messages.
The composite midpoint M represents the aggregated market consensus and is computed as a weighted average across all sources:
Each source’s weight w is determined by its reliability, liquidity contribution, and latency, ensuring that high-quality, low-latency sources have a greater influence on the final composite value.
Reliability
Reliability R quantifies the historical stability of a source’s pricing relative to a reference feed — a benchmark constructed from a broad and statistically stable subset of sources. The reference feed serves as a neutral baseline against which deviations are measured. Reliability is defined as the inverse of the rolling variance of each source’s deviation from the reference midpoint over a defined window of hours:
Sources that show minimal divergence from the consensus — i.e., smaller σ — are assigned higher reliability scores.
Liquidity
Liquidity contribution L captures the market depth or transactional strength of each source. It can be estimated using reported trading volume, quoted size at the top of the order book, or the frequency of quote updates. A source providing deeper liquidity or tighter spreads contributes more to the price discovery process and thus receives a higher weight.
Latency
Latency T represents the time delay between the occurrence of a market event and the delivery of data to the aggregator. Lower latency implies fresher information and better responsiveness to real-time market changes. To reflect this, latency enters the weighting function inversely: sources with shorter delays contribute proportionally more to the composite.
The final weight for each source is computed as a normalized composite score:
where α, β, and γ are tunable coefficients adjusted to reflect current market dynamics and the characteristics of the data source.
Outlier filtering
To prevent anomalous data from distorting the aggregate, individual midpoints are excluded if they deviate excessively from the median:
where σ is the standard deviation of midpoints and k is a configurable constant.
Summary
The result is a high-accuracy, low-latency currency feed that powers applications ranging from real-time charting and analytics to algorithmic trading and risk modeling.
Twelve Data’s composite methodology provides the transparency and resilience of institutional-grade aggregation, unified under one API for both forex and crypto markets.