Skip to content

PalashKulkarni/quantumtrade

Repository files navigation

 β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ  β–ˆβ–ˆ    β–ˆβ–ˆ  β–ˆβ–ˆβ–ˆβ–ˆβ–ˆ  β–ˆβ–ˆβ–ˆ    β–ˆβ–ˆ β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ β–ˆβ–ˆ    β–ˆβ–ˆ β–ˆβ–ˆβ–ˆ    β–ˆβ–ˆβ–ˆ
β–ˆβ–ˆ    β–ˆβ–ˆ β–ˆβ–ˆ    β–ˆβ–ˆ β–ˆβ–ˆ   β–ˆβ–ˆ β–ˆβ–ˆβ–ˆβ–ˆ   β–ˆβ–ˆ    β–ˆβ–ˆ    β–ˆβ–ˆ    β–ˆβ–ˆ β–ˆβ–ˆβ–ˆβ–ˆ  β–ˆβ–ˆβ–ˆβ–ˆ
β–ˆβ–ˆ    β–ˆβ–ˆ β–ˆβ–ˆ    β–ˆβ–ˆ β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ β–ˆβ–ˆ β–ˆβ–ˆ  β–ˆβ–ˆ    β–ˆβ–ˆ    β–ˆβ–ˆ    β–ˆβ–ˆ β–ˆβ–ˆ β–ˆβ–ˆβ–ˆβ–ˆ β–ˆβ–ˆ
β–ˆβ–ˆ β–„β–„ β–ˆβ–ˆ β–ˆβ–ˆ    β–ˆβ–ˆ β–ˆβ–ˆ   β–ˆβ–ˆ β–ˆβ–ˆ  β–ˆβ–ˆ β–ˆβ–ˆ    β–ˆβ–ˆ    β–ˆβ–ˆ    β–ˆβ–ˆ β–ˆβ–ˆ  β–ˆβ–ˆ  β–ˆβ–ˆ
 β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ   β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ  β–ˆβ–ˆ   β–ˆβ–ˆ β–ˆβ–ˆ   β–ˆβ–ˆβ–ˆβ–ˆ    β–ˆβ–ˆ     β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ  β–ˆβ–ˆ      β–ˆβ–ˆ
    β–€β–€                         TRADE  AI

An AI-native institutional trading operating system.
Multi-agent decisioning. Explainable AI. Real-time risk intelligence.
Built for the terminal. Runs in your browser.

FastAPI Next.js Python TypeScript License


πŸš€ Live Demo

Service Link
πŸ–₯️ Frontend Dashboard https://quantumtrade2.vercel.app/
βš™οΈ Backend API https://quantumtrade-backend.onrender.com
πŸ“„ Swagger Docs https://quantumtrade-backend.onrender.com/docs

πŸ’‘ Fully deployed version of QuantumTrade AI with live market simulation + AI copilot enabled.


What is this?

QuantumTrade AI is a full-stack, production-grade trading intelligence platform that brings institutional-level tooling to individual investors. It combines a six-agent AI ensemble, a live market data pipeline, a quantitative backtesting engine, a portfolio risk suite, and a conversational AI copilot β€” all running locally, instantly, with zero setup friction.

No paid APIs. No login walls. No bloat. Just open it and trade smarter.


Features

πŸ€– Six-Agent AI Ensemble

The core of QuantumTrade is a MetaAgent β€” a weighted ensemble of six independent sub-agents that each analyse the market from a different lens and vote on a final decision.

Agent Strategy
Momentum Trend direction + MACD crossover signal
Mean Reversion RSI extremes + Bollinger Band position
Volatility ATR-filtered regime suppression
Sentiment Tape-implied sentiment from price action
Risk Manager Hard veto on high-volatility regimes
Allocation Regime-aware position sizing overlay

Every decision comes with a confidence score, per-agent vote breakdown, feature importance weights, market regime classification, and a plain-English explanation.

πŸ“ˆ Live Market Data

Real-time OHLCV data via Yahoo Finance with automatic NSE/BSE routing. Type RELIANCE, TCS, INFY β€” no .NS suffix needed. The data pipeline resolves 50+ Nifty tickers automatically, with a synthetic fallback that keeps the app functional even when Yahoo rate-limits.

Supported: NSE Β· BSE Β· NASDAQ Β· NYSE Β· Crypto Β· Forex

πŸ’¬ AI Copilot β€” Streaming Chat

A conversational AI analyst built into the dashboard. Ask it anything about your portfolio, market conditions, or investment strategy and get back institutional-quality, streaming responses word by word β€” complete with animated tool-call badges showing what it's "doing" behind the scenes.

The copilot understands nine analytical domains:

  • Portfolio drop analysis & attribution
  • Market crash / stress scenario modelling
  • Sharpe ratio improvement pathways
  • Sector exposure & concentration risk
  • Full risk breakdown (beta, VaR, drawdown, Sortino)
  • Stock purchase decision framework
  • Diversification quality analysis
  • Volatility regime assessment
  • Portfolio optimisation (Mean-Variance, Black-Litterman concepts)

πŸ”¬ Strategy Backtester

Replay the AI meta-agent's decisions against real historical data. Configure symbol, timeframe, initial capital (up to $1M), commission, and slippage β€” then get back:

  • Equity curve β€” area chart with reference line at initial capital
  • Drawdown chart β€” peak-to-trough loss over time
  • Monthly returns heatmap β€” 24-month bar chart, green/red coloured
  • Full trade log β€” every BUY/SELL with quantity, price, and fee
  • Risk metrics β€” Sharpe, Sortino, CAGR, alpha, beta, profit factor, win rate, max drawdown

🏦 Portfolio Risk Engine

Upload your holdings via CSV or add them manually. The engine computes:

  • Unrealised P&L with live prices fetched concurrently across all tickers
  • Portfolio beta vs SPY benchmark
  • Sharpe ratio on actual historical return distribution
  • Sector & asset class exposure breakdown
  • Correlation matrix across all holdings
  • Four stress tests β€” 2008 crash, COVID shock, rate hike cycle, tech selloff
  • Health score β€” composite rating with specific, actionable recommendations

All 48 tickers fetch in parallel. Cold cache takes ~4–6s. Warm cache (subsequent loads): instant.

πŸ“° News Intelligence

Holdings-linked news from Yahoo Finance RSS, sentiment-scored in real time. Every article gets a keyword sentiment score (positive / negative / neutral) displayed as a micro-bar. The panel shows a live sentiment distribution bar across your entire portfolio and filters by sentiment category.

πŸ”” Price Alerts

Set above/below threshold alerts on any supported symbol. Alerts are stored per-session and can be evaluated on-demand. Triggered alerts appear as a dismissible banner with the actual price vs target.

πŸ“Š Explainability Panel

The dashboard surfaces the AI's reasoning at every level β€” confidence pulse (animated bar), feature importance chart, regime classification, per-agent vote percentages, and a full plain-English explanation for every decision. Nothing is a black box.

πŸ–₯️ Live Terminal Feed

A scrolling event feed on the dashboard shows every market event, agent decision, and system message in real time β€” styled like a Bloomberg terminal, updating on every 12-second polling cycle.

πŸ“„ Paper Trading Engine

An in-memory paper trading engine tracks position entries, exits, realised P&L, cash balance, and total equity against simulated fills with commission and slippage applied. The WebSocket endpoint pushes live portfolio snapshots to the frontend.


Tech Stack

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Frontend                                                        β”‚
β”‚  Next.js 15 Β· TypeScript Β· Tailwind CSS Β· Framer Motion         β”‚
β”‚  Recharts Β· Zustand Β· cmdk Β· React Markdown                      β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  Backend                                                         β”‚
β”‚  FastAPI Β· SQLAlchemy 2 (async) Β· SQLite / PostgreSQL            β”‚
β”‚  Alembic Β· Pydantic v2 Β· Uvicorn                                 β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  AI & Quant Engine                                               β”‚
β”‚  Custom 6-agent MetaAgent (NumPy + Pandas, no ML frameworks)     β”‚
β”‚  Mock AI copilot (45+ institutional responses, SSE streaming)    β”‚
β”‚  Backtesting engine with Sharpe, Sortino, alpha, beta, CAGR      β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  Data                                                            β”‚
β”‚  Yahoo Finance (yfinance) Β· NSE/BSE auto-routing                 β”‚
β”‚  In-memory cache (4h TTL for daily bars)                         β”‚
β”‚  Synthetic fallback provider (always available)                  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Getting Started

No API keys. No environment variables. No Docker. Just Python and Node.

Backend

cd quantumtrade

# Create and activate virtual environment
python -m venv venv
source venv/bin/activate        # macOS / Linux
venv\Scripts\Activate.ps1       # Windows PowerShell

# Install dependencies
pip install -r backend/requirements.txt

# Start
python -m uvicorn backend.app.main:app --reload --port 8000

β†’ API live at http://localhost:8000
β†’ Interactive docs at http://localhost:8000/docs β€” no auth token needed

Frontend

cd quantumtrade/frontend
npm install
npm run dev

β†’ Dashboard at http://localhost:3000 β€” opens directly, no login

Sample Portfolio

A sample CSV with 48 real holdings (35 NSE + 13 US stocks) is included:

quantumtrade/sample-portfolio.csv

Open the dashboard β†’ Manage Portfolio β†’ drag and drop the file.


Project Structure

quantumtrade/
β”‚
β”œβ”€β”€ backend/app/
β”‚   β”œβ”€β”€ main.py                     Entry point, CORS, startup seeding
β”‚   β”œβ”€β”€ models.py                   SQLAlchemy ORM models
β”‚   β”œβ”€β”€ middleware/auth.py          Demo mode β€” auto demo user, no JWT
β”‚   β”œβ”€β”€ routers/
β”‚   β”‚   β”œβ”€β”€ agents.py               POST /api/decisions
β”‚   β”‚   β”œβ”€β”€ backtests.py            POST /api/backtests/run
β”‚   β”‚   β”œβ”€β”€ chat.py                 POST /api/chat/stream (SSE)
β”‚   β”‚   β”œβ”€β”€ portfolio.py            GET/POST /api/portfolio
β”‚   β”‚   β”œβ”€β”€ alerts.py               CRUD /api/alerts
β”‚   β”‚   β”œβ”€β”€ news.py                 GET /api/news
β”‚   β”‚   β”œβ”€β”€ market_data.py          GET /api/market-data/{symbol}
β”‚   β”‚   └── websocket.py            WS /ws/live
β”‚   └── services/
β”‚       β”œβ”€β”€ mock_ai.py              AI copilot β€” 9 categories, 45+ responses
β”‚       β”œβ”€β”€ portfolio_analytics.py  Beta, Sharpe, stress tests, correlations
β”‚       └── news.py                 Yahoo RSS + keyword sentiment scoring
β”‚
β”œβ”€β”€ ml_engine/
β”‚   └── meta_agent.py               6-agent ensemble decision engine
β”‚
β”œβ”€β”€ data_pipeline/
β”‚   β”œβ”€β”€ providers.py                NSE + Yahoo + Synthetic fallback chain
β”‚   └── ingestion.py                In-memory cached MarketDataService
β”‚
β”œβ”€β”€ backtesting/
β”‚   β”œβ”€β”€ engine.py                   Historical strategy simulation
β”‚   └── metrics.py                  Sharpe, Sortino, CAGR, alpha, beta
β”‚
β”œβ”€β”€ paper_trading/
β”‚   └── engine.py                   In-memory paper trading with P&L
β”‚
β”œβ”€β”€ frontend/
β”‚   β”œβ”€β”€ app/
β”‚   β”‚   β”œβ”€β”€ page.tsx                Main dashboard
β”‚   β”‚   β”œβ”€β”€ backtests/page.tsx      Strategy backtesting lab
β”‚   β”‚   └── alerts/page.tsx         Price alert management
β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”œβ”€β”€ ai-chat-panel.tsx       Streaming AI chat (SSE consumer)
β”‚   β”‚   β”œβ”€β”€ news-intelligence.tsx   News feed with sentiment scoring
β”‚   β”‚   β”œβ”€β”€ portfolio-manager.tsx   Holdings CRUD + CSV import
β”‚   β”‚   β”œβ”€β”€ agent-orchestration.tsx Agent vote visualisation
β”‚   β”‚   └── explainability-panel.tsx Decision breakdown + feature importance
β”‚   β”œβ”€β”€ lib/
β”‚   β”‚   β”œβ”€β”€ quant-engine.ts         Client-side quant analysis
β”‚   β”‚   β”œβ”€β”€ markets.ts              Symbol universe + currency conversion
β”‚   β”‚   └── config.ts               API base URL (env var aware)
β”‚   └── store/
β”‚       └── use-dashboard-store.ts  Zustand global state
β”‚
β”œβ”€β”€ sample-portfolio.csv            48 real holdings ready to import
└── alembic/                        DB migrations (production use)

API Reference

All endpoints are available at http://localhost:8000/docs with no authentication required.

Method Endpoint Description
GET /health Service health check
GET /api/portfolio Get current holdings
POST /api/portfolio/holdings Save holdings + return analytics
GET /api/portfolio/analytics Full risk analytics
POST /api/decisions Run AI meta-agent on a symbol
POST /api/chat/stream SSE streaming AI chat
GET /api/chat/history Load conversation history
POST /api/backtests/run Run historical backtest
GET /api/news Sentiment-scored news feed
GET/POST/DELETE /api/alerts Price alert management
POST /api/alerts/check Evaluate alerts against live prices
WS /ws/live?symbol=X Live market tick WebSocket

Deployment

Frontend β†’ Vercel

# Set in Vercel dashboard:
NEXT_PUBLIC_API_URL=https://your-backend.onrender.com

vercel --prod

Backend β†’ Render

# Render auto-detects nixpacks.toml
# Set environment variable:
ALLOWED_ORIGINS=https://your-app.vercel.app

# Start command (already in render.json):
uvicorn backend.app.main:app --host 0.0.0.0 --port $PORT

Optional environment variables for production:

DATABASE_URL=postgresql+asyncpg://...   # Upgrade from SQLite
ANTHROPIC_API_KEY=sk-ant-...            # Enable real Claude AI
ALLOWED_ORIGINS=https://yourapp.com     # Restrict CORS

Contributor


Palash Kulkarni
Author & Maintainer

Built with obsessive attention to detail by Palash Kulkarni

No AI was harmed in the making of this AI trading platform.

About

AI-powered algorithmic trading platform

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors