Skip to main content

What you'll build

A script that compares Chainlink oracle prices with CEX spot prices from Kwery, measures the lag between on-chain updates and market price movements, and identifies periods of elevated latency.

Prerequisites

  • A Kwery API key (get one here)
  • Python 3.10+
  • requests, pandas, and matplotlib installed

Outline

  1. Fetch Chainlink oracle data
  2. Fetch corresponding CEX spot data
  3. Align timestamps and compute price deltas
  4. Measure update latency
  5. Visualize latency distribution

Step 1 — Fetch Chainlink oracle data

Pull the latest oracle price and update metadata using /v1/chainlink/{symbol}.

curl "https://kwery-api.com/v1/chainlink/ETH-USD?api-key=YOUR_KEY"

Section coming soon — will include Python code to poll and store oracle state over time.

Step 2 — Fetch CEX spot data

Pull the corresponding spot price from Binance using /v1/binance/spot/{symbol}/ticker as a reference price.

curl "https://kwery-api.com/v1/binance/spot/ETHUSDT/ticker?api-key=YOUR_KEY"

Section coming soon.

Step 3 — Align and compute deltas

Join the two time-series on the nearest timestamp and compute the price difference between the oracle value and the CEX reference.

Section coming soon.

Step 4 — Measure update latency

For each oracle update, find the timestamp when the CEX price first reached that level. The difference is the effective latency.

Section coming soon.

Step 5 — Visualize

Plot the latency distribution as a histogram and overlay latency over time to identify patterns (e.g., higher latency during volatile periods).

Section coming soon.


Next steps

  • Analyze latency across multiple Chainlink feeds using /v1/chainlink
  • Correlate latency spikes with liquidation events
  • Estimate theoretical MEV from oracle lag