This project implements a Variational Quantum Classifier (VQC) to predict financial market risk levels. By leveraging Quantum Machine Learning (QML), the pipeline transforms high-dimensional classical market data into quantum states to classify future realized volatility into four distinct tiers: Low, Medium, High, and Very High.
The repository is organized into a modular pipeline to ensure reproducibility:
- data/: Contains raw historical data and engineered feature sets.
- src/: Core logic including data preparation, the quantum circuit definition, and classical benchmarks.
- notebooks/: Experimental environment and final results visualization.
- run_experiments.py: The main execution script for training and evaluation.
Phase 1: Data Acquisition & Feature Engineering
- Source: Automated download of the top 100 tickers and S&P 500 benchmark via yfinance.
- Feature Set: Generated 701 technical features, including Log Returns, RSI, 20-day Volatility, and Market Beta.
- Preprocessing: Applied StandardScaler to normalize features for high-fidelity quantum embedding.
Phase 2: Quantum-Classical Bridge (PCA)
- To accommodate the constraints of Near-term Intermediate Scale Quantum (NISQ) devices, Principal Component Analysis (PCA) was used to reduce 701 features down to 4 principal components.
- These components are mapped to rotation angles
$[0, \pi]$ for quantum state preparation.
Phase 3: Quantum Model Architecture (VQC)
- Framework: Built using PennyLane.
- Embedding: AngleEmbedding maps classical data onto 4 qubits.
- Ansatz: StronglyEntanglingLayers are used to create complex quantum correlations between features.
- Optimization: A hybrid approach using the Adam Optimizer and Cross-Entropy Loss to adjust quantum gate weights.
The model was tested against the early 2025 market environment.
Key Findings:
- Risk Detection: The model demonstrated a high sensitivity to market turbulence, correctly identifying "High" risk regimes during 2025 volatility spikes.
- Performance: Achieved stable classification, though it showed a conservative bias (classifying some "Very High" instances as "High").
- Comparison: Outperformed random guessing by establishing a clear correlation with the benchmark realized volatility trend.
- Clone the repository:
git clone https://github.com/your-username/Quantum-Risk-Scoring.git- Install dependencies:
pip install -r .\requirements.txt- Run the full pipeline:
- Generate data:
python data_processing.py
python data_scaling_labeling.py- Train model:
python run_experiments.py- View Dashboard: Open results.ipynb