< return to vault
DETAILS·PROJ.ATS / 03·operational
> source: github.com/advay-sinha/Algo-Trade-Simulator> live: algo-trade-simulator-lovat.vercel.app

Algo Trade Simulator

Lets strategies face real market data without letting simulated capital, lookahead, or free trades pretend to be real.

project overview

Algo Trade Simulator grew from a trading simulator into a modular quant research platform for developing, testing and monitoring strategies without risking real capital. It backtests SMA crossover, time-series momentum and mean-reversion rules; compares cross-sectional momentum and volatility-managed trend following against an equal-weight universe baseline on frozen Nifty 100 snapshots; trains directional classifiers and a walk-forward stock-ranking pilot; and runs forward paper-trading simulations marked to live quotes. A research copilot runs the same platform tools as the forms, and the whole stack is deployed live on Vercel (paper trading only).

architecture

The pipeline runs in stages, each persisting what the next one reads. Market data: yfinance → raw Yahoo HTTP → clearly flagged offline values, cached in Upstash Redis and tagged live, offline or synthetic on every value. Features: daily bars become returns, lags, volatility, RSI, MACD, Bollinger and moving-average features with direction, return-bucket or regime labels and a time-ordered train / embargo / test split — features see only the past, labels only the future, enforced by tests. Strategies and models: rule strategies, universe strategies, logistic / random-forest / gradient-boosting classifiers, and walk-forward ridge and gradient-boosted ranking models refitted only on matured, purged labels. Execution: a backtester with next-open fills, commission and slippage, and a portfolio engine with INR accounting, whole-share fills, volume caps and dated Indian statutory charges, reading content-addressed price snapshots so every run replays exactly. Analytics and registry: Sharpe, Sortino, CAGR, drawdown, beta and alpha against the benchmark over identical days, stored with each run in MongoDB (models in GridFS) and optionally logged to MLflow. Simulations: forward paper trading on the same strategies, marked to live quotes and compared with buy-and-hold and the index. The copilot is a LangChain tool-calling agent over Groq, Cerebras, OpenRouter, Hugging Face, Ollama or OpenAI, grounded in RAG over the user's notes (Hugging Face embeddings, FinBERT sentiment). Deployment is one Vercel project: the Vite build as static files and FastAPI as a Python function under /api in the Mumbai region, next to MongoDB Atlas.

YAHOO · CACHEFEATURESSTRATEGIES · MLBACKTEST · RISKPAPER SIMleakage-free splits · mlflow · copilot

constraints

  • no lookahead — signals computed at bar t execute at bar t+1, features never see future data, splits are time-ordered with an embargo
  • cost realism — every fill pays commission and slippage; research runs apply a dated schedule of STT, exchange, SEBI, stamp duty, GST and DP charges
  • reproducibility — research runs read a frozen, content-addressed snapshot so the same inputs always give the same result
  • market data dependency — the platform sits downstream of public sources it does not control, and Yahoo rate-limits cloud IPs
  • serverless envelope — the deployed Python bundle must stay within Vercel's 500 MB function limit, with training kept out of web requests

tradeoffs

  • a tool-calling copilot over free-text parsing: the agent runs the same validated tools as the forms, capped at five calls per message, with prompt-injection guardrails fencing untrusted data off from instructions
  • hosted Hugging Face inference over in-process models: sentiment and embeddings cost nothing in the deployed bundle, at the price of cold-start latency
  • frozen snapshots over live data for research: exact replay and auditability, at the cost of survivorship bias from today's index members — labelled wherever results appear
  • strict database mode when hosted over a silent in-memory fallback: a 503 is better than data that appears to save and vanishes on restart

failure notes

  • the ML ranking pilot shows no reliable skill on the Nifty 100 snapshot (mean rank IC about zero, intervals spanning zero) — it stays labelled a research result rather than being promoted
  • neither universe strategy beats the equal-weight baseline on a risk-adjusted basis; each is rerun with all charges doubled and the result is reported, not tuned away
  • when Yahoo is unreachable, quotes and charts fall back to flagged offline or synthetic values that the interface badges — never passed off as real prices
  • metrics that can't be computed honestly come back as null with a reason, never NaN

infrastructure

fastapi + pydantic · react + vite + typescript · mongodb atlas (motor) · scikit-learn · pandas · mlflow · langchain tool-calling copilot · vercel · upstash redis

engineering reasoning

Each stage is a separate service with its own contract — market data, features, strategies, execution, analytics, simulations, copilot — so a failure in one does not block the rest, and every result can be traced back to its data snapshot, configuration and model. Quant-research discipline (no lookahead, time-series validation, cost realism, honest universes) is enforced by golden-baseline and leakage tests rather than left to convention.

future work

  • > point-in-time universes to remove survivorship bias
  • > shorting, leverage and position scaling beyond long/flat
  • > an optional read-only broker sync for portfolio analysis
< return to vaultEND OF RECORD · PROJ.ATS / 03