Skip to content

A univariate LSTM model to predict IBEX 35 index stock market returns

License

Notifications You must be signed in to change notification settings

lajobu/LSTM_stocks_thesis

Repository files navigation

LSTM_stocks_thesis:

This repository is part of the dissertation Challenging the weak form of market efficiency: a univariate LSTM model to forecast the IBEX 35 index by Jorge Bueno Perez (@lajobu).

The related materials are part of the final dissertation of the master studies in Data Science and Business Analytics at the University of Warsaw (Poland).

Summary:

The increase in the computational power together with the rapid development in the implementation of deep learning models enable to verify whether some hypotheses are still valid in the finance theory. A LSTM (long short-term memory) univariate model, based on recurrent neural networks, is used to forecast financial time series with the aim of predicting returns on the IBEX 35 index high frequency hourly data for the last quarter of 2020. A random walk with drift model is utilized for comparison purposes. The results of the statistical Diebold-Mariano test suggest that the weak form of efficient market hypothesis is accepted, due to the fact that the random walk with drift model has significantly better prediction accuracy than the LSTM model.

Keywords:

deep learning, long short-term memory, recurrent neural networks, financial time series forecasting, IBEX 35 index, high frequency data, Diebold-Mariano test, efficient market hypothesis

Codes:

🔗 model_modules.py contains all the the modules used in this project.

🔗 econ_test.py contains the econometric tests perfomed (unit root tests and autocorrelation).

🔗 tuning.py contains the tuning process created by the author.

🔗 final_model_LSTM.py contains the codes to run the final model with the selected final parameters.

🔗 Diebold-Mariano_test.R contains the Diebold-Mariano test performed on the LSTM model and random walk with drift model.

Some insights:

1) Model pipeline scheme:

2) Model summary:

3) Chosen parameters

4) Training process. RMSE on validation and training samples

5) Real and predicted mid-price in test sample

6) Real and predicted mid-price in training and validation samples

Software:

The proposed univariate LSTM many-to-one sequence forecast model applied to the IBEX35 index, is built in python 3.8.3. Several packages were used while creating the model, more details about the versions can be found in requirements

For the purpose of running Diebold-Mariano test, R 4.1.0 (Camp Pontanezen). The package forecast (version 8.1.4) is utilized.

Data source:

https://www.dukascopy.com/swiss/english/home/

Licence

Copyright (c) 2021 Jorge Bueno Perez