LSTM Based Stock Prediction Modeling And Analysis

1y ago
28 Views
2 Downloads
1.11 MB
6 Pages
Last View : 4d ago
Last Download : 3m ago
Upload by : Eli Jorgenson
Transcription

Advances in Economics, Business and Management Research, volume 648Proceedings of the 2022 7th International Conference on Financial Innovation and Economic Development (ICFIED 2022)LSTM-based Stock Prediction Modeling and AnalysisRuobing Zhang1,*1Beijing University of Technology, BJUT*Ruobing Zhang.Email:1262385605@qq.comABSTRACTThe stock market plays an important role in the economy of a country in terms of spending and investment. Predictingstock prices has been a difficult task for many researchers and analysts. Research in recent years has shown that LongShort-Term Memory (LSTM) network models perform well in stock price prediction, and it is considered one of themost precise prediction techniques, especially when it is applied to longer prediction ranges. In this paper, we set theprediction range of the LSTM network model to 1 to 10 days, push the data into the built LSTM network model afterpre-processing operations such as normalization of data, and set the optimal values of epochs, batch size, dropout,optimizer and other parameters through training and testing. By comparing with Linear Regression, eXtreme gradientboosting (XGBoost), Last Value and Moving Average, the results show that the LSTM network model does notperform better than other models when applied to a short forecasting horizon.Keywords: Long Short-Term Memory, Stock Market, forecasting, prediction.1.INTRODUCTIONWith the continuous application and development ofartificial intelligence technology and big datatechnology, along with the further improvement of thefinancial market and the strong demand of the financialservice industry, stock market forecasting has attractedwide attention from the industry and academia[1].Machine learning algorithms such as decision trees,genetic algorithms, support vector machines, logisticregression and deep learning network models have beenapplied to stock forecasting in research. In recent years,LSTM network models have become a hot researchtopic for researchers. The LSTM neural network is atype of realizable recurrent neural network model withselective memory and intra-temporal influence, which isvery suitable for the stochastic non-stationary series ofstock price time series. LSTM network is considered tobe one of the most accurate forecasting techniques.A large number of studies is currently active on thesubject of LSTM neural network used in finance. Somestudies used a various set of parameters with a differentnumber of epochs to measure the RMSE of the LSTMneural network model so as to improve the accuracy ofthe model [2], others used ML algorithm based onLSTM RNN to do predictions and tried to find the bestsets for bout data length and the number of trainingepochs that better suit the assets and maximize theaccuracy of the predictions[3]. Another paper comparedthe evaluation indicators with the prediction results tofind the appropriate number of LSTM layers and hiddenneurons[4]. And some studies explored whether LSTMneural networks can be applied to the price trendprediction of individual stocks[5]. Also, somestudiesemployed tree-based models and neural networks (ANN,RNN, and LSTM) to correctly forecast the values offour stock market groups as a regression problem and tosee which models are more precise[6]. Another paperdid a comparison of ARIMA, ANN and LSTM for stockprice prediction[7]. Many existing literatures study theapplication of LSTM neural network models to stockmarket forecasting, but most of them focus on applyingLSTM to forecast a longer forecast range and improvingthe accuracy of the predictions. The performance ofLSTM neural network models in this regard doesoutperform other machine learning methods. In additionto improving the prediction accuracy of LSTM neuralnetwork models by optimizing parameter settings andprocessing data, some studies have proposed morecomplex models based on LSTM models to improve theprediction accuracy. Some studies processed stock datathrough a wavelet transform and used an attention-basedLSTM neural network to predict the stock[8]. Othersproposed a multi-value associated network model ofLSTM-based deep-recurrent neural network (AssociatedNet) to predict multiple prices of stocksimultaneously[9].Copyright 2022 The Authors. Published by Atlantis Press International B.V.This is an open access article distributed under the CC BY-NC 4.0 license 37

Advances in Economics, Business and Management Research, volume 648However, there is a lack of research applying LSTMneural network models to predict the stock market in ashort-term range. In this paper, we apply five models,LSTM, Linear Regression, XGboost, Moving Average,and Last Value, respectively, by setting the predictionscope and using the historical data of Vanguard TotalStock Market Index Fund ETF Shares (VTI) from10/5/2018 to 10/4/2021, as the original data forshort-term prediction. The forecasting performance ofthe models is evaluated using root mean square error(RMSE) and mean absolute percentage error (MAPE).The main objective of this paper is to investigate theprediction accuracy of LSTM neural network modelsapplied to short-term prediction ranges and to seewhether the LSTM model shows certain advantages,compared to other machine learning algorithms.2.LONG SHORT-TERM MEMORY (LSTM)Long Short - Term Memory (LSTM) is a long andshort-term memory network, which is a time-recursiveneural network suitable for processing and predictingimportant events with relatively long intervals anddelays in time series. The LSTM algorithm was firstproposed by Sepp Hochreiter and Jurgen Schmidhuberin 1997 as a specific form of Recurrent neural network(RNN).Long Short-Term Memory (LSTM) is one of manytypes of Recurrent Neural Network RNN, it’s alsocapable of catching data from past stages and using itfor future predictions [10]. In general, an ArtificialNeural Network (ANN) consists of three layers: consistsof three layers:1) Input layer,2) Hidden layers,3) Output layer.In LSTM, the early stages can be remembered bygating and joined along the memory line. The followingFigure 1 depicts the composition of LSTM nodes.one cell to another. Finally, the sigmoidal neuralnetwork layers consisting of gates drive the cells to anoptimal value by disposing or letting the data pass. Eachsigmoid layer has a binary value (0 or 1), where 0 means"doesn't let anything through"; and 1 means "letseverything through". The goal here is to control the stateof each cell.The gate is controlled in the following way:- The Forget Gate outputs a number between 0 and 1,where 1 means "keep this completely"; and 0 means"ignore this completely".- The Memory Gate selects which new data will bestored in the cell. First, a sigmoid layer "input gatelayer" selects which values will be changed. Next, atanh layer makes a vector of new candidate values thatcan be added to the state.- The Output Gate determines what the output ofeach cell will be. The output value will be based on thestate of the cell and the filtered freshest data[3].3.METHODOLOGY AND DATAOur system can be divided into 4 parts. These areraw data acquisition, date pre-processing, featureextraction and training of Neural Network.3.1. Raw DataThe data used in this article is from Yahoo Financeand includes 7 features: Date, Open Price, High Price,Low Price, Close Price, Adjusted Closing Price andVolume. The data structure is shown in Table 1. For VIT,our data series cover the period going from 10/5/2018 to10/4/2021.3.2. Data Pre-processingThe pre-processing stage involves:a) Data discretization: Part of data reduction but withparticular importance, especially for numerical datab) Data transformation: Normalization.c) Data cleaning: Fill in missing values.Figure 1. The internal structure of an LSTM [11].The ability to memorize data sequences makesLSTMs a special kind of RNNs. Each LSTM node ismostly composed of a set of cells responsible for storingthe passed data streams. The upstream connection modelin each cell acts as a transport line to pass data from thepast to the present, and the independence of the cellshelps the model to dispose of filters that add values fromAfter the dataset is transformed into a clean dataset,the dataset is divided into training, testing andcross-validation set so as to evaluate. In order to buildour model, we are going to use the LSTM RNN. Ourmodel uses 60% of data for training, 20% of data fortesting and 20% of data for cross-validation.3.3. Feature ExtractionIn this stage, only the features which are to be fed tothe neural network are chosen. We will choose the featurefrom date, open, high, low, close, adj close and volume.2538

Advances in Economics, Business and Management Research, volume 648In this paper, the feature adj close is selected and itsline graph is shown in Figure 2. It is clear that adjustedclosing price rose considerably between 2018 and 2021.However, at the beginning of 2020, the entire economicmarket has been hit hard by the outbreak of theCOVID-19 and there is a sudden decrease can be seen inthis year, with the price of the stock dropped by roughly 60.Figure 2. Adj closeand trained for prediction. For training, we use meansquared error to optimize our model and determine theoptimal parameter settings:3.4. Training Neural NetworkIn this stage, the data is fed to the neural networkTable 1.The structure of raw 9996143.800003141.720001adj 12003386400399040031483003783800epochs 50dropout 0.2batch size 8The structure of our model is shown in the Table 2.lstm units 128Table 2. the LSTM model summeryLayer(type)Output ShapeParameterslstm 2(LSTM)(None,9,50)10400dropout 2 (Dropout)(None, 9, 50)0lstm 3 (LSTM)(None, 50)20200dropout 3 (Dropout)(None, 50)0dense 1 (Dense)(None, 1)51Total params: 30,651Trainable params: 30,651Non-trainable params: 02539

Advances in Economics, Business and Management Research, volume 6484. RESULT AND DISCUSSIONIn this experiment, four other methods were alsoused to make predictions in this paper separately andcompared with the prediction results of applying theLSTM neural network model. The prediction results areshown in the following figures:The result of using Last Value to predict is shown inthe Figure 3. This is the most cost effective forecastingmodel. We can find that the forecast for each day (redcross) is simply the value of the previous day (greencross). Last Value is often used as a benchmark forcomparing more complex models.The result of using linear regression to predict isshown in the Figure 4. It can be found that this methoddoes not capture changes in stock prices up or downwell.The prediction results of using Moving Average,XGBoost and LSTM can be shown in Figure 5, Figure 6and Figure 7 respectively. Using the method ofXGBoost is an iterative process of transforming weaklearners into strong learners. In the moving averagemethod, the predicted value will be the average of thefirst N values. As can be seen from the figures, there isnot much difference between the prediction results ofthese three methods, but the prediction results obtainedby using the LSTM and the XGBoost respectively areslightly better than using the Moving Average, withrelatively small errors between the test and predictedvalues.Figure 4. Forecast results of Linear RegressionFigure 5. Forecast results of Moving AverageFigure 6.Forecast results of XGBoostFigure 3. Forecast results of Last Value2540

Advances in Economics, Business and Management Research, volume 648(2)The RMSE and MAPE values of the five methodsare shown in Table 3.Table 3. RMSE of five methodsMethodLast ValueMoving AverageLinear RegressionXGBoostLSTMFigure 7. Forecast results of LSTMThe prediction results of the 5 models are integratedinto the same graph for comparison, as shown in Figure8, except for the poor prediction results of linearregression, the predictions of the other 4 are difficult tojudge by direct 5980.6890.7800.5930.633Comparing the RMSE and MAPE of the fivemethods, it can be seen from Table 3 that the twomethods with the best prediction results are XGBoostand Last Value, which provide lower RMSE and MAPE.Last Value achieves better prediction results than theother more complex methods, especially outperformingthe LSTM neural network model. This conclusion maybe due to the fact that the prediction range is only 1. Ifthe prediction range is longer, the other methods may bemore effective than the Last Value. Additionally, there isthe issue of data size. The LSTM is a neural network,and like any neural network requires a large amount ofdata to be trained on properly. The best predictions areobtained using XGBoost. The XGBoost performssecond-order Taylor expansions on the loss function.This method introduces the second-order derivative bothto increase accuracy and to allow customisation of theloss function. This largely avoids the problem of timelag, a drawback that is common in LSTM.4. CONCLUSIONFigure 8. Forecast results of 5 methodsThe article uses root mean square error (RMSE) andmean absolute percentage error (MAPE) to evaluate theprediction results.The Root Mean Square Error (RMSE) is verysensitive to the very large or very small errors in a set ofmeasurements, so the root-mean-square error can reflectthe precision of the measurement very well. Equation (1)shows its formula, where yi is the neural network outputand y is the true value.(1)Mean Absolute Percentage Error (MAPE) is oftenemployed to assess the performance of the predictionmethods. MAPE is also a measure of predictionaccuracy for forecasting methods in the machinelearning area, it commonly presents accuracy as apercentage[6]. Equation (2) shows its formula, where yiis the output value of the neural network and y is thetrue value.Trading in the stock market is growing rapidly andinvestors, analysts are eager to find a method andtechnique to effectively predict future stock markettrends. In recent years, many studies have shown thatLSTM neural network models are effective in predictingthe stock market, and compared with other machinelearning algorithms, LSTM neural network modelsperform very well when applied to longer predictionhorizons.In this paper, we compare the results of the LSTMneural network model in making short-term forecastrange predictions with the results of the other fouralgorithms and find that the LSTM neural networkmodel is not a perfect prediction method. However, ithas to be admitted that the LSTM neural network modelis better at capturing trends and seasonality in long-termforecast range prediction. This will encourage moreresearchers to use new techniques to find newforecasting methods that can be applied to moresituations, thus helping investors, analysts or anyoneinterested in investing in the stock market by providing2541

Advances in Economics, Business and Management Research, volume 648them with a good knowledge of the future of the stockmarket.REFERENCES[1] Agrawal, J.G., Chourasia, V. and Mittra, A., 2013.State-of-the-art in stock prediction techniques.International Journal of Advanced Research inElectrical, Electronics and InstrumentationEngineering, 2(4), pp.1360-1366.[2] Roondiwala, M., Patel, H. and Varma, S., 2017.Predicting stock prices using LSTM. InternationalJournal of Science and Research (IJSR), 6(4),pp.1754-1756.[3] Moghar, A. and Hamiche, M., 2020. Stock marketprediction using LSTM recurrent neural network.Procedia Computer Science, 170, pp.1168-1173.[4] PENG Yan, LIU Yuhong, ZHANG Rongfen, 2019.Modeling and analysis of stock price forecast basedon LSTM. Computer Engineering and Applications,55(11), pp.209-212.[5] Deng, Fengxin and Wang, Hongliang, 2018.Application of LSTM neural networks in stockprice trend prediction - a study based on individualstock data from the US and Hong Kong stockmarkets. Collection, 14.[6] Nabipour, M., Nayyeri, P., Jabani, H., Mosavi, A.and Salwana, E., 2020. Deep learning for stockmarket prediction. Entropy, 22(8), p.840.[7] Ma, Q., 2020. Comparison of ARIMA, ANN andLSTM for stock price prediction. In E3S Web ofConferences (Vol. 218). EDP Sciences.[8] Qiu, J., Wang, B. and Zhou, C., 2020. Forecastingstock prices with long-short term memory neuralnetwork based on attention mechanism. PloS one,15(1), p.e0227222.[9] Ding, G. and Qin, L., 2020. Study on the predictionof stock price based on the associated networkmodel of LSTM. International Journal of MachineLearning and Cybernetics, 11(6), pp.1307-1317.[10] Patterson, J. and Gibson, A., 2017. Deep learning:A practitioner's approach. " O'Reilly Media, Inc.".[11] Olah, C. (2015). Understanding lstm networks–colah’s blog. Colah. github. io.2542

stock prices has been a difficult task for many researchers and analysts. Research in recent years has shown that Long Short-Term Memory (LSTM) network models perform well in stock price prediction, and it is considered one of the . by setting the prediction scope and using the historical data of Vanguard Total Stock Market Index Fund ETF .

Related Documents:

1. BASIC INTRODUCTION OF STOCK MARKET A stock market is a public market for trading of company stocks. Stock market prediction is the task to find the future price of a company stock. The price of a share depends on the number of people who want to buy or sell it. If there are more buyers, then prices will rise. If the seller has a number of .

the relationship between stock prices and these factors. Although these factors will temporarily change the stock price, in essence, these factors will be reflected in the stock price and will not change the long-term trend of the stock price. erefore, stock prices can be predicted simply with historical data.

The stock market is dynamic, non-stationary and complex in nature, the prediction of stock price index is a challenging task due to its chaotic and non linear nature. The prediction is a statement about the future and based on this prediction, investors can decide to invest or not to invest in the stock market [2]. Stock market may be

on a benchmark dataset from Twitter. Empirical results show that modeling sentence represen-tation with standard LSTM does not perform well. Incorporating target information into LSTM can signicantly boost the classication accuracy. The target-dependent LSTM models achieve

An ecient stock market prediction model using hybrid feature reduction method based on variational autoencoders and recursive feature elimination Hakan Gunduz* Introduction Financial prediction, especially stock market prediction, has been one of the most attrac - tive topics for researchers and investors over the last decade. Stock market .

Credit Card Fraud Detection Model Based on LSTM Recurrent Neural Networks . Ibtissam Benchaji, Samira Douzi, and Bouabid El Ouahidi . [10], [11], hidden Markov models [11], [12], logistic regression algorithms [10], [13], decision trees [14], [15], random forests [10], [16]-[19], and k-nearest . LSTM has feedback connections between hidden .

stock prices then an increase in the -rm s own stock price informativeness reduces the sensitivity of its investment to its peer stock price (prediction 1). Indeed, as the signal conveyed by its own . stock price (prediction 2), but not otherwise. The same prediction holds for an increase in the correlation of the fundamentals of a -rm .

additif alimentaire ainsi que d’une nouvelle utilisation pour un additif alimentaire déjà permis. Les dispositions réglementaires pour les additifs alimentaires figurent à la partie B du titre 16 du RAD. L’article B.16.001 énumère les exigences relatives à l’étiquetage des additifs alimentaires. En particulier, l’article B.16.002 énumère la liste des critères qui doivent .