YAML Metadata Warning:empty or missing yaml metadata in repo card
Check out the documentation for more information.
π Time Series Forecasting β Stock Prices
This project demonstrates how to perform time series forecasting on stock prices using both statistical models (ARIMA, SARIMAX) and deep learning (LSTM), with proper evaluation techniques like rolling window forecasting.
π Project Overview
The notebook walks through the end-to-end pipeline of forecasting stock prices:
Dataset Acquisition
- Uses the Kaggle dataset: World Stock Prices β Daily Updating
- Downloaded via
kagglehub
Preprocessing
- Convert
Datecolumn to datetime and set as index. - Sort data by date.
- Filter for a single stock (default: AAPL).
- Handle missing values using forward-fill / interpolation.
- Convert
Exploratory Data Analysis (EDA)
- Visualize stock closing prices over time.
- Check for stationarity (ADF test).
- Plot ACF/PACF to guide ARIMA orders.
Modeling Approaches
- ARIMA: Baseline forecasting with manually selected parameters.
- Auto-ARIMA: Automated parameter tuning using AIC/BIC.
- SARIMAX: Seasonal ARIMA with exogenous variables (optional).
- LSTM: Deep learning model for sequence prediction.
Forecast Evaluation
- Implement rolling window forecasting:
- Train on initial window β Forecast one step ahead β Update with true value β Repeat.
- Evaluate models using metrics:
- RMSE, MAE, MAPE
- Implement rolling window forecasting:
βοΈ Installation & Requirements
Install dependencies:
pip install pandas numpy matplotlib seaborn scikit-learn statsmodels pmdarima tensorflow kagglehub
If running in Google Colab, you may also need:
pip install kagglehub
π Usage
Clone or download the notebook:
git clone <repo-link> cd stock-forecastingRun the Jupyter Notebook:
jupyter notebook "Time_Series_Forecasting_β_Stock_Prices.ipynb"Inside the notebook:
- Change the stock ticker (
ticker_symbol = 'AAPL') to forecast other stocks. - Choose between ARIMA / SARIMAX / LSTM sections.
- Run evaluation cells to compare results.
- Change the stock ticker (
π Results
- ARIMA works well for short-term stationary series.
- SARIMAX captures seasonality but is computationally heavier.
- LSTM adapts to nonlinear patterns, showing better performance for long-term forecasts.
- Rolling window evaluation provides realistic performance assessment compared to a single train-test split.
π Key Files
Time_Series_Forecasting_β_Stock_Prices.ipynbβ Main notebook with full workflowworld_stock_prices_2_years.csvβ Example filtered dataset for a single stock
β¨ Future Improvements
- Add Prophet model for easier seasonality handling.
- Incorporate financial indicators (RSI, MACD) as exogenous features.
- Deploy as a web dashboard with live forecasts.
π License
This project is for educational and research purposes only. Not financial advice.