Year: 2024
Type: article
Abstract: In this paper, we will be using the LSTM model to predict the next day's updtrend for financial time series. The idea here is to analyze whether LSTM is able to predict the sign of daily returns based on adjusted close prices. Thus, it is a classification problem.I begin with the problem statement of this paper i.e. the use of LSTM model for time series prediction. The data has been cleaned to remove any null values and use the linear interpolation method in case there are any such values. The pandas TA library has been used in order to generate features. Importing all the stategies present in the library, I have used the BorutaPy method of feature selection as it is a robust method that provides us with the relevant feature ranking that can be used for our model. Next I transform the features that have been selected. By using MinMaxScaler estimator fromsklearn.preprocessing.With MinMaxScaler we scale our data such that each feature lies between zero and one (mapping 0,1). Post this, we jump into the model building exercise.I have built three different LSTM models. Each of them has different number of layers with different number of dropout layers. The reason for building these three types of models is to test the different depths our models and how they are working on the given dataset. There is a shallow model, a model that has a few layers, and a model that has a relatively larger number of layers. Once we have fitted each model on the data and then tested it out, I have built a classification report, confusion matrix and ROC curve plot to compare the 3 models. Post evaluating how each of the models work, I have chosen two of the best models (as they had similar evaluations) for the hyperparameter tuning process. The reason for choosing two models is as i mentioned, because they had similar accuracy results, so I was intrigued to see how they would perform after the tuning process, given that the layers are different for both models, yet they had similar predictions. Lastly, on the best model from the above two, I have adopted a simple trading strategy and backtested the same on our data post which I present the concluding remarks.# plotting & outputs from pprint import pprint import matplotlib.pyplotas plt plt.style.use('seaborn')# sklearn imports from sklearn.compose import ColumnTransformer from sklearn.preprocessing import StandardScaler, MinMaxScaler, OneHotEncoder from sklearn.pipeline import Pipeline from sklearn.model_selection import train_test_split from sklearn.model_selection import TimeSeriesSplit, cross_val_score from sklearn.model_selection import GridSearchCV,
Author: Aumkar Wagle
Language: English
Field: Decision Sciences
Domain: Social Sciences
Open Access status: diamond
OpenAlex ID: W4396862079
