Time Series Forecasting for Portfolio Management Optimization by Natnael YilmaTime Series Forecasting for Portfolio Management Optimization by Natnael Yilma

Time Series Forecasting for Portfolio Management Optimization

Natnael Yilma

Natnael Yilma

Time Series Forecasting for Portfolio Management Optimization

A comprehensive financial time series analysis and forecasting project for portfolio management decision support. This project provides tools for data preprocessing, exploratory data analysis (EDA), and time series forecasting using both classical statistical methods (ARIMA/SARIMA) and deep learning approaches (LSTM).

📋 Project Overview

This project is designed for Guide Me in Finance (GMF) Investments, a financial advisory firm focused on data-driven portfolio management. The goal is to understand trends, volatility, risk, and stationarity in financial time series data to support forecasting models and portfolio optimization strategies.

Key Features

Data Preprocessing & EDA: Comprehensive data cleaning, exploratory analysis, and risk metrics calculation
ARIMA/SARIMA Forecasting: Classical time series models with automatic parameter selection
LSTM Deep Learning: Neural network models for capturing non-linear patterns
Model Comparison: Evaluation metrics (MAE, RMSE, MAPE) and visual comparisons
Risk Analysis: Value at Risk (VaR) and Sharpe Ratio calculations

🎯 Objectives

Prepare, clean, and explore historical financial time series data
Build and evaluate multiple forecasting models
Compare statistical and deep learning approaches
Provide actionable insights for portfolio decision-making

📊 Data Sources

Primary Data Source

Library: YFinance (Python)
Date Range: January 1, 2015 → January 15, 2026
Assets Analyzed:
TSLA (Tesla Inc.) - High-growth stock
BND (Vanguard Total Bond Market ETF) - Low-risk bonds
SPY (S&P 500 ETF) - Market benchmark

Data Fields

Date
Open, High, Low, Close
Adjusted Close (primary target variable)
Volume

🛠️ Dependencies

Core Libraries

yfinance (≥0.2.28): Financial data download
pandas (≥2.0.0): Data manipulation
numpy (≥1.24.0): Numerical computations
matplotlib (≥3.7.0): Plotting
seaborn (≥0.12.0): Statistical visualizations

Time Series Analysis

statsmodels (≥0.14.0): Statistical models (ARIMA, ADF tests)
pmdarima (≥2.0.0): Auto ARIMA parameter selection
scipy (≥1.10.0): Scientific computing

Machine Learning

tensorflow (≥2.13.0): Deep learning framework
scikit-learn (≥1.3.0): Preprocessing and metrics

Development

jupyter (≥1.0.0): Notebook environment
ipykernel (≥6.25.0): Jupyter kernel

🚀 Setup Instructions

1. Clone the Repository


2. Create Virtual Environment (Recommended)


3. Install Dependencies


4. Verify Installation


📓 Notebooks

1. Financial Data Preprocessing & EDA

File: notebooks/financial_data_preprocessing_eda.ipynb
Purpose: Prepare, clean, and explore historical financial time series data for portfolio analysis.
What it does:
Extracts historical data for TSLA, BND, and SPY
Performs data cleaning and quality assessment
Conducts exploratory data analysis (price trends, volatility, returns)
Detects outliers and anomalies
Performs stationarity tests (ADF)
Calculates risk metrics (VaR, Sharpe Ratio)
How to run:
Open Jupyter: jupyter notebook or jupyter lab
Navigate to notebooks/financial_data_preprocessing_eda.ipynb
Run all cells sequentially (Cell → Run All)
Note: Data download may take a few minutes
Expected runtime: 5-10 minutes
Output:
Cleaned datasets
Visualizations (price trends, volatility, distributions)
Risk metrics tables
Stationarity test results

2. TSLA Forecasting Models

File: notebooks/tsla_forecasting_models.ipynb
Purpose: Build and compare ARIMA/SARIMA and LSTM forecasting models for Tesla stock.
What it does:
Loads and preprocesses TSLA data
Splits data chronologically (train: 2015-2024, test: 2025-2026)
Builds ARIMA/SARIMA model with auto parameter selection
Builds LSTM deep learning model
Generates forecasts and evaluates performance
Compares models using MAE, RMSE, and MAPE
How to run:
Open Jupyter: jupyter notebook or jupyter lab
Navigate to notebooks/tsla_forecasting_models.ipynb
Run all cells sequentially (Cell → Run All)
Note:
Auto ARIMA search may take 5-15 minutes
LSTM training may take 10-30 minutes (depending on hardware)
Expected runtime: 20-45 minutes (depending on hardware)
Output:
Trained ARIMA/SARIMA model
Trained LSTM model
Forecast visualizations
Model comparison table
Performance metrics

📁 Project Structure


🔧 Usage Examples

Using the Data Loader Module


Using Evaluation Metrics


⚠️ Important Notes

Efficient Market Hypothesis (EMH)

This project acknowledges the Efficient Market Hypothesis, which suggests that stock prices reflect all available information. The goal is not to claim perfect price prediction, but rather to:
Evaluate how models capture trend, momentum, and volatility patterns
Understand model limitations
Provide decision-support tools for portfolio management
Recognize that any forecasting advantage is likely temporary

Data Limitations

Historical data may not predict future performance
External factors (news, events) not captured in price-only models
Market efficiency may limit forecasting advantage
Models assume past patterns will continue (may not hold in crises)

Best Practices

Use forecasts as one input among many (not the sole decision factor)
Combine quantitative forecasts with fundamental analysis
Regularly retrain models as new data becomes available
Monitor model performance over time
Maintain risk management discipline

🐛 Troubleshooting

Common Issues

1. ModuleNotFoundError

2. Data Download Fails
Check internet connection
Verify ticker symbols are correct
YFinance may have rate limits - wait a few minutes and retry
3. TensorFlow Installation Issues

4. Memory Errors (LSTM Training)
Reduce batch size in LSTM model
Reduce sequence length
Use smaller training set

📝 License

This project is for educational and research purposes. Please ensure compliance with data usage terms from YFinance and other data providers.

🤝 Contributing

Contributions are welcome! Please:
Fork the repository
Create a feature branch
Make your changes
Submit a pull request

📧 Contact

For questions or issues, please open an issue on the repository.
Disclaimer: This analysis is for informational and decision-support purposes only. Past performance does not guarantee future results. All investment decisions should consider individual risk tolerance, investment objectives, time horizon, market conditions, and professional financial advice.
Like this project

Posted May 11, 2026

Developed time series forecasting models for portfolio management.