Case study
A gamified stock market simulator with live NSE prices, weekly competitions and an in-house ML assistant.
Chapters
~258
live-priced NSE stocks
₹1L
virtual cash per player
~9 ms
per assistant reply
95%
advice-refusal recall
What & why!
Tradexcel lets anyone learn how the stock market works without risking a rupee. Every player starts with ₹1,00,000 in virtual cash and can trade about 258 NSE-listed stocks at real market prices, streamed live while the market is open.
Around the trading engine sit the things that make people come back: weekly seasons that reset everyone to the same starting line, leaderboards, private leagues, 1v1 duels, quests that teach the basics, and Tex, an assistant that answers questions without a hosted LLM.
From a price tick to your screen!
Yahoo Finance
Quotes cached 12s while the market is open, 30 min when it's closed.
Price broadcast loop
One central 5-second loop fetches only symbols someone is watching and emits real changes.
Express + Prisma trading engine
Market, limit and stop-loss orders; open orders reserve the cash or shares they need.
PostgreSQL ledger
Every trade runs in one transaction; check constraints reject negative balances.
Socket.IO
Prices and a marketStatus event, so the UI shows “Market closed” instead of a fake “Live”.
Next.js dashboard
Charts, portfolio analytics against NIFTY 50, leaderboards and contests.
The fun parts!
All money uses Prisma.Decimal, never floats. Buys and sells lock the user's ledger, validate funds, write the holding and an immutable transaction row, and update the wallet in a single $transaction, with database check constraints as a last line of defence.
Instead of one fetch per viewer, a single broadcast loop fetches quotes once for every symbol anyone is watching and only emits real changes, while market-hours-aware caching keeps Yahoo Finance traffic low.
Tex runs guard rules first (it never gives investment advice), then a fine-tuned 22M-parameter MiniLM encoder with a 13-intent head and dense retrieval over 142 hand-written cards. Exported to ONNX and served inside Express, it fits on a 1 GB VM.
Weekly seasons snapshot and reset every wallet each Monday. Contests use their own entry, holding and transaction tables, so league trading never touches a player's main wallet.
Built with!
Next case study
Argus