Case study · Metals trading and price watch

240x faster API

I made a metals trading and price-watch API 240x faster, from 6 seconds to 25ms, by taking price work out of the request path.

  • 240xfaster API, from 6s to 25ms
  • < 400msprice freshness
  • 50,000price ticks a second ingested
  • < 1.5 sto deliver an alert

Challenge

Every request fetched and computed prices from several exchange and broker feeds live, taking 6 seconds.

What I built

Streaming feed ingestion, precomputed price snapshots, a time-series store, a cache layer, WebSocket price alerts, LLM market summaries, and cost-prediction models for metal and gas markets.

Stack

Python (Django REST Framework), Go for the feed ingestors, Kafka, TimescaleDB on PostgreSQL, Redis, AWS ECS and Lambda, OpenAI.

System design

The public API reads only Redistickslatest snapshothistoryWebSocketsEach exchange and brokerfeedGo ingestorsKafkaa topic per instrumentAggregatorreference pricesRedisTimescaleDBcontinuous aggregatesPublic APIDjango REST FrameworkAlert engineusers' thresholds in memoryAlertsNightly jobLLM market summary,OpenAI

Go ingestors subscribe to each exchange and broker feed and publish ticks to a Kafka topic per instrument. An aggregator computes reference prices and writes the latest snapshot to Redis and history to TimescaleDB, whose continuous aggregates keep open, high, low and close bars current. The public API reads only Redis, which is where the 6s to 25ms gain comes from. An alert engine reads the same stream, checks users' thresholds held in memory and pushes alerts over WebSockets. A nightly job builds the LLM market summary from TimescaleDB aggregates.

Results

  • 6s to 25ms (240x)
  • price freshness under 400ms
  • alerts delivered in under 1.5s
  • 50,000 price ticks a second ingested
Back to Work & Research