Back to ShipLog
🛠️ Engine RoomFebruary 15, 20267 min read

How Our Consensus Pricing Engine Works

Three data sources, anchor-based outlier detection, and a weighted median — all computed in under 200ms.

By TradeStance Engineering
pricingarchitectureDecimal.js

The Problem

No single commodity price source is reliable for all products in all countries. Comtrade data is 3–6 months lagged. Scraper prices depend on a website staying online. Hardware pricing APIs cover electronics but not agricultural goods.

The Solution

Our consensus engine queries Comtrade average unit values, Apify web scrapers, and Nexar hardware APIs in parallel. Results go through anchor-based outlier detection: any price more than 2.5 standard deviations from the median is flagged and downweighted. The final consensus is a weighted median computed with Decimal.js at 20-digit precision.

Financial math demands precision. We use Decimal.js with ROUND_HALF_UP across every calculation in the platform — no floating-point surprises.

The Benefit

Users see a single, trustworthy price with a confidence score. The consensus result is cached in price_history with a 24-hour TTL, feeding both the price ticker and the landed-cost calculator.

Related Help GuideUnderstanding Price Confidence Scores
Open Guide

Was this update useful?

#pricing#architecture#Decimal.js