Case study
D-TradeX
Automated trading suite for Indian markets
An automated trading suite connecting five Indian brokers through a single normalised adapter layer. A canonical Greeks engine replaces broker-supplied risk numbers; a LightGBM classifier outputs directional signals; and Redis Streams deliver ticks to the UI in under 200 ms.
- Next.js
- FastAPI
- Python
- Redis Streams
- LightGBM
- PostgreSQL
The problem
Retail algorithmic trading in India is split across incompatible broker APIs, inconsistent risk numbers and platforms that hide where their data comes from.
Fragmented broker APIs
Each broker authenticates, streams ticks and places orders differently.
Inconsistent Greeks
Brokers calculate option risk numbers in different ways, so the same position can look different on each.
Mock data
Many platforms mix simulated data into what looks like a live feed.
How it is built
Market data
Broker WebSocket feeds, historical data from Kite Connect, and licensed feeds.
Adapter layer
One adapter per broker, a token subscription manager, and a polling fallback.
Streaming
Redis Streams with a consumer group per strategy, so ingestion is decoupled from delivery.
Analytics
A Greeks engine (Black-76 and Black-Scholes-Merton), a LightGBM signal classifier and Celery scheduled jobs.
Persistence
PostgreSQL for accounts and orders, MongoDB as a short-lived tick cache, Redis for sessions and streams.
API
FastAPI with JWT in HttpOnly cookies and refresh rotation.
Frontend
Next.js App Router with Auth.js sign-in through Google and GitHub.
What it does
Five brokers, one interface
Zerodha, Upstox, Angel One, Nuvama and Dhan behind a single adapter pattern.
Live options chain
Greeks refreshed as ticks arrive.
Canonical Greeks
One calculation for every broker, used instead of broker-supplied risk numbers.
Signal classifier
A LightGBM model trained on Nifty 50 price and options-flow features.
Backtesting and paper trading
Strategies run against historical or licensed data, and paper trades use live prices and are labelled as such.
Risk controls
Daily loss limits, position caps and automatic strategy pauses, enforced in the API.
Token automation
Broker tokens refresh on a schedule before the market opens.
Per-user isolation
Role-based access and separate broker credentials for every user.
The hard parts
Two databases, one identity
A single user ID is carried into both PostgreSQL and MongoDB, with a lookup service across them.
The 9,000-instrument cap
Zerodha limits one connection to 9,000 instrument tokens. A live counter sends the overflow to REST polling so no instrument is silently dropped.
No mock data
All market data comes from live broker connections or licensed feeds, and the architecture enforces it instead of relying on convention.
A settings parsing bug
A comma-separated CORS list was read as one string by the configuration library. Switching to a JSON array fixed it.
Decisions we made
- Canonical Greeks over broker-native ones; broker data is used only for prices and open interest.
- MongoDB is a time-limited cache, never the source of truth.
- Redis Streams instead of direct WebSocket fan-out, so a slow consumer cannot stall ingestion.
- LightGBM instead of deep learning, because labelled data is limited.
- Celery with Beat instead of an in-process scheduler, so scheduled jobs survive restarts.
Need something built like this?
Tell us what you are trying to build and we will reply with how we would approach it.