Prince Okunade.
All projects

TIME SERIES

Stock Price Direction Predictor

Exploring next-day price direction with chronological evaluation, technical indicators and model explanations.

The problem

Financial time series are noisy, and a model can appear successful if its evaluation lets future information influence training. This project explores next-day direction while making the modelling and explanation workflow visible.

Data and approach

The pipeline fetches daily price and volume data through yfinance. Technical features include returns, moving averages, RSI, MACD, Bollinger Bands, ATR and OBV. The target is whether the following day’s closing price is higher than today’s.

How I built it

Separate modules fetch data, engineer features and train models. Logistic Regression, Random Forest and XGBoost are compared, with GridSearchCV and TimeSeriesSplit for tuning. Saved model artefacts, feature names and a scaler are loaded by a Streamlit dashboard. Plotly charts show price history, while SHAP explains model predictions.

How decisions were made

The most recent 20% of observations form the test set rather than using a shuffled split. TimeSeriesSplit preserves ordering during model selection. Comparing a linear model with tree ensembles provides different levels of complexity, but I have not established an out-of-sample trading advantage.

What worked

I connected data collection, 22 engineered features, model training and explanations in one workflow. The dashboard supports ticker selection, price charts, direction predictions and strategy comparison.

What needs improvement

The current implementation fits preprocessing across the training set before cross-validation. I need to fit it independently inside each fold. Adjacent next-day labels also need separation at split boundaries. A chronological holdout alone is therefore not enough to claim the entire evaluation is leakage-free.

Effect and limits

This demonstrates an end-to-end modelling workflow. It does not demonstrate a profitable strategy. The next evaluation should fix fold-level preprocessing and label boundaries, then include transaction costs and robust out-of-sample comparisons.

Demo availability

This project runs locally; there is no public hosted demo. The code includes the implementation and setup instructions.