A real-time oracle price feed system built for low-latency trading, analytics, and risk engines. It ingests live market prices, normalizes them, caches them for ultra-fast access, stores full history, and exposes clean APIs for downstream consumption.
Most trading systems fail at the price layer — slow updates, stale data, no confidence metrics, and zero observability.
I built this to design a production-grade pricing backbone focused on:
- Deterministic price normalization
- Sub-second freshness guarantees
- Historical traceability
- Health-based automation
- Zero-trust oracle design (on-chain ready)
This system is meant to be the single source of truth for mark price, funding, and liquidation logic.
- Live oracle price ingestion
- Confidence-aware normalization
- Ultra-low latency caching
- Time-series persistence
- Health & freshness checks
- Prometheus metrics for observability
- Designed on-chain oracle consensus (outlier rejection + median aggregation)
struct PriceResponse {
symbol: String,
source: String,
price: f64,
confidence: f64,
timestamp: i64,
}GET /oracle/price/{symbol} # Latest price (cache)
GET /oracle/prices # All active prices
GET /oracle/history/{symbol} # Historical data
GET /oracle/health # Data freshness
GET /metrics # Prometheus metricsCREATE TABLE price_history (
id SERIAL PRIMARY KEY,
symbol TEXT NOT NULL,
timestamp BIGINT NOT NULL,
price DOUBLE PRECISION NOT NULL,
confidence DOUBLE PRECISION NOT NULL,
source TEXT NOT NULL
);loop {
let raw = fetch_price().await?;
let price = raw.price * 10f64.powi(raw.expo);
let conf = raw.conf * 10f64.powi(raw.expo);
let payload = PriceResponse {
symbol: "BTC".into(),
source: "oracle".into(),
price,
confidence: conf,
timestamp: now(),
};
redis.set(key, to_json(&payload))?;
db.insert(payload)?;
}- Redis is used as the single-read source
- Database is used only for historical analysis
- No live system ever blocks on database reads
- Oracle fetch count
- API request volume
- Fetch latency histogram
All exposed via the /metrics endpoint.
- Multi-oracle validation
- Median-based aggregation
- Staleness & confidence filtering
- Outlier & manipulation rejection
This project is built as a real oracle infrastructure layer, not a demo application — designed for:
- Exchanges
- Perpetual futures
- Risk engines
- Quant research
- Backtesting systems