A Streamlit dashboard for multivariate stock forecasting using Close and Volume.
Supports three model options: XGBoost, Prophet, and SARIMAX. The project includes robust preprocessing (handling MultiIndex columns from yfinance, datetime normalization, dtype sanitization), lag & rolling feature engineering, recursive multi-step forecasting for tree models, and defensive code to handle common runtime issues.
app.py/r1_ui_forecast.py— main Streamlit script (replace with your script name)- utility modules or functions:
- feature engineering (lags, rolling stats)
- model wrappers for XGBoost, Prophet, SARIMAX
requirements.txt— Python dependencies
- Streamlit UI to choose ticker, date range, model, and forecast horizon.
- Multivariate modeling:
- XGBoost: lag & rolling features, recursive multi-step forecasting, GridSearch with safeguards on small datasets.
- Prophet:
Volumeused as regressor (if provided). - SARIMAX:
Volumeused as exogenous variable.
- Robust input handling:
- Auto-detect & normalize
Date,Close,Volumecolumns (handles MultiIndex / tuple column names). - Convert datetime to numeric (ordinal/dayofweek) or engineered features.
- Sanitize predictions and arrays to ensure 1-D shapes for metrics.
- Auto-detect & normalize
- Defensive GridSearch usage — reduces/avoids heavy tuning on small datasets.
- Visualizations: holdout vs predicted, historical + forecast combined chart.
- Clone repository
git clone https://github.com/<your-username>/multivariate-stock-forecast.git
cd multivariate-stock-forecast- Create & activate virtual environment (recommended) macOS / Linux:
python -m venv .venv
source .venv/bin/activateWindows (PowerShell):
python -m venv .venv
.venv\Scripts\Activate.ps1- Install dependencies
pip install -r requirements.txtIf you experience issues installing Prophet on Windows, try using conda:
conda install -c conda-forge prophet- Run the app
streamlit run r1_ui_forecast.py