Case Study

LAZAZ Financial Terminal

A full-stack financial terminal and portfolio analyser for the Pakistan Stock Exchange. Built as a multi-tenant SaaS platform with microservices architecture, real-time market data via Server-Sent Events, and institutional-grade quantitative analytics.

The Problem

PSX investors track portfolios in spreadsheets. None of the available tools account for Pakistan's specific statutory friction costs — CDC charges, Capital Value Tax, Federal Excise Duty, brokerage commission structures — which means reported P&L is always wrong. There was no terminal that combined accurate cost accounting, live market data and quantitative analytics in one place for the Pakistani market.

Architecture

LAZAZ is not a monolith. It runs as four decoupled services, each responsible for a single domain. If the scraper goes down, the core app keeps serving cached data. If the quant engine is under load, it queues — it never blocks the main API.

Service Role Stack
Core API Client REST API, authentication, MongoDB persistence, portfolio math, SSE broadcast to connected browsers Node.js, Express, Mongoose, Redis
PSX Scraper Live price ingestion from PSX during market hours. Smart delta polling — only emits events when prices change. Automated index constituent mapping for all 18 PSX indices Python, FastAPI, Redis
LQME Quantitative engine: Pearson correlation matrices, marginal risk contributions, dynamic Beta, Sortino ratios, mean-variance optimisation with constrained MVO and sector filtering Python, FastAPI, pandas, numpy, scipy
LCM Communications microservice: transactional email dispatch, inbound email processing, three-queue BullMQ architecture for traffic isolation Node.js, BullMQ, React Email, Resend

Key Technical Decisions

SSE over WebSockets. Server-Sent Events for market data instead of WebSockets. One-directional server-to-client push is all that's needed for price ticks, and SSE reconnects automatically, works through corporate proxies and is simpler to scale behind a load balancer.

Smart delta polling. The scraper writes to Redis only when a price mathematically changes, not on every poll cycle. The core API reads from Redis at zero network latency. This eliminates redundant SSE pushes and keeps the client render loop quiet during low-volatility periods.

True-cost accounting. Every P&L figure includes the exact statutory friction costs for PSX trades: CDC custody charges, Capital Value Tax, Federal Excise Duty and tiered brokerage commissions. The numbers a user sees match what their broker's back-office system reports.

Backward adjustment engine. Corporate actions (stock splits, cash dividends) create artificial price gaps in historical data. LQME runs an autonomous backward adjustment processor that heals EOD arrays before they enter the covariance matrix for MVO calculations.

Screenshots

[ Portfolio dashboard ]
public/assets/img/lazaz-portfolio.png
[ Market data terminal ]
public/assets/img/lazaz-market.png
[ Quant analytics ]
public/assets/img/lazaz-quant.png
[ Sector heatmap ]
public/assets/img/lazaz-heatmap.png

Technical Scope

Metric Detail
Services 4 independent microservices (Node.js + Python)
Data pipeline Live PSX price ingestion, EOD historical backfill, company financials profiler
Quant features Correlation, Beta, Sortino, MVO with constrained optimisation, sector filtering
Infrastructure Docker Compose, Caddy reverse proxy, MongoDB, Redis, SSE
PSX indices mapped All 18 major indices (KSE-100, KSE-30, KMI-ALL, PSXDIV20, etc.)

Need something similar for your brokerage?

Let's talk