Skip to content

aaf091/QuantLab

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

QuantLab

A Bloomberg Terminal-style quantitative finance platform. Full-stack — React/TypeScript frontend with a dark terminal aesthetic, Flask REST API backend with a 350k+ instrument SQLite database, and 11 live quant analysis modules.


Screenshots

Bloomberg chessboard layout: full-width live chart, scrolling world indices ticker tape, live news feed, watchlist panel, company info (4 tabs: Overview / Supply Chain / Analyst / News), sector heatmap, order flow, correlation matrix, earnings history, economic calendar, and 6 draggable floating panels.


Project Structure

QuantLab/
├── backend/          Flask API + SQLite DB
│   ├── app/
│   │   ├── database/     SQLAlchemy ORM (11 tables, 350k+ instruments)
│   │   ├── routes/       14 API blueprints
│   │   ├── services/     Business logic + yfinance data layer
│   │   └── utils/        Response helpers, validators
│   ├── setup_db.py       One-time DB seed script
│   ├── wsgi.py
│   └── README.md         Full backend API reference ← start here
│
└── frontend/         React + TypeScript + Vite + Tailwind
    └── src/
        ├── api/          Typed API client (client.ts)
        ├── components/
        │   ├── layout/   TerminalHome, WatchlistManager
        │   ├── common/   Modal, Panel, DraggablePanel
        │   └── modules/  11 analysis module components
        └── index.css     Bloomberg dark theme + ticker-tape animation

Quick Start

1. Backend

cd backend
python -m venv .venv
source .venv/bin/activate          # Windows: .venv\\Scripts\\activate
pip install -r requirements.txt

# Seed the instrument database (run once — downloads 350k tickers)
python setup_db.py
# Or for instant start with 250 built-in tickers:
python setup_db.py --quick

python wsgi.py
# → http://localhost:3000

2. Frontend

cd frontend
npm install
npm run dev
# → http://localhost:5173

Features

Terminal UI

Component Description
World indices ticker tape 22 global indices scrolling in real time — S&P 500, DAX, Nikkei, Nifty 50, Hang Seng, KOSPI, Gold, BTC, Crude Oil, and more
Live chart Interactive OHLCV candlestick chart (lightweight-charts) with 1D / 5D / 1M / 3M / 6M / 1Y / 2Y / 5Y periods
Watchlist Persistent watchlist loaded from SQLite on boot. Live price + change every 60s
Company info 4-tab panel: Overview (financials + description), Supply Chain (suppliers/customers), Analyst Ratings, News
Sector heatmap Performance heatmap across 11 GICS sectors
Order flow Buy/sell volume analysis
Correlation matrix Pairwise return correlations for watchlist tickers
Earnings history EPS estimate vs. actual with beat/miss
Economic calendar Upcoming macro events
6 draggable panels Any panel can be expanded into a free-floating resizable window

Watchlist Manager

Feature Description
Search Full-text search across 350k+ instruments with live results
Sector browser Browse by sector with junk-filtered labels
Country browser Browse by country with city + ISO code display
Asset type Filter by Equity / ETF / Crypto / Fund / Index
Presets Curated groups: FAANG, Semiconductors, S&P sectors, Crypto, etc.
Persistence Watchlist saved to SQLite via REST API

Quant Analysis Modules

Module Description
Predictor ML next-day price forecast (scikit-learn ensemble)
Optimizer Markowitz mean-variance efficient frontier + max Sharpe allocation
Options Pricer Monte Carlo + Black-Scholes pricing with Greeks
Pairs Trading Cointegration test + z-score entry/exit backtest
Value at Risk Historical VaR + Monte Carlo VaR + CVaR
Screener Multi-factor filtered stock screening
Signals RSI, MACD, Bollinger Bands, moving average signal generation
Backtester Strategy backtesting with equity curve + metrics
Experiment Tracker Save, compare, and manage backtest runs

Tech Stack

Backend

  • Flask 3.0 — REST API with CORS
  • SQLAlchemy — ORM with SQLite (WAL mode for concurrent reads). PostgreSQL-ready via DATABASE_URL env var
  • FinanceDatabase — 350k+ global instruments across Equity, ETF, Crypto, Fund, Index asset classes
  • yfinance 1.2+ — Live market data. Uses fast_info (chart endpoint) as fallback when quoteSummary returns 401
  • PyPortfolioOpt — Portfolio optimisation
  • statsmodels — Cointegration tests for pairs trading
  • scikit-learn — ML models for price prediction

Frontend

  • React 18 + TypeScript — Component architecture
  • Vite — Dev server on port 5173
  • Tailwind CSS — Utility-first styling
  • TanStack Query — Server state management with automatic refetch intervals
  • lightweight-charts — TradingView-grade candlestick charts
  • Lucide React — Icons

Currency Support

Prices and market cap figures are displayed in the instrument's native currency. Supported: USD, EUR, GBP, JPY, INR, CNY, HKD, CAD, AUD, CHF, KRW, BRL, and 20+ others. Currency is sourced from yfinance's financialCurrency or fast_info.currency field.


Data & Caching

All market data is cached in-memory on the backend with TTLs:

Data Cache duration
Company info (full) 10 minutes
Company info (degraded / Yahoo 401) 90 seconds
Live prices 60 seconds
World indices 60 seconds
Market news 2 minutes
Chart OHLCV 5 minutes

A CLEAR CACHE button in the bottom-right corner of the terminal wipes all cached data and forces a fresh fetch from Yahoo Finance. Individual tickers can also be refreshed via POST /api/terminal/company/<ticker>/refresh.


Environment Variables (Backend)

Variable Default Description
PORT 3000 API server port
FLASK_ENV development development or production
ALLOWED_ORIGINS http://localhost:5173,... CORS origins (comma-separated)
AV_API_KEY (optional) Alpha Vantage key for richer news sentiment
DATABASE_URL sqlite:///quantlab.db DB URL — swap for PostgreSQL in production

Database Setup Options

python setup_db.py             # Full — 350k+ tickers from FinanceDatabase
python setup_db.py --quick     # Fast — 250 built-in tickers (no internet needed)
python setup_db.py --force     # Wipe instruments and re-seed
python setup_db.py --status    # Show stats without seeding

The seeder uses INSERT OR IGNORE to handle duplicate (ticker, exchange) pairs across asset class datasets. Each asset class is seeded in its own SQLAlchemy session so a failure in one doesn't poison the others.


API Reference

See backend/README.md for the full endpoint reference.

About

Unified Quantitative Finance Platform

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors