This project builds a quantitative commodity portfolio allocation pipeline from raw price data to final portfolio weights.
It combines data import, risk analysis, time-series forecasting, and Black-Litterman portfolio construction in a single workflow.
The prices.py script is designed to automatically build and maintain a
daily commodity price dataset using Yahoo Finance.
- If no existing dataset is found, the script downloads approximately five years of historical daily close prices for all listed assets.
- The data are stored locally in a
prices.parquetfile.
- If a dataset already exists, the script identifies the last available trading date.
- It then downloads only the missing daily close prices, starting from the day following the last recorded date.
- New observations are appended to the existing dataset, avoiding duplicates.
- To ensure data consistency, the script updates prices only up to the previous trading day (T-1).
- This avoids the inclusion of partial or intraday data for the current day, which may be incomplete depending on market closing times.
- Assets with unavailable or missing data are automatically skipped and reported via warning messages.
- The update process continues without interruption for all remaining assets.
This approach ensures a robust, reproducible, and continuously updated dataset suitable for quantitative analysis and portfolio construction.
The goal is to construct a diversified long-only commodity portfolio by combining:
- historical risk analysis
- ARIMA forecasts for short-term return views
- GARCH forecasts for conditional volatility
- Black-Litterman allocation to combine market priors and model-driven views
The project is designed to produce both:
- clean Excel reports
- interpretable portfolio outputs for analysis and presentation
The project computes descriptive and portfolio risk metrics such as:
- return series
- volatility and rolling volatility
- drawdown
- correlation matrix
- Sharpe ratio
- summary tables by asset
Two families of models are used:
- ARIMA to estimate one-step-ahead expected returns
- GARCH(1,1) to estimate one-step-ahead conditional volatility
These forecasts are transformed into portfolio views and risk inputs.
The portfolio is built using a Black-Litterman framework, where:
- the prior comes from a reference portfolio (market-like or equal weight)
- ARIMA forecasts provide the views
- confidence levels determine the uncertainty of each view
- the covariance matrix blends Ledoit-Wolf shrinkage and GARCH-based conditional covariance
The final optimization is performed under:
- long-only constraints
- weights summing to 100%
.
├── MASTER_FINAL.csv
├── prices.py
├── Portfolio.py
├── ts_models.py
├── run_models.py
├── run_portfolio.py
├── risk_report.py
├── outputs/
│ ├── models/
│ └── portfolio/
└── README.md