Stock price prediction with optimized deep LSTM network with artificial rabbits optimization algorithm

The stock market is a financial market where shares of publicly listed corporations are purchased and sold. It is an indicator of a country ’ s economic health, reflecting the performance of companies and the overall business environment. The prices of stocks are determined by supply and demand. Investing in the stock market can be risky, but it can offer the potential for significant returns over the long term. Artificial intelligence, including the stock market, has become increasingly prevalent in the financial sector. Long Short-Term Memory (LSTM) is a type of artificial neural network that is often used in time series analysis. It can effectively predict stock market prices by handling data with multiple input and output timesteps. Metaheuristic algorithms, such as Artificial Rabbits Optimization algorithm (ARO), can be used to optimize the hyperparameters of an LSTM model and improve the accuracy of stock market predictions. In this paper, an optimized deep LSTM network with the ARO model (LSTM-ARO) is created to predict stock prices. DJIA index stocks are used as the dataset. LSTM-ARO is compared with one artificial neural network (ANN) model, three different LSTM models, and LSTM optimized by Genetic Algorithm (GA) model. All the models are tested on MSE, MAE, MAPE, and R2 evaluation criteria. The results show that LSTM-ARO overcomes the other models.


Introduction
A stock market is a place where people can buy and sell stocks of companies that are publicly traded with the goal of making money.It is an important indicator of a country's economic health because it reflects the performance of companies and the overall business environment.The stock market operates through a network of exchanges, like Dow Jones (DJIA), which is one of the stock markets in the USA (Gürbüz & S ¸ahbaz, 2022).These exchanges are where buyers and sellers meet to trade stocks.The prices of stocks are determined by the law of supply and demand, where buyers are willing to pay more for a stock if they think it will go up in value, and sellers are willing to accept less if they think it will go down in value (Bosworth et al., 1975;Shah et al., 2019;Teweles & Bradley, 1998).
There are different types of stocks, and they include common, preferred, and warrants.Common stock allows shareholders to own part of a company, vote on company matters, and receive dividends.On the other hand, preferred stock gives shareholders an advantage over common stockholders in terms of receiving dividends and liquidating assets.Lastly, warrants are like options that enable investors to buy a specific number of shares at a set price within a particular period (Giudici et al., 2022;Gornall & Strebulaev, 2022).
The stock market can be affected by different factors that can influence the prices of stocks, such as the state of the economy, political stability, and the performance of individual companies.To predict and analyze stock prices, investors can use different tools and strategies, including fundamental analysis that examines a company's financial situation and industry conditions and technical analysis that considers trends and patterns in stock prices and trading volume (Lim & Rokhim, 2020;Nguyen & Nguyen, 2020).Investing in the stock market is not without risk, as the value of stocks can change a lot.Nevertheless, investing in the stock market can lead to considerable gains over the long term.Mutual funds are a common way for people to invest in the stock market.These funds combine the money of multiple investors and invest in a varied portfolio of stocks.Alternatively, individual investors can invest in stocks directly through brokerage firms (Kim et al., 2020).
Algorithmic trading, also known as automated or black box trading, is the use of computer algorithms to make trading decisions in financial markets.This type of trading is becoming more popular in the stock market because it allows traders to make faster and more accurate decisions than they could with manual trading.Algorithmic trading systems analyze market data in real-time and identify trading opportunities.They execute trades based on predefined rules and make decisions based on various factors, including market trends, news events, and technical indicators.Both individuals and institutions, including hedge funds, can use algorithmic trading to trade various financial instruments, such as stocks, futures, options, and forex.However, algorithmic trading is not without its risks, and traders must be aware of its potential downsides (Li et al., 2019;Park & Lee, 2021;Tao et al., 2021;Théate & Ernst, 2021).
In recent years, artificial intelligence (AI) has become more prevalent in the financial industry, including the stock market.AI algorithms have the capability to analyze vast amounts of data and make predictions or decisions based on that analysis.This can be useful for predicting stock prices, identifying trends, and making investment decisions.For example, AI algorithms can analyze data like historical stock prices, company financial statements, and market trends in the stock market to predict future performance.AI can also monitor market conditions in real time and identify opportunities for buying or selling stocks.All in all, AI has the potential to significantly improve the efficiency and accuracy of stock market analysis and decision-making, which can ultimately lead to better investment outcomes for investors (Ashta & Herrmann, 2021;Milana & Ashta, 2021).
Long Short-Term Memory (LSTM) is a type of computer program that is designed to analyze and understand data that has long-term dependencies.It is often used in analyzing time series data, such as stock market prices.Time series data refers to the sequence of past stock prices and other financial data, and LSTM can use this data to identify patterns and trends that can be used to predict future stock prices.LSTM is particularly useful in analyzing stock market data because it can handle data with multiple input and output timesteps.For example, a company's stock price may be influenced by various factors such as economic indicators, market trends, and company-specific news.These factors may have a direct or indirect impact on the stock price, and the LSTM model is able to capture these relationships and use them to make more accurate predictions.Overall, LSTM and time series analysis can be a powerful tools for investors who want to make informed investment decisions based on the analysis of stock market data (Gülmez, 2022b;Hu et al., 2021;Mehtab & Sen, 2020).
Metaheuristic algorithms are optimization techniques that can be used to optimize the hyperparameters of an LSTM model.These algorithms are beneficial because they can search for optimal hyperparameters more efficiently and effectively than traditional optimization methods.One benefit of using metaheuristic algorithms is that they can explore a larger search space and find the optimal global solution.Traditional optimization methods may get stuck in a local minimum and not find the best solution.In contrast, metaheuristic algorithms can escape from local minima and find the best solution across the entire search space.Another benefit of metaheuristic algorithms is their ability to handle complex and noisy data.LSTM models can have many hyperparameters, and finding the optimal values for these hyperparameters can be difficult due to the complex nature of the data.However, Metaheuristic algorithms are able to handle this complexity and noise and find the optimal hyperparameters even in these challenging situations (Gülmez, 2023b,a;Kumar & Haider, 2021;Öztürk, 2022).
ARO is a metaheuristic algorithm that is inspired by the behaviour of the rabbits in the nature.It is used to find approximate solutions to optimization and search problems.The basic idea is to use techniques inspired by survival strategies of rabbits, such as foraging, hiding, to generate new solutions to a problem.The solutions, which are often represented as strings of numbers or characters, are evolved over many generations through the application of these algorithm operators until an acceptable solution is found.ARO is a novel metaheuristic algorithm and can be used in a wide range of fields, including artificial intelligence, machine learning, and engineering (Gülmez, 2023a;Wang et al., 2022).
ARO algorithm can be used to optimize the hyperparameters of LSTM networks.Optimizing the hyperparameters of an LSTM network can be challenging, as many different parameters can be adjusted, including the number of layers, the number of neurons per layer, and the learning rate.However, a ARO algorithm can be used to optimize these hyperparameters by treating them as a set of variables in a search space.

Literature review
In the literature, there are lot of research on predicting stock prices.Some of them are listed below.Xie et al. (2021) attempted to solve the issue of typical offline neurofuzzy systems needing training data to fully reflect all system behaviors, which may be challenging owing to dramatic swings in data distributions.The authors developed a unique technique that combines a neurofuzzy system with the Hammerstein-Wiener model, establishing an indivisible five-layer network.The efficacy of the suggested model was examined on three financial stock datasets and found to outperform existing neuro-fuzzy systems and the standard Hammerstein-Wiener model.Li et al. (2020) investigated the predictability of investor sentiment in the Chinese stock market by utilizing online user-generated material to gauge sentiment and by comparing various text classification algorithms, price forecasting models, time horizons, and information update systems.The findings demonstrated that daily investor sentiment only provided predicted information for opening prices, but hourly investor sentiment provided two hours of predictive information for closing prices.This indicates that investors adjust their expectations during market hours.Chen et al. (2019) aimed to develop a stock market trend prediction model using an anticipatory computing approach and public mood and emotion data.The model was tested on a real-world stock market dataset and found to accurately predict stock market trends.Adhikari et al. (2021) proposed a hybrid deep learning model for stock price prediction using sentiment analysis and found that the model was able to improve prediction accuracy compared to traditional machine learning methods.This suggests that the use of deep learning techniques in combination with traditional machine learning approaches can lead to improved performance in stock price prediction.Rezaei et al. (2021) presented hybrid algorithms, CEEMD-CNN-LSTM and EMD-CNN-LSTM, which employ full ensemble empirical mode decomposition (CEEMD) and empirical mode decomposition (EMD) to extract deep features and time sequences for one-step-ahead stock price prediction.The results demonstrated that the combination of CNN, LSTM, and CEEMD or EMD improved prediction accuracy and beat other models.
Hammoudeh et al. (2021) used the nonparametric causality-inquantiles test to investigate the causal connections between oil prices and five clean energy stock indexes.During normal market circumstances, oil returns produced renewable stock index returns, but this was not the case during difficult market situations.Lower quantiles of the volatility study revealed the considerable bidirectional correlation between oil price volatility and renewable energy stock volatility.There were no substantial causal correlations between oil prices and renewable energy stocks during the COVID-19 epidemic.
Maguluri and Ragupathy (2020) used the Auto-Regressive Integrated Moving Average (ARIMA) model to forecast stock prices.Results showed that the model was effective in predicting future prices and forecasting the stock market.

Time series analysis
Time series analysis is a statistical method used to analyze data that is collected over a period of time.It involves examining the patterns and B. Gülmez trends in the data to make predictions about future events or to understand the underlying processes that are driving the data.Time series analysis can be used to forecast demand for a product, predict the stock market, or understand the trends in economic indicators such as unemployment or inflation.Time series models use past data to forecast future values and can be used to understand the underlying trends, seasonality, and noise in the data.Time series analysis can also be used to identify and forecast the impact of exogenous variables, such as changes in government policies or technological innovations, on the data.There are several factors that can impact a time series (Chatfield, 2003;Hamilton, 2020;Gülmez, 2021): Trend: A trend refers to the overall direction of the time series, whether it is increasing, decreasing, or stable over time.
Seasonality: Seasonality refers to the presence of repeating patterns in the data, such as spikes in sales during the holiday season.
Cyclicality: Cyclicality refers to the presence of longer-term patterns in the data, such as economic booms and busts.
Irregularity: Irregularity refers to random or unpredictable fluctuations in the data.
Exogenous factors: Exogenous factors are external factors that can affect the time series, such as economic policies, natural disasters, or social trends.

Ann
Artificial neural networks (ANNs) are computational models inspired by the structure and function of the human brain.They consist of layers of interconnected nodes or "neurons" that process and transmit information.Each neuron receives input from other neurons and applies a mathematical function to this input to produce an output.The output is then passed on to other neurons in the next layer (Gülmez & Kulluk, 2019).
The structure and function of ANNs can be adjusted through a process called training.During training, the network is presented with a set of inputs and their corresponding outputs, and the network adjusts its weights and biases to minimize the difference between its predicted output and the actual output.This process allows the network to "learn" and improve its performance on tasks such as classification, regression, and clustering (Askarzadeh & Rezazadeh, 2013).
A neuron, also known as a perceptron or processing element, is the fundamental unit of computation in an artificial neural network.It receives input from other neurons or external sources, processes the input using a set of weights and biases, and produces an output based on that processing.The processing occurs through the application of an activation function, which determines the output of the neuron based on the input and weights.Neurons are connected to each other in layers, with the input layer receiving external data and the output layer producing the final result of the network.The intermediate layers, known as hidden layers, process the data and pass it along to the next layer.Neurons within a layer are connected to every neuron in the next layer, allowing the network to learn complex relationships and patterns in the data (Gülcü, 2022).
There are several elements that make up a neuron in an ANN.These include (Krogh, 2008): Inputs: These are the data that are fed into the neuron, which are typically numerical values.
Weights: These are the values assigned to each input, which are used to determine the importance of that input in the overall calculation of the neuron.
Bias: This is a constant value that is added to the weighted sum of the inputs.
Activation function: This is a mathematical function that determines the output of the neuron based on the inputs and weights.The most common activation functions used in ANNs are sigmoid, tanh, and ReLU.
Output: This is the final result of the neuron's calculation, which is then passed on to other neurons in the network.
Error: This is the difference between the predicted output of the neuron and the actual output, which is used to adjust the weights and biases in order to improve the accuracy of the network.
A layer in an ANN is a group of interconnected neurons that work together to process and transmit information.There are typically multiple layers in an ANN, with the input layer receiving the raw data and the output layer producing the final result.Between the input and output layers are hidden layers, which are responsible for performing the necessary computations and transformations on the input data to produce the desired output.The number of hidden layers and the number of neurons in each layer can vary depending on the specific task the ANN is designed to perform.A layer can be seen in Fig. 1.

Lstm
LSTM is a type of artificial neural network designed to process sequential data, such as time series, audio, or text.It is particularly useful for processing data with long-term dependencies, where the output at a given time step depends on information from previous time steps.LSTM networks are able to remember this information over a longer period of time by using memory cells, input gates, output gates, and forget gates.These gates control the flow of information into and out of the memory cells, allowing the network to selectively store and retrieve information as needed.LSTMs are commonly used for tasks such as language translation, speech recognition, and stock price prediction.The elements of an LSTM network include (Gers et al., 2000;Yu et al., 2019): Input gate: Controls the flow of data into the memory cell.
Forget gate: Controls the flow of data out of the memory cell.
Output gate: Controls the output of the memory cell to the rest of the network.
Cell state: Stores the information in the memory cell.
Hidden state: Output of the LSTM unit, used to make predictions or pass information to the next LSTM unit.hiddenstate = ot*tanh(ct) (5)

Genetic algorithm (GA)
GA is a computational method that mimics the process of natural selection to find solutions to optimization and search problems.The idea behind it is to use a population of candidate solutions, called individuals, and repeatedly apply genetic operators such as selection, crossover (recombination), and mutation to generate new individuals.The new individuals are then evaluated using a fitness function that measures the quality of the solution.This process is repeated over multiple generations until an acceptable solution is found (Gülmez, 2023a;Gülmez & Korhan, 2021).
GA has three essential components (Alkafaween et al., 2021) It is worth noting that GA is a heuristic optimization method, and it is not guaranteed to find the optimal global solution, but it can provide a good solution with reasonable computational cost.However, it may be computationally intensive and time-consuming for large-scale problems, especially if the dataset is large and the training process is prolonged (Gülmez, 2022c).

Artificial rabbits optimization (ARO)
ARO is a novel algorithm created by Wang et al. (Wang et al., 2022).Rabbits are plant-eaters, feeding mainly on grass, forbs, and leafy weeds.They have evolved various survival strategies over time.One of their strategies is to avoid eating the grass close to their burrows to prevent predators from finding their nests.Rabbits have an extensive field of vision, with most of it devoted to overhead scanning, making it easier for them to find food over a large area.This strategy of foraging away from their nests is known as exploration and is reflected in the Chinese idiom "rabbits do not eat the grass near its own nest."Another strategy is random hiding.Rabbits are skilled at creating burrows to evade predators or hunters.They dig multiple burrows around their nest and select one randomly as a shelter from predators.With short forelegs and long back legs, rabbits can run quickly due to strong muscles and tendons.They can also abruptly stop while running, turn sharply, or even run back in a zigzag motion to confuse their enemies and increase their chances of survival.This strategy is called exploitation.Since rabbits are at the bottom of the food chain and have many predators, they must conserve energy to survive.To do this, they adaptively switch between detour foraging and random hiding based on their energy levels (Gülmez, 2022a;Wang, Cao, Zhang, Mirjalili, & Zhao, 2022).
ARO has two stages.They are detour foraging (exploration) and random hiding (exploitation).
When rabbits forage, they often go far away and ignore nearby grass.This behavior is called detour foraging.In ARO, each rabbit has its own region with grass and burrows.They randomly visit each other's regions to forage and may perturb around a food source.This means they update their position towards another rabbit in the swarm and add a perturbation.A model has been proposed to describe this behavior.
The candidate position of each rabbit at time t + 1 is v i (t + 1), while x i (t) is its position at time t.Other variables include n (rabbit population size), d (problem dimension), and T (maximal number of iterations).Perturbation and running length (L) aid in global search, with longer step sizes promoting exploration and shorter ones promoting exploitation.The mapping vector c helps randomly select search individuals to mutate.The running operator (R) simulates rabbit running behavior, probing the search space with sudden turns in random directions.Detour foraging enables rabbits to move to other regions, promoting the   6) perturbation helps avoid local extrema and perform the global search, while Eq. ( 8) generates longer steps during initial iterations and shorter steps later.Mapping vector c selects individuals for mutation during foraging.The running operator R simulates rabbit movements.Eq. ( 6) shows that search individuals explore by randomly searching for food based on the position of other rabbits.This unique behavior allows them to venture far from their own territory and discover new regions, ensuring global search capability in the ARO algorithm.
ARO uses random hiding to exploit the search space and avoid predators.Each rabbit generates d burrows around its nest in each dimension of the search space and chooses one at random to hide in.This helps reduce the risk of being preyed upon.The jth burrow of the ith rabbit is generated using the following equation: ) Rabbits create d burrows around themselves along each dimension of the search space to avoid predators.Eq. ( 12) shows how these burrows are generated.The hiding parameter, H, decreases linearly from 1 to 1/T over iterations, with a random perturbation.This causes the burrows to be generated in a larger neighborhood initially and gradually decrease as iterations progress.
A rabbit selects one of its d burrows for hiding using a random number b ir , and two random numbers r 4 and r 5 .The ith search individual updates its position towards this selected burrow according to Eq. ( 16).
The ith rabbit's position is updated after either detour foraging or random hiding as follows: Eq. ( 19) means that if the fitness of the candidate position of the ith rabbit is superior to its current position, it will move to the candidate position generated by either Eq. ( 6) or Eq. ( 16).
ARO rabbits switch from detour foraging to random hiding as the iterations progress, which is based on their energy level.The energy factor in ARO represents this switch from exploration to exploitation and is defined as Eq.(20).

Models
In this study, one ANN and five LSTM model are used.The LSTM models are LSTM1D, LSTM2D, LSTM3D, LSTM-GA, and the last and proposed model, the LSTM model optimized by ARO (LSTM-ARO).

Ann
Table 1 shows ANN architecture.The input layer has 20 neurons, and this is the input dimension of the network.The first dense layer has 10 neurons, this layer is fully connected to the input layer.The second dense layer also has 10 neurons, this layer is fully connected to the first dense layer.The dropout layer has a dropout rate of 0.5, this layer is applied between the second dense and the output layer.The output layer has 1 neuron, this is the output dimension of the network.It is fully connected to the dropout layer.This network takes an input of size and passes it through two dense layers, each with 10 neurons.In between the two dense layers, there is a dropout layer with a dropout rate of 0.5 which will randomly drop out 50% of the neurons from the second dense layer during training.Finally, the output of the dropout layer is passed through the output layer which has 1 neuron and produces the output of the network.

Lstm1d
Table 2 shows LSTM1D architecture.The first layer is the input layer, which has 20 nodes.The second layer is an LSTM layer, which has nodes.The third layer is a dense layer, which also has 10 nodes.The fourth layer is a dropout layer, which has a dropout rate of 0.5.The final layer is a dense layer with 1 node, which is an output layer.

Lstm2d
Table 3 shows LSTM2D architecture.It consists of four layers: an input layer, two LSTM layers, a dense layer, and a final dense layer with a dropout rate of 0.5.The input layer has 20 neurons, the first and second LSTM layers have 10 neurons each, the dense layer has neurons, and the final dense layer has 1 neuron.This architecture utilizes the sequential nature of LSTM layers to process input data, followed by dense layers for further feature extraction and dropout for regularization.The final dense layer with 1 neuron is used for output.

Lstm3d
Table 4 shows LSTM3D architecture.The architecture of the model consists of an input layer with 20 inputs, followed by three LSTM layers with 10 units each, a dense layer with 10 units, a dropout layer with a dropout rate of 0.5, and finally a dense layer with 1 unit as the output layer.

LSTM-GA and LSTM-ARO
Table 5 shows LSTM-GA and LSTM-ARO architectures.This neural network architecture consists of several layers, including an input layer with 20 neurons, and three LSTM layers with x 0 , x 2 and x 4 neurons, respectively.If the values of x 1 and x 3 is 0, these layers do not exist.The second and third layer is connected to variables.A dense layer with x neurons, a dropout layer with a dropout rate of x 6 , and an output layer with 1 neuron.X 0 , x 2 , x 4 , x 5 , x 6 values are variables from GA and ARO.Hyperparameter alternatives of the LSTM-GA and LSTM-ARO models are seen in Table 6.GA and ARO search and try to find best hyperparameters.
LSTM-ARO model can be seen in Fig. 2.

Dataset
DJIA is the abbreviation for Dow Jones,.It is the market for trading equities, bonds, and other securities in USA.
Yahoo Finance can be used to collect DJIA data from the internet.It is a financial news and data website that provides various financial data, including stock prices, market indices, exchange rates, and more.Python is used with Yahoo Finance API to access and download DJIA data for specific time periods (Garita, 2021;Yahoo Finance, 2023).
Price prediction has been made with time window sized 20 previous days.The input is prices of 20 days.The output is the price of the next day.The dataset time range is between 2018.01.01 and 2023.01.01.It is 5 years stock market data.80 percent of the data is used for training, 20 percent of the data is used for test.

Evaluation criteria
Evaluation criteria for regression models are used to measure the accuracy and effectiveness of the model in predicting the output values based on the input data (Gülmez, 2022a).
MSE is a measure of the difference between the predicted values and the actual values.It is calculated by taking the difference between the predicted and actual values and squaring them, then taking the average of all these squared differences.This value is used to assess the accuracy of the model, and the lower the MSE, the better the model.

MSE =
1 n MAE is another measure of the difference between the predicted and actual values.It is calculated by taking the absolute value of the difference between the predicted and actual values and taking the average of all these differences.This value is also used to assess the accuracy of the model and the lower the MAE, the better the model.
MAPE is a measure of the accuracy of a model that is expressed as a percentage.It is calculated by taking the absolute value of the difference between the predicted and actual values and dividing it by the actual value, then taking the average of all these percentages.This value is used to assess the accuracy of the model and the lower the MAPE, the better the model.
R2 score is a measure of how well a model fits the data.It is calculated by taking the sum of the squares of the differences between the predicted and actual values, dividing it by the sum of the squares of the differences between the mean of the actual values and the actual values, and then subtracting this value from 1.This value is used to assess the accuracy of the model and the closer it is to 1, the better the model.

Results
In this study, various algorithms, including LSTM1D, LSTM2D, LSTM3D, ANN, LSTM-GA, and optimized LSTM with ARO (LSTM-ARO) are tested on the DJIA stock dataset from 2018 to 2023.The results of these algorithms are then carefully analyzed and recorded.The aim is to determine which algorithm performs best in terms of accuracy and efficiency for predicting stock prices.The evaluation criteria used include MSE, MAE, MAPE, and R2 score.The results of the testing are crucial in determining the most effective approach for predicting stock prices in the DJIA market.
The proposed model LSTM-ARO gives successful results.The graphs of the results can be seen Fig. 3. Blue and dotted line is the real values, orange lines are predictions.The figure shows generally predictions are successful.Also, Fig. 4 shows LSTM-GA results, Fig. 5 shows LSTM1D results, Fig. 6 shows LSTM2D results, Fig. 7 shows LSTM3D results, and Fig. 8 shows ANN results.
For MSE evaluation criteria, the models are compared.The comparison and the results are seen in Table 7.The results appear to be a table of mean squared errors (MSE) for various ticker symbols and  Table 8 shows the MAE results of the models.The MAE is a measure of how accurate the predictions made by each model are, with lower values indicating better performance.It appears that in general, the LSTM-ARO model has the lowest MAE across most of the stocks, indicating that it is the most accurate model.However, it's important to notice that the results vary depending on the stock.Some stocks are better predicted by different models.
Table 9 shows the results of MAPE values for different stock tickers and different models.The MAPE is a measure of the prediction accuracy of a model, where a lower MAPE value indicates a better fit.From the table, it appears that the LSTM-ARO model generally has the lowest MAPE values across all tickers, followed by the ANN model.The LSTM1D, LSTM2D, and LSTM3D models generally have higher MAPE values, indicating lower prediction accuracy.
Table 10 shows the results of R2 score for each stock ticker, using different models.R2 is a measure of how well the model fits the data, where a score of 1.0 means a perfect fit and a score of 0 means the model does not explain any of the variance in the data.From the results, it appears that the LSTM-ARO model generally has the highest R2 scores, although there are some outliers where other models perform better.It is also worth noting that some of the models, such as LSTM1D and LSTM2D, have negative R2 scores for certain tickers, indicating that they are performing worse than a simple average of the data.Overall, it looks like the LSTM-ARO is the best model for fitting the data.
The paper proposes using various deep learning models, such as LSTM-ARO, ANN, LSTM1D, LSTM2D, and LSTM3D, to predict future stock market prices using the DJIA dataset.The results show that the LSTM-ARO model outperforms the other models in terms of MSE, MAE, MAPE, and R2 scores.This suggests that using ARO algorithm optimization in combination with LSTM is an effective approach for predicting stock market prices in this dataset.
Table 11 shows the time spent predicting DIAJ stocks' future prices.It is in second.ANN is the fastest algorithm.Then LSTM1D, LSTM-GA, LSTM-ARO, LSTM2D, and LSTM3D follow.LSTM-ARO and LSTM-GA algorithms are worked with 50 iterations and 50 population numbers.So, the total time of the response of the algorithms is 754,890 s (8.737 days) and 721,660 s (8.353 days).The total time is used only one time to get the best models.Then in a real dynamic trading system, the models will run one time per day.So, the execution times are about 5 min for the total of the DJIA stocks.It is so enough.

Conclusion
This paper proposes a new deep LSTM network optimized by the ARO algorithm.The proposed model is named LSTM-ARO.The aim of the proposed model is to predict stock market prices.DJIA index stock price data is used to predict stock market prices.The dataset consists of 30 different stock prices between 2018.01.01 and 2022.12.31.The period of the data is five years.The data is converted to a new format that has 20 previous days for predicting the next day's price.After converting to the new format, the data is split 80% as train data and 20% as test data.A novel LSTM network is created with parameters.The parameters are connected to the ARO algorithm variables.When the variables change, the LSTM architecture changes.ARO finds the best architecture to get the best results.To evaluate the quality of the new proposed model, it is compared with LSTM1D, LSTM2D, LSTM3D, ANN, and LSTM-GA networks.The results clearly show that the LSTM-ARO model is the best model among the models.And it gives very successful predictions.The predictions can assist traders or investors.
For future research, the prediction system can be improved.Alternative metaheuristic algorithms can be tried.This system can be integrated into a dynamic trading system or an automated stock market system.It is aimed to use the successful model of this paper in the dynamic trading system.So, future values of the stocks can be predicted with low error.The trading system can give successful buy/sell/keep suggestions.

Declaration of Competing Interest
The authors declare that they have no known competing financial interests or personal relationships that could have appeared to influence the work reported in this paper.
: Encoding: Each individual is encoded as a string of numbers or characters, called a chromosome.The encoding is chosen based on the specific problem being solved.Evaluation: The fitness function is used to evaluate the quality of the solution represented by each individual.The fitness function is designed based on the problem at hand.Evolutionary Operators: These operators are used to create new individuals from existing ones.The most commonly used operators are selection, crossover, and mutation.Selection is used to pick the best individuals to reproduce.Crossover is used to merge the chromosomes of two individuals to form a new individual.The mutation is used to introduce small random changes into the chromosomes of individuals.
global search capability of the algorithm.Eq. (

Table 1
ANN model architecture.Also optimizer and learning rate are other variables.GA and ARO find the best variable values for the architecture.

Table 5
LSTM-GA and LSTM-ARO architectures.The lower the MSE, the better the model is at predicting the true values.From the table, it can be seen that the LSTM-ARO model has the lowest MSE for most of the ticker symbols, indicating that it may be the best model for predicting the stock prices.

Table 7
Comparison of the models for MSE criteria.

Table 8
Comparison of the models for MAE criteria.

Table 9
Comparison of the models for MAPE criteria.