Skip to content

arnavnagzirkar/QuantSight

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

33 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“ˆ QuantSight - Intelligent Quantitative Research Platform

Transform market data into actionable insights with machine learning-powered stock analysis

QuantSight is a professional-grade quantitative research platform that combines the power of machine learning, statistical analysis, and modern web technologies to help traders, analysts, and researchers make data-driven investment decisions. Whether you're backtesting trading strategies, analyzing alpha factors, or exploring market sentiment, QuantSight provides the tools you need in an intuitive, elegant interface.

✨ Key Features

  • πŸ” Secure Authentication - Email/password and OAuth (Google, GitHub) with email verification
  • πŸ€– Walk-Forward ML Models - XGBoost predictions with proper out-of-sample validation
  • πŸ“Š Portfolio Backtesting - Multi-asset strategies with various allocation methods
  • πŸ” Factor Analysis - 60+ alpha factors with PCA diagnostics and IC analysis
  • πŸ“° Sentiment Analysis - NLP-powered news sentiment extraction
  • πŸ“ˆ Signal Diagnostics - Validate signal quality with decay analysis
  • ⚑ Modern UI - React + TypeScript frontend with dark mode
  • πŸ”§ RESTful API - Production-ready endpoints for automation

πŸš€ Quick Start

Prerequisites

  1. Supabase Account - Sign up at supabase.com
  2. Node.js 16+ and Python 3.9+

Local Development

The project is organized into two main directories:

  • frontend/ - React + TypeScript (Vite)
  • backend/ - Flask + Python

Terminal 1 - Backend:

cd backend
pip install -r requirements.txt
python main.py

Backend runs at http://localhost:5000

Terminal 2 - Frontend:

cd frontend
npm install
npm run dev

Frontend runs at http://localhost:5173

First-Time Setup

  1. Set up Supabase database:

    • Follow instructions in SUPABASE_SETUP.md
    • Run the SQL script to create the profiles table
    • Enable email authentication and OAuth providers
  2. Configure environment variables:

    frontend/.env:

    VITE_SUPABASE_URL=your_supabase_url
    VITE_SUPABASE_ANON_KEY=your_anon_key
    VITE_API_BASE_URL=http://localhost:5000

    backend/.env:

    NEWS_API_KEY=your_news_api_key
    PORT=5000
  3. Access the app:

    • Open http://localhost:5173
    • Create an account or sign in
    • Verify your email to access the platform

🌐 Deployment

This project is designed to deploy on:

  • Frontend: Vercel (free tier)
  • Backend: Render (free tier)

See DEPLOYMENT.md for complete deployment instructions.

Quick Deploy:

  1. Push to GitHub
  2. Connect Render to deploy backend
  3. Connect Vercel to deploy frontend
  4. Update environment variables on both platforms

πŸ” Authentication

QuantSight uses Supabase for secure authentication:

  • Email/Password: Traditional registration with email verification
  • OAuth: Sign in with Google or GitHub
  • Protected Routes: All app features require authentication
  • User Profiles: Stores user information and preferences

See SUPABASE_SETUP.md for detailed setup instructions.

πŸ—οΈ Tech Stack

Frontend: React 18 β€’ TypeScript β€’ Vite β€’ TailwindCSS β€’ Recharts β€’ Radix UI
Backend: Flask 3 β€’ Python 3.9+ β€’ Flask-CORS β€’ XGBoost β€’ pandas β€’ numpy
Auth: Supabase Authentication β€’ Row Level Security
Data: yfinance (market data) β€’ NewsAPI (sentiment) β€’ local file cache
Deployment: Vercel (Frontend) β€’ Render (Backend)

πŸ“ Project Structure

QuantSight/
β”œβ”€β”€ frontend/                  # React + TypeScript (β†’ Vercel)
β”‚   β”œβ”€β”€ components/           # React components
β”‚   β”œβ”€β”€ contexts/             # Auth context
β”‚   β”œβ”€β”€ services/             # API & Supabase client
β”‚   β”œβ”€β”€ App.tsx               # Main app
β”‚   β”œβ”€β”€ package.json          # Frontend deps
β”‚   └── vercel.json           # Deployment config
β”œβ”€β”€ backend/                   # Flask API (β†’ Render)
β”‚   β”œβ”€β”€ core/                 # Python backend logic
β”‚   β”‚   β”œβ”€β”€ adapter_api.py   # REST API endpoints
β”‚   β”‚   β”œβ”€β”€ model.py         # XGBoost ML models
β”‚   β”‚   β”œβ”€β”€ backtest.py      # Backtesting engine
β”‚   β”‚   └── research/        # Factor analysis, portfolios
β”‚   β”œβ”€β”€ main.py              # Flask app entry
β”‚   └── requirements.txt     # Python deps
β”œβ”€β”€ DEPLOYMENT.md            # Deployment guide
β”œβ”€β”€ SUPABASE_SETUP.md        # Supabase setup
└── README.md                # This file

See PROJECT_STRUCTURE.md for detailed structure information. β”‚ β”œβ”€β”€ adapter_api.py # REST API endpoints β”‚ β”œβ”€β”€ model.py # XGBoost ML models β”‚ β”œβ”€β”€ backtest.py # Backtesting engine β”‚ └── research/ # Factor analysis, portfolios, experiments β”œβ”€β”€ components/ # React frontend β”‚ β”œβ”€β”€ pages/ # 11 main pages (Dashboard, ModelLab, etc.) β”‚ β”œβ”€β”€ ui/ # Reusable UI components β”‚ └── charts/ # Data visualizations β”œβ”€β”€ data/ # Cached market data β”œβ”€β”€ models/ # Trained ML models └── dist/ # Production build


## πŸ”§ API Endpoints

### Main Endpoints
- `POST /api/models/train` - Train walk-forward XGBoost model
- `POST /api/portfolio/backtest` - Multi-asset portfolio backtest
- `POST /api/factors/compute` - Calculate 60+ alpha factors
- `POST /api/experiments/run` - Hyperparameter grid search
- `POST /api/signals/decay` - Signal decay analysis
- `POST /api/sentiment/analyze` - News sentiment extraction
- `GET /api/dashboard/overview` - Portfolio metrics
- `GET /api/tickers/:ticker` - Single-stock analysis
- `GET /api/risk/metrics` - Risk analytics

**Example Request:**
```bash
curl -X POST http://localhost:5000/api/models/train \
  -H "Content-Type: application/json" \
  -d '{"tickers": ["AAPL"], "startDate": "2015-01-01", "horizon": "1d"}'

πŸ’‘ Usage Example

Train a model and backtest a strategy:

# 1. Train XGBoost model
curl -X POST http://localhost:5000/api/models/train \
  -H "Content-Type: application/json" \
  -d '{"tickers": ["AAPL"], "startDate": "2015-01-01", "horizon": "1d"}'

# 2. Run portfolio backtest
curl -X POST http://localhost:5000/api/portfolio/backtest \
  -H "Content-Type: application/json" \
  -d '{
    "tickers": ["AAPL", "MSFT", "GOOGL"],
    "start": "2015-01-01",
    "signal": "prob_up_1d",
    "allocator": "equal_weight",
    "rebalance": "weekly"
  }'

Or use the web interface - navigate to Model Lab or Portfolio Backtest pages.

βš™οΈ Configuration

Create a .env file for API keys:

NEWS_API_KEY=your_news_api_key_here  # Get free key at newsapi.org
VITE_API_BASE_URL=http://localhost:5000

Customize factors in core/research/factors.py or model parameters in core/model.py.


πŸ› Troubleshooting

Issue Solution
ModuleNotFoundError Run pip install -r requirements.txt
Cannot find module 'react' Run npm install
Port 5000 in use Change port in main.py or kill process
"Failed to fetch" errors Ensure Flask backend is running
Slow model training Reduce date range or use fewer tickers

πŸš€ Deployment

Production build:

npm run build
pip install gunicorn
gunicorn -w 4 -b 0.0.0.0:5000 main:app

Security: Enable HTTPS, set FLASK_DEBUG=False, implement rate limiting and authentication.


🀝 Contributing

Contributions welcome! Fork the repo, create a feature branch, and submit a PR.
Follow PEP 8 for Python and ESLint rules for TypeScript.


πŸ“„ License

MIT License - see LICENSE file for details.


Built with ❀️ for quantitative researchers

QuantSight - See the market through a quantitative lens

About

Stocks ML

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors