Case study
₹ Rupee Engine
A modular equity-analysis and portfolio engine for Indian markets: CLI, API and dashboard.
- Status
- Active, since Feb 2026
- Coverage
- 1,300+ NSE stocks
- Algorithms
- 13 pluggable, registered
- Interfaces
- CLI · REST API · React dashboard
Problem
Judging a stock means combining fundamentals, price behaviour and news sentiment, and doing it consistently across a thousand names. Done by hand it is slow and impossible to audit.
Context
I wanted a system where every recommendation is the output of explicit, testable scoring logic, and where the logic itself can be measured against history instead of trusted on instinct.
Constraints
- Data arrives from several public sources with different shapes, cadences and failure modes.
- A full-universe run has to stay fast enough to re-run daily.
- Scoring logic changes often, so it has to be isolated and replaceable.
- Anything that changes a recommendation must be measurable after the fact.
Architecture
Data flows left to right. Select a stage to see what it does, why it exists, what it costs and how it fails.
Decisions
Why PostgreSQL only?
Backtesting, run history and analysis snapshots are relational and need transactions and migrations. Running one database everywhere removes a whole class of local-versus-production differences.
Why async ingestion?
The pipeline is I/O bound. Concurrent fetching with caching turns a slow serial crawl into something that can run daily.
Why a plugin registry for algorithms?
Each algorithm is one file behind one interface and is registered by decorator. Adding or retiring one never touches the rest, and the docs are checked against the registry so they cannot drift.
Why a CLI first?
A CLI is the fastest way to iterate on the engine. The API and dashboard were added once the engine's behaviour was stable enough to expose.
What was retired?
Algorithms that failed measurement were de-registered and moved to a historical record with the evidence for removal, instead of being deleted silently.
Trade-offs
- Operational simplicity (one database, one machine) over horizontal scale.
- Measurability over cleverness: every algorithm must be scoreable against history.
- A small, explicit public surface rather than exposing engine internals.
Implementation
- Python with FastAPI, asyncio and httpx for the engine and API; Alembic migrations for schema.
- Docker images for the API and for one-shot CLI jobs, so scheduling is just running a container.
- React dashboard with typed data-fetching, charts, portfolio builder and backtest views.
Outcome
- One pipeline scores 1,300+ NSE stocks with 13 registered algorithms.
- Backtest and walk-forward calibration make algorithm changes measurable.
- CLI, API and dashboard share a single engine.
Lessons
- Making things measurable early changes what you are willing to build.
- Schema ownership by migrations (nothing implicit) prevents a lot of silent breakage.
- A registry plus a check that docs match code keeps a growing system honest.