QuantLab Backend is a modular, structured API built with FastAPI. It handles quantitative strategy design, statistical analysis, backtesting, and real-time paper trading simulations.
This repository is optimized for deployment on Render, while the frontend repository (QuantLab_Frontend) is designed to be deployed on Vercel.
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).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.main.py: FastAPI entrypoint hosting the REST API endpoints.run_pipeline.py: CLI pipeline to run strategies locally.
-
Install dependencies:
pip install -r requirements.txt
-
Run the API locally:
uvicorn main:app --reload --port 8000
The interactive Swagger documentation will be available at
http://127.0.0.1:8000/docs. -
Run a local backtest CLI:
python run_pipeline.py
You can deploy this API to Render either as a native Python Web Service or using the included Dockerfile.
- Sign in to Render and click New > Web Service.
- Connect this repository (
QuantLab_Backend). - Set the following configuration details:
- Runtime:
Python 3(or choose Python matching your workspace) - Build Command:
pip install -r requirements.txt - Start Command:
uvicorn main:app --host 0.0.0.0 --port $PORT
- Runtime:
- Add the following Environment Variables (under the "Env" tab) if you want custom paths:
DATA_CACHE_DIR:dataPAPER_TRADING_LOG:paper_trading.log
- Create a New > Web Service on Render.
- Connect this repository and set:
- Runtime:
Docker
- Runtime:
- Render will automatically build the container using the root Dockerfile and expose the port.
When deploying your frontend QuantLab_Frontend to Vercel:
- Copy your Backend URL from the Render dashboard (e.g.,
https://quantlab-backend.onrender.com). - In your frontend repository, configure the environment variable or configuration file to point to this URL.
- For example, if using React/Vite, set:
VITE_API_BASE_URL=https://quantlab-backend.onrender.com
- Ensure the frontend fetch calls point to
${VITE_API_BASE_URL}/api/backtestand other endpoints.
- For example, if using React/Vite, set:
- Note: The backend has CORS enabled for all origins (
*) by default in main.py, making it ready to receive requests from your Vercel URL.