QuantLab is a modular, structured environment for the design, statistical analysis, backtesting, and real-time simulation (Paper Trading) of quantitative trading strategies.
This project serves as a professional portfolio demonstrating the application of mathematical rigor and software engineering principles to quantitative finance.
Live Deployment: https://quantlab-liard-delta.vercel.app/
The QuantLab platform consists of:
- Frontend Dashboard: A responsive, modern UI built with HTML5, CSS3, and Vanilla JavaScript, deployed live on Vercel.
- FastAPI Backend Server: Exposes REST APIs and WebSockets for real-time market data streaming and simulation control, designed to run in Docker containerized environments.
- Quantitative Engine: Contains modules for backtesting, custom strategy implementations, data pipeline (fetching from Yahoo Finance API), risk metrics, and live/paper trading.
01_backtesting_engine/: Event-driven simulation engine with full portfolio accounting, commissions, and slippage.02_strategies/: Concrete strategy implementations (Mean Reversion, Momentum, Pairs Trading, Multi-Factor), documenting mathematical hypotheses and practical limitations.03_data_pipeline/: Robust data download (yfinance), cleaning, and feature engineering pipeline.04_research_notebooks/: Statistical tests (ADF, Cointegration) and pre-development experimentation.05_risk_metrics/: Risk-adjusted performance metrics (Sharpe, Sortino, Drawdown, position sizing).06_live_or_paper/: Real-time simulated execution module with structured logging system.
- Hypothesis: Prices revert to their historical mean after extreme deviations.
- Key Limitation: Sensitive to strong trend regimes (prolonged bull/bear markets) where price "walks the band", generating accumulated losses.
- Hypothesis: Price direction persists after confirmation of fast/slow EMA crossovers.
- Key Limitation: Generates consecutive false signals (whipsaws) in sideways-ranging markets.
- Hypothesis: Two cointegrated assets maintain a stationary spread over the long term.
- Key Limitation: Loss of structural cointegration due to changes in corporate fundamentals.
Using the unified execution script run_pipeline.py to simulate the Bollinger Mean Reversion strategy on asset KO:
- Total Return: ~9.52% (relative to initial capital of $100,000.00).
- Sharpe Ratio: ~0.45.
- Max Drawdown: ~12.30%.
- Slippage & Commissions: Incorporated (0.1% commission and 0.05% slippage per trade).
This project is fully containerized with Docker to easily run both the frontend and backend in unified environments.
Make sure you have Docker and Docker Compose installed on your machine.
To spin up the entire application (FastAPI backend + Nginx-served frontend), run the following command in the root directory:
docker compose up --build- Frontend Dashboard: Access at http://localhost:3000
- FastAPI Documentation (Swagger UI): Access at http://localhost:8000/docs
If you prefer to run the components manually, install the dependencies and follow these steps:
pip install -r requirements.txt
python run_pipeline.py-
Start the FastAPI backend:
cd backend uvicorn main:app --reload --port 8000 -
Open the frontend:
Open
index.htmldirectly in your browser, or serve it with any static file server:# Using Python's built-in server (from the project root) python -m http.server 3000Then navigate to http://localhost:3000.
- Parameter Optimization: Add Bayesian optimization in the research step to calibrate thresholds and rolling windows while avoiding overfitting.
- MetaTrader 5 / Interactive Brokers API Integration: Connect the
06_live_or_papermodule to real brokers for live order transmission and execution, or paper trading on demo accounts. - Machine Learning Module: Implement a simple XGBoost classifier in the factors section to filter false signals based on market regime detection.
