A minimalist Quantitative Finance Dashboard built with Streamlit. It optimizes a portfolio of "Tech Giant" stocks using Hierarchical Risk Parity (HRP) and compares its performance against the S&P 500 (SPY).
- Quantitative Engine: Uses
PyPortfolioOptto perform HRP optimization. - Live Data: Fetches 2-year historical data using
yfinance(with caching). - Interactive Viz: Plotly charts for Asset Allocation, Cluster Dendrograms, and Cumulative Returns.
- Lightweight: Designed to run on minimal resources (e.g., free tier VPS with 1GB RAM).
- Python 3.10+
- Streamlit: UI Framework.
- yfinance: Market Data.
- PyPortfolioOpt: Portfolio Optimization.
- Plotly: Visualization.
Update your system and install Python/Pip.
sudo apt update && sudo apt upgrade -y
sudo apt install python3-pip python3-venv git -yA full-stack quantitative finance dashboard that constructs a Hierarchical Risk Parity (HRP) portfolio of top Tech stocks. It features a FastAPI backend for robust calculation and a React (Vite) frontend for a modern, responsive UI.
- HRP Optimization: Uses
PyPortfolioOptto build a risk-parity portfolio, robust to market noise. - Modern Interactive UI: React + Recharts + TailwindCSS.
- Automated Updates: Dedicated scheduler service keeps market data fresh daily (Rolling Window).
- Persistence: SQLite database (
data/portfolio.db) stores history and allocations. - Dockerized: One-command deployment for the entire stack.
- Frontend: React, TypeScript, Vite, TailwindCSS, Recharts.
- Backend: Python, FastAPI, Pandas, PyPortfolioOpt, yfinance.
- Database: SQLite (persisted via Docker volumes).
- DevOps: Docker & Docker Compose.
├── backend/ # FastAPI App & Worker
│ ├── main.py # API Entrypoint
│ ├── scheduler.py # Background Updater
│ ├── logic.py # Core Quant Logic
│ └── database.py # SQLite Handler
├── frontend/ # React App
│ ├── src/ # Components & Pages
│ └── Dockerfile # Multi-stage Nginx build
├── data/ # Persistent Data Storage
├── compose.yml # Full Stack Orchestration
└── analysis.ipynb # Research Notebook (Backtesting)
The application is designed to be deployed on a VPS using Docker.
- Docker & Docker Compose installed.
Clone the repository and launch the stack:
# 1. Clone
git clone https://github.com/achillekrtf/HRP_Optimizer.git
cd HRP_Optimizer
# 2. Launch
docker compose up -d --build- Dashboard:
http://<YOUR_VPS_IP>(Port 80) - API:
http://<YOUR_VPS_IP>:8000 - Scheduler: Runs automatically in the background (Updates daily at 22:00 UTC).
For a deep dive into the algorithm and a rolling backtest of the strategy:
- Open
analysis.ipynb(Jupyter Notebook). - Includes Dendrograms, Correlation Matrices, and Equity Curves comparing HRP vs SPY.
To run locally:
docker compose upOr run services individually (requires python 3.11 and node 18+).
- Data Update: Fetches the last 2 years of data for all tickers daily.
- Rebalancing: Checks if the last allocation is older than 7 days. If yes, it re-runs HRP optimization and saves the new weights.