Harness the power of PCA and Eigen decomposition for smarter investing.
Welcome to Eigen Portfolio, a data science project that uses Principal Component Analysis (PCA) and eigen decomposition to create an optimized portfolio of assets. This project explores dimensionality reduction in finance and how eigenvectors and eigenvalues can guide investment strategies.
The goal is to analyze historical price data of multiple stocks and extract the principal components that explain the most variance. These components are then used to allocate weights to the assets, forming an optimal portfolio.
Key concepts include:
- Covariance matrices
- Eigenvalues & eigenvectors
- PCA in financial markets
- Portfolio variance & risk
Eigen-Portfolio/
├── Eigen Portfolio.ipynb # Main Jupyter notebook
├── README.md # You're reading it!
└── data/ # Historical stock data (if applicable)- ✅ Data fetching using
yfinance - ✅ Log returns computation
- ✅ Covariance matrix and its decomposition
- ✅ PCA-based portfolio construction
- ✅ Eigen portfolio vs equal-weighted portfolio comparison
- ✅ Visualization of risk-return tradeoff
- Scree plot of explained variance
- Portfolio weights based on eigenvectors
- Comparative performance graphs
-
Clone the repo:
git clone [https://github.com/your-username/eigen-portfolio.git](https://github.com/your-username/eigen-portfolio.git) cd eigen-portfolio -
Install dependencies:
pip install -r requirements.txt
-
Run the notebook:
Open
Eigen Portfolio.ipynbin Jupyter Notebook or VSCode and run all cells.
numpypandasmatplotlibyfinanceseaborn
Install all using:
pip install numpy pandas matplotlib yfinance seabornMade with ❤️ by Shretima