Next Article in Journal
A Class of Quasilinear Equations with Distributed Gerasimov–Caputo Derivatives
Previous Article in Journal
Integration of the Wang & Mendel Algorithm into the Application of Fuzzy Expert Systems to Intelligent Clinical Decision Support Systems
Previous Article in Special Issue
Neural Network-Based Modeling for Risk Evaluation and Early Warning for Large-Scale Sports Events
 
 
Font Type:
Arial Georgia Verdana
Font Size:
Aa Aa Aa
Line Spacing:
Column Width:
Background:
Article

Improving Stock Market Predictions: An Equity Forecasting Scanner Using Long Short-Term Memory Method with Dynamic Indicators for Malaysia Stock Market

1
Department of Computer Science, Universiti Tunku Abdul Rahman, Kampar 31900, Malaysia
2
Faculty of Computer Science and Information Technology, Universiti Malaya, Kuala Lumpur 50603, Malaysia
3
Department of Computer Science and Information Engineering, National Taipei University of Technology, Taipei 106344, Taiwan
4
Department of Information Systems, Universiti Tunku Abdul Rahman, Kampar 31900, Malaysia
*
Authors to whom correspondence should be addressed.
Mathematics 2023, 11(11), 2470; https://doi.org/10.3390/math11112470
Submission received: 5 May 2023 / Revised: 18 May 2023 / Accepted: 25 May 2023 / Published: 27 May 2023

Abstract

:
Stock market predictions are a challenging problem due to the dynamic and complex nature of financial data. This study proposes an approach that integrates the domain knowledge of investors with a long-short-term memory (LSTM) algorithm for predicting stock prices. The proposed approach involves collecting data from investors in the form of technical indicators and using them as input for the LSTM model. The model is then trained and tested using a dataset of 100 stocks. The accuracy of the model is evaluated using various metrics, including the average prediction accuracy, average cumulative return, Sharpe ratio, and maximum drawdown. The results are compared to the performance of other strategies, including the random selection of technical indicators. The simulation results demonstrate that the proposed model outperforms the other strategies in terms of accuracy and performance in a 100-stock investment simulation, highlighting the potential of integrating investor domain knowledge with machine learning algorithms for stock price prediction.

1. Introduction

Stock forecasting is a critical task for investors, financial analysts, and computer scientists. Accurate stock price predictions can help investors make informed trading decisions, resulting in significant benefits. However, stock price prediction is a complex problem due to the numerous variables that can affect stock prices, such as economic conditions, market trends, company news, and geopolitical events. Therefore, developing a reliable and accurate model for stock price prediction is a challenging task.
Traditional methods of stock price prediction, such as technical analysis, involve analyzing historical stock data manually to identify trading opportunities [1]. However, analyzing large amounts of data manually can be time-consuming and challenging for investors. To overcome these limitations, researchers have turned to machine learning techniques to help predict stock prices. Machine learning algorithms can handle vast amounts of complex data, identify hidden patterns, and reveal complex relationships that are difficult to detect manually.
Recent research has shown that combining machine learning algorithms with technical and fundamental indicators can improve stock price prediction efficiency by 60% to 80% [2]. However, most previous works lack flexibility and dynamism in their prediction models. Previous works have employed feature selection algorithms to filter out the most popular features, but this approach can result in input that is full of randomness and excludes essential technical indicators specific to a stock. Therefore, a better solution is to allow domain users, such as investors, to customize the prediction model using their preferred indicators as input parameters.
This paper aims to fill the gap in the stock price prediction model’s lack of flexibility and dynamism, enabling investors to make more meaningful predictions that will assist them in making informed trading decisions. In this paper, we propose a novel approach to stock forecasting using LSTM with dynamic indicators that incorporates investor domain knowledge and outperforms the traditional approach of randomly selecting technical indicators as input. We have conducted an extensive evaluation of the proposed model using a dataset of 100 stocks from the Malaysian stock market, demonstrating superior prediction accuracy, cumulative return, and risk performance compared to existing approaches. We provide evidence that integrating the domain knowledge of investors into the prediction model can significantly enhance the accuracy and performance of the model. We demonstrate the effectiveness of LSTM models in capturing the temporal dependencies and patterns in stock market data, enabling accurate and reliable forecasting.
The remaining sections of this paper are organized as follows: Section 2 will cover related work on machine learning algorithms used for equity forecasting; Section 3 will cover the design of the proposed model using the LSTM method; Section 4 will cover the experiments to evaluate the effectiveness of the proposed model; Section 5 will cover the results of the experiments for four different strategies: article model, buy-and-hold, optimistic model, and the proposed model; Section 6 will cover the discussion on the outcome of the proposed model; and Section 7 will cover the conclusion of this paper.

2. Related Works

In recent times, stock prices have become increasingly dynamic and volatile due to the easy availability of information through technology such as social media and online news. This has led to a greater number of reactions to stocks, resulting in high volatility in stock prices in the market. Predicting stock prices, therefore, heavily relies on the analysis of vast amounts of data, which is where machine learning comes into play. Machine learning algorithms such as evolutionary algorithms (e.g., genetic algorithms (GAs) [3]), artificial neural networks (ANNs), long-short-term memory (LSTM), and support vector machines (SVMs) are widely used as stock price prediction models [4,5].
In today’s dynamic and volatile stock markets, machine learning algorithms play a crucial role in predicting stock prices. Genetic algorithms (GAs), which are a type of evolutionary algorithm, are one such algorithm that has been widely used to optimize the combination of technical indicators for maximum trading profits.
A recent study [6] proposed a stock trading model based on optimized technical indicators using GAs. The authors used historical stock prices of Dow Jones’, New York, NY, USA, 30 stocks from 1997 to 2017 as training data to determine the best parameters for relative strength index (RSI) and simple moving average (SMA) combinations in the time series of the stocks. They then used these optimized technical indicators as input features in a deep neural network (DNN) to predict the buy and sell positions. The results showed that the GA+DNN model achieved 11.93% of the average annualized return of 30 stocks, which was better than the model that used random technical indicators. The GA was able to determine the important technical indicators that had yielded the highest results in the past and solved the difficulty of setting the hyperparameters for different stock indicators.
However, one limitation of this approach is that the selection of GA hyperparameters such as crossover rate and mutation rate should be determined carefully to avoid meaningless combinations of technical indicators. Furthermore, when a GA is used in the feature optimization process, more hyperparameters (GAs hyperparameters and neural networks’ hyperparameters) need to be fine-tuned during the training process, which requires more time.
Another study [7] used GAs to optimize the hyperparameters of different technical indicators for trading rules. They considered a total of six technical indicators with different meanings and adopted GAs to find a trading rule that had generated the highest profit in the past. The results showed that the derived strategies generated an average profit of 21% to 54% even though the index of the India Cement Stock Price Index (ICSPI), New Delhi, India, was decreasing during the validation period. However, this approach does not account for the movement behavior of stocks throughout history, which is important for investors’ decision-making. Therefore, it is better to include the optimized trading rules as input parameters for machine learning models to learn the movement behavior of stocks.
In conclusion, GAs have shown consistent results in finding the best hyperparameters of technical indicators for generating positive profits in the stock market. However, some limitations need to be addressed, such as the careful selection of hyperparameters and the consideration of stock movement behavior in the decision-making process.
In addition to GAs, artificial neural networks (ANNs) are also often used to predict stock prices. According to [8], the ANN model is the most commonly used machine learning model in stock price prediction. An ANN is designed to simulate the processing of information by human brain cells, which enables it to learn complex, nonlinear relationships between data. One limitation of an ANN is that it cannot detect the long-term dependency between historical prices.
In [9], the authors used ANNs to forecast the S&P 500 index, New York, USA, based on 60 financial and fundamental features (2003–2013 period). They used fuzzy c-means clustering (FCM) and principal component analysis (PCA) to reduce the complexity of the input data and extract the features that had a strong relationship with the stock index. PCA is a powerful unsupervised linear technique for feature extraction and dimension reduction, and FCM is a well-known data clustering technique. The pre-processed data was then supplied to ANNs to make predictions. The results showed that the introduction of PCA techniques not only reduced the complexity of the data but also increased the prediction accuracy of the ANN model. The maximum accuracy achieved was about 59%. The ANN model was also evaluated in a trading simulation to find out whether the high predictability of ANN models implies high returns in stock trading. The trading simulation results proved that incorporating PCA with ANNs generated higher returns than the benchmark technical analysis buy-and-sell strategy.
In [10], the authors used the National Association of Securities Dealers Automated Quotations (NASDAQ), New York, NY, USA, stock market index for 2017 and 2018 as training data. They considered both technical indicators and financial news as extra features in prediction, resulting in 151 to 611 dimensions in the input dataset. They used the synthetic minority over-sampling technique (SMOTE) to balance the label and the increasing window cross-validation method to preserve the time series behavior of the data during the validation process. They also introduced dropout layers in the ANN model to avoid overfitting issues. The results showed that the ANN model achieved between 50% and 68% accuracy on average, an 85.2% positive annualized return, and a 4.6% Sharpe ratio in the trading simulation. The strength of the approach proposed by this study is that the model not only considers technical, fundamental, and sentiment data from financial news but also focuses on retaining the time series behavior of stock prices during the validation process.
Overall, all the above ANN models have shown consistent results in both machine learning validation and trading simulation. To increase the overall performance of the stock prediction model, [9] applied feature engineering techniques such as FCM and PCA, while [10] balanced the label and retained the time series behavior of the data during the validation process. However, they have limitations, such as the inability of ANNs to detect long-term dependence between historical prices and the loss of information after applying PCA components to the technical indicators. To address these limitations, the LSTM algorithm can be used, as it can capture both non-linearity and sequential information in the data.
The LSTM is a powerful time series model that is derived from the recurrent neural network (RNN) structure [11,12]. Unlike RNNs, LSTM can memorize long-term sequential information by using extra memory lines and control gates, making it a suitable algorithm for time series problems such as stock prediction [13]. In the traditional RNN structure, the neural network concatenates the hidden layer output of the previous time step (ht−1) with the input of the next time step (xt), and these procedures are repeated until the latest time frame of input data is reached. However, the RNN structure has a limitation in that it is not able to store long-term memory and tends to put more emphasis on recent memory, resulting in difficulty in capturing long-term dependencies in the data. LSTM solves this problem by having extra gates that control the information stored in memory, allowing it to decide which past information is valuable in making predictions and thus memorizing long-term dependencies in the data. Figure 1 illustrates the working procedure of a single unit of LSTM.
Each time-step Xt−1, Xt, and Xt+1 will go through the LSTM unit that is named “A”. Each time step will result in hidden state outputs ht−1, ht, and ht+1, respectively, and all-time steps will go through the same unit. The hidden state output produced at each time step would also be brought to another time step so that the time dependency could be learned by the model. LSTM is suitable for any problem that involves sequential information, such as stock forecasting, traffic prediction [15], etc.
Two papers have been reviewed that compare the performance of LSTM and ANNs in the stock forecasting domain. [16] conducted research on combining optimal technical indicators with LSTM in stock prediction and compared the performance of LSTM with that of ANN and SVM models. The results show that using optimal technical indicators produces promising results, with the highest accuracy of 64% achieved by LSTM. In comparison with other models, LSTM outperformed other models when supplied with relevant input parameters, reducing its complexity, and increasing its performance. [17] conducted comprehensive research that compared the performance of LSTM, ANNs, and uncertainty-aware attention (UA) in stock price prediction using different types of market environments. The results showed that LSTM and UA models performed better than ANNs in developing and less developed markets, where time series algorithms are more suitable for handling such data.
In both papers, evaluating the algorithm in the stock forecasting problem is divided into two methods: machine learning evaluation and trading simulation evaluation. Prediction accuracy is calculated in machine learning evaluation, while in trading simulation evaluation, the model is evaluated as a trading system, and popular portfolio metrics such as percentage return and risk metrics (Sharpe ratio, Sortino ratio, and maximum drawdown) are calculated to measure the overall trading portfolio performance.
In conclusion, the previous literature has shown that technical indicators alone are insufficient for accurate stock trend prediction, with state-of-the-art performance typically ranging from 50% to 70% [18,19,20,21]. As such, it is essential to explore other data sources to improve the accuracy of stock forecasting. In our proposed method, we aim to integrate the domain knowledge of investors with an LSTM algorithm to improve its overall performance for predicting stock prices.

3. Methods

Figure 2 shows the process of obtaining the optimal LSTM model for the proposed model.
The design of the proposed model involved nine stages (see Figure 2) to determine the optimal LSTM model. Many possible technical indicator combinations will be used to study and obtain the optimal LSTM model so that the proposed model can closely simulate the real-world situation where many investors will use different indicator combinations as the input to the real-time model. Thus, the goal is to determine the optimal LSTM model that can accommodate and achieve averagely promising results across all 100 stocks with different types of input indicator combinations. Each stage of the process of obtaining the optimal LSTM model for the proposed model is discussed as follows:

3.1. Data Collection

The development of a prediction model starts with collecting stock data from historical prices of the selected stock using the Yahoo Finance API provided by the Python (Python Software Foundation, Fredericksburg, Virginia) platform. This data includes the open, close, high, low, volume, and adjusted closing prices of 100 selected stocks listed on Bursa Malaysia, Kuala Lumpur, Malaysia, (see Table 1) from the beginning of the listing to 30 June 2022.
In addition, the data between 1 January 2019 and 30 June 2022 will be used for the simulation, while the remaining data (before 1 January 2019) will be used as a model training dataset. A feature expansion will then be carried out based on this data. One crucial aspect of feature expansion is calculating 22 technical indicators: exponential moving average, simple moving average, sum over period, minimum in period, maximum in period, Aroon, Adx, moving average convergence divergence, momentum, commodity channel index, relative strength index, Williams %R, price rate-of-change, stochastic relative strength index, volatility ratio, standard deviation, variance, standard error, on-balance volume, Bollinger bands, volume oscillator, and linear regression, which can be customized by the investor based on their preferences (see Table 2).
However, calculating technical indicators manually using code is both time-consuming and inefficient. To address this issue, Python (Python Software Foundation, Fredericksburg, Virginia) offers the Ta-lib library, which can automatically generate the necessary technical indicator values by calling a function. Utilizing the Ta-lib library can help avoid human errors in the calculation process and save significant time in model development.

3.2. Correlation Analysis and Data Labeling

To further improve the accuracy of the model, it is necessary to analyze the correlation between the selected features and the stock closing prices. This correlation analysis will help identify the features that have a strong influence on stock prices and exclude those that are not significantly correlated. By reducing the number of input features, the noise present in the data can be minimized, and the dimension of the data can be reduced, which is an important step in developing a robust prediction model.
After the correlation analysis, the data labeling process will be carried out, which is crucial in formulating the stock trend prediction problem as a binary classification problem. The labeling condition defined in Equation (1) will be used to label the data as “up” or “down” based on the forecast horizon and the previous day’s closing price.
L a b e l 2 C L ( P i ) = U p , i f ( C t + s C t ) C t > 0 D o w n , i f ( C t + s C t ) C t 0
The selected window size and forecast horizon will determine the time frame used for prediction. For example, if the window size is set to 5 and the forecast horizon is set to 1, the model will use the first five days’ stock prices to predict the close price of the sixth day. If the close price of the 6th day is higher than that of the 5th day, then the data will be labeled “up”, otherwise “down”. It is worth noting that since text cannot be included in the calculation during the model training, “1” will be used to represent “up” and “0” will be used to represent “down”.

3.3. Data Pre-Processing and Time Series Transformation

After data labeling, the next step is to scale the data into the range of 0 to 1 using Min-Max scaling. This is important, as neural networks tend to perform better with data that have a standardized range [22]. However, it is crucial to compute the scaling factors on the training set only and then apply the transformation to both the training and testing sets. Some beginners mistakenly computed the scaling factors using the whole dataset as training data without separating the dataset into training data and test data individually. It will lead to a look-ahead bias in the model and make the result less reliable when tested on unseen data if the test data is part of the training data used to compute the scaling factors. To prevent such bias, the dataset will be divided into a training set and a test set in a 70:30 ratio. Algorithm 1 shows the pseudocode of the dataset separated into train data and test data.
Algorithm 1 Pseudocode of the Data Separating into Train Data and Test Data
var x_train = [];//fetched data from the beginning of listing to 30 June 2022
for (let i = 0; i < x_train.length; i++) {
   x_train_new.push(x_train[i].slice(0, Math.round(x_train[i].length × 0.7)));
   x_test_new.push(x_train[i].slice(Math.round(x_train[i].length × 0.7),
   x_train[i].length + 1)); }
y_train_new.push(label.slice(0, Math.round(label.length × 0.7)));
y_test_new.push(label.slice(Math.round(label.length × 0.7), label.length + 1));
last_train_date = dateStock[Math.round(dateStock.length × 0.7) − 1];
dateStock = dateStock.slice(Math.round(dateStock.length × 0.7), dateStock.length + 1)
for (let i = 0; i < indicator.length; i++) {
   ind_train_new.push(indicator[i].slice(0, Math.round(indicator[i].length × 0.7)));
   ind_test_new.push(indicator[i].slice(Math.round(indicator[i].length × 0.7), indicator[i].length + 1)); }
The scaling factors will be calculated based on the training set and then applied to both sets. Additionally, a time-series transformation will be applied as LSTM networks require input in 3D format: sample, time-step, and variable. As shown in Figure 3, the first dimension represents the number of samples, the second dimension represents the number of time steps, and the last dimension represents the number of variables in each time step. The number of time steps and horizons used in the proposed model are 2 and 1, respectively.

3.4. LSTM Model Training and Model Evaluation

After the input data has been pre-processed, the LSTM model training will begin, followed by evaluation using the testing data. The evaluation process will involve two stages, namely machine learning evaluation and trading evaluation. In the machine learning evaluation, the prediction accuracy of the LSTM model on the testing data will be computed. Additionally, the predicted result score will be divided into buy (greater than or equal to 0.7), hold (between 0.3 and 0.7), and sell (less than or equal to 0.3). So, if the predicted score is greater than or equal to 0.7, the predicted result will be marked as 1 (recommend to buy); otherwise, it will be marked as 0 (not recommended to buy). In contrast, the trading evaluation will involve evaluating the LSTM model as a trading system, where a “buy” operation will be made if the model predicts an “up” trend at any moment during the testing data, and the return on investment will be calculated. Portfolio evaluation metrics such as cumulative return, Sharpe ratio, and maximum drawdown will be calculated to measure the performance of the proposed model in a stock trading simulation. Additionally, the LSTM model’s trading performance will be compared with the buy-and-hold and optimistic strategies, which are the most fundamental strategies used in the stock market. The buy-and-hold strategy involves buying the stock at the beginning of the testing data period and selling it at the end of the period [23], while the optimistic strategy buys the stock at the current time step and sells it at the next time step if the current stock price is higher than the previous stock price, expecting the stock price to continue to increase in the future. The performance of the proposed model is expected to outperform these two strategies. After the evaluation process, the results, including prediction accuracy and trading simulation performance, will be presented to users. Additionally, by comparing the performance of the proposed model with these two strategies, users can gain a better understanding of the strengths and weaknesses of the model. Figure 4 and Figure 5 illustrate the buy-and-hold and optimistic strategies, respectively.
Overall, the proposed model aims to provide reliable predictions and perform better than traditional buy-and-hold and optimistic strategies, as shown through the evaluation process. Algorithm 2 shows the pseudocode of the evaluation process.
Algorithm 2 Pseudocode of the Evaluation Process
var time_step = 2, horizon = 1, npcheck = [],npcheck_percent = [],checksum = 0,
  checksum_percent = 0, optimistic = 0, count_operation_done = 0;
var decision_buy = [...y_pred];//computed from Algorithm 3
var actual_close = x_test_new[3].slice(time_step − 1, x_test_new[3].length)
for (let i = 0; i < decision_buy.length; i++) {
if (i + horizon < actual_close.length) {
   if (decision_buy[i] == 1) {
     count_operation_done++;
     checksum += (actual_close[i + horizon]) − (actual_close[i]);
     checksum_percent += ((actual_close[i + horizon]) − (actual_close[i]))/
      (actual_close[i]);
     npcheck.push((actual_close[i + horizon]) − (actual_close[i]));
     npcheck_percent.push(((actual_close[i + horizon]) − (actual_close[i]))/
     (actual_close[i])); }
   if (i − 1 > 0) {
     if ((actual_close[i]) > (actual_close[i v 1])) {
       optimistic += (actual_close[i + 1]) − (actual_close[i]); } } } }
var avg_return = (checksum/count_operation_done);
var avg_return_percent = (checksum_percent/count_operation_done);
var std_return = getStandardDeviation(npcheck);
var std_return_percent = getStandardDeviation(npcheck_percent);
var sharpe_ratio = (avg_return/std_return) × Math.sqrt(252);
var sharpe_ratio_percent = (avg_return_percent/std_return_percent) × Math.sqrt(252);
var Buy_hold = (actual_close[actual_close.length − 1] − actual_close[0]);

3.5. Fine-Tuning

In this stage, the model training process and model evaluation process will be repeated multiple times with different combinations of indicators as model input so that an architecture design of the LSTM model that works well, in general, can be determined. The model will be further fine-tuned to find out the best hyperparameters, such as the number of time steps, forecast horizon, and decision threshold. After multiple runs of fine-tuning, the optimal model architecture will be determined based on the number of indicators selected by the investor. During the fine-tuning process, a combination of technical indicators that work well will be obtained. The proposed model will rank each of the combinations based on their prediction accuracy.

3.6. System Architecture and Design of the Proposed Stock Prediction Model

The proposed stock prediction model’s system architecture design is illustrated in Figure 6, with the output size of each phase represented by a gray box. The input data will be in the form of a time series, as shown in Figure 3.
The model consists of different types of layers, starting with the first hidden layer, which is an LSTM layer with 64 units. The LSTM layer, also known as the RNN layer, will learn the time-series dependency present in the data. Each time step in each input data set will go through all 64 LSTM units, resulting in an output size of (number of samples = m, 64). 64 represents the number of hidden state outputs accumulated from the first-time step to the last time step in each sample.
The activation function used in the LSTM layer is the rectified linear unit (ReLU), which will output the input directly if it is positive; otherwise, it will output zero (see Equation (2)).
f x = m a x 0 , x
On the other hand, the initial weight of each neuron is assigned using a uniform distribution (see Equation (3)). The a and b are denoted as the minimum value and maximum value, respectively.
f x = 1 b a
Next, the data will be passed to the dropout layer, where 5% of the LSTM hidden nodes will be turned off randomly during each training operation to increase the generalization capability of the model and reduce overfitting issues. Finally, the data will be passed to the dense layer with 32 neurons. The purpose of adding a fully connected layer (FC) is to perform classification learning based on the LSTM hidden state data. The activation function used in the LSTM layer is ReLU. The proposed model is an improvement over previous models, which only used the LSTM layer to learn the temporal features and time dependency of the data but did not include any layers for the classification learning.
The output of the dense layer consists of one neuron. The activation function used is a sigmoid function, which will always return a value between 0 and 1, return a value close to zero for a small value, and return a value close to 1 for a large value (see Equation (4)).
s i g m o i d x = 1 1 + e x
The proposed LSTM+FC layer model can learn and extract temporal features using the LSTM layer and learn the classification of data using the FC layer. The final output of the model will be in the form of probabilities, and the model will predict the data as “1” if the probability is greater than the threshold and “0” otherwise. The Adam optimizer is used in this training model to update the weight during the training. The set learning rate and epochs for the Adam optimizer are 0.001 and 100, respectively.
The n, y and ŷ are denoted as the number of the data points, the actual label of the data point, and the predicted probability of the data point, respectively. The binary cross-entropy (BCE) method (see Equation (5)) will be used as a loss function to evaluate the predictive and target output values during the training.
f x = 1 n i = 1 n y i · log y ^ i + 1 y i · log 1 y ^ i
The binary accuracy (BA) method (see Equation (6)) will be used as a metric in this LSTM model to calculate the percentage of predicted values that match the actual values of the binary labels.
f x = 0 , T P + T N T P + T N + F P + F N < 0.5 1 , T P + T N T P + T N + F P + F N 0.5
The true positive (TF), true negative (TN), false positive (FP), and false negative (FN) are denoted as correctly indicating the presence of a condition, correctly indicating the absence of a condition, wrongly indicating a condition is present, and wrongly indicating a condition is absent, respectively. Overall, the proposed stock prediction model is designed to learn from time-series data using LSTM and FC layers, with the aim of accurately predicting the direction of the stock price movement. The model’s output will be probabilities, which can be used to make informed trading decisions. Algorithm 3 shows the pseudocode of the data transformation to a time series.
Algorithm 3 Pseudocode of the Data Transformation to a Time Series
//Creating the LSTM Model
var time_step = 2, horizion = 1;
var x_train_scaled = [];//min max normilzation
const model = tf.sequential();
model.add(tf.layers.lstm({ units: 64, activation: ‘relu’, inputShape: [time_step,
  (x_train_new_scaled.length + ind_train_new_scaled.length)], returnSequences: false }))
model.add(tf.layers.dropout({ rate: 0.05 }));
model.add(tf.layers.dense({ units: 32, activation: ‘relu’ }));
model.add(tf.layers.dense({ units: 1, activation: ‘sigmoid’ }));
//Compiling the model
model.compile({
    optimizer: tf.train.adam(0.001),
    loss: tf.metrics.binaryCrossentropy,
    metrics: tf.metrics.binaryAccuracy });
model.fit(x, y, {
    batchSize: xtrain.length,
    epochs: 100,
    verbose: 2
}).then(async(history) => {
    var y_hat = [],y_pred = [];
   //convert it to array
    const values = model.predict(xt).dataSync();
    const y_score = Array.from(values);
   //today prediction
    today.print();
    const valuest = model.predict(today).dataSync();
    var y_scoret = Array.from(valuest);
    y_score.forEach((data, index) => {
    if (data >= 0.7) {
     y_pred.push(1);
    } else {
     y_pred.push(0); }
})
const testacc = model.evaluate(xt, yt);
var count_acc_70 = 0;
y_pred.forEach((data, index) => {
    if (y_pred[index] == ytest[index]) {
     count_acc_70++; }
})
const accuray = [count_acc_70/y_pred.length];

4. Experiments

To evaluate the effectiveness of the proposed model, a simulation was conducted to predict the price movement of 100 stocks between 1 January 2019 and 30 June 2022. The model training data did not include stock data between 1 January 2019 and 30 June 2022, to avoid look-ahead bias and allow the proposed model to make predictions based on unseen data. The evaluation of the proposed model was based on four performance metrics: prediction accuracy, cumulative return, Sharpe ratio, and maximum drawdown. The simulation process also compared the performance of the proposed model strategy with the buy-and-hold strategy, the optimistic strategy, and the prediction method used in a previous article [16], which selected random indicators and applied feature extraction to filter the best-voted features for training. To account for the random initialization of some LSTM algorithm parameters, such as the weight of nodes in each gate, three simulation rounds were conducted per stock to obtain the average accuracy rate and average trading performance. Figure 7 illustrates the simulation procedure for testing the proposed model’s prediction accuracy and trading performance.

5. Results

5.1. Average Prediction Accuracy Rate Results for the Simulation

After running simulations for all 100 stocks, the results were presented and compared using several performance metrics. Figure 8 displays the average prediction accuracy distribution of the 100 stocks for four different strategies, and Table 3 shows the statistics of the accuracy rate of the 100 stocks for four different strategies.
The blue curve represents the proposed model, and each blue dot on the graph represents the average model accuracy of a specific stock. The proposed model achieved at least 50% accuracy for all 100 stocks, which indicates it has passed the first part of the test. Furthermore, the proposed model outperformed the other three strategies, achieving the highest average accuracy rate of around 57%. The prediction approach used in the article [16] obtained an average accuracy of 54% and a minimum accuracy of 39%, which is less than 50%. Therefore, the proposed model is better than the prediction approach used in the article [16]. The buy-and-hold and optimistic strategies achieved significantly lower accuracy rates than the proposed and article models because they lacked statistical analysis. Therefore, machine learning models are expected to outperform these strategies.

5.2. Average Cumulative Return Results for the Simulation

After evaluating the prediction accuracy rate, the proposed model was assessed from a trading perspective. Figure 9 displays the average cumulative return distribution for the 100 stocks under each of the four strategies, along with a summary table, and Table 4 shows the statistics of the cumulative return of the 100 stocks for the four different strategies.
The black line in the graph represents the zero cumulative return boundary, where values below it denote a negative cumulative return. Ideally, the graph should skew towards positive returns, indicating profitable trades. As shown in Table 2, 90% of the stocks under the proposed model simulation achieved positive cumulative returns, while the buy-and-hold, optimistic, and article models only had 41%, 30%, and 59% of the stocks with positive returns, respectively. This suggests that the proposed model outperforms the other strategies. Additionally, the proposed model recorded the highest average cumulative return of 29% across the 100 stocks, with the lowest maximum capital losses among the strategies, amounting to only about 40% of profits.

5.3. Average Sharpe Ratio and Maximum Drawdown Results for the Simulation

In addition to accuracy and cumulative return, the proposed model was also evaluated based on risk performance using the Sharpe ratio and maximum drawdown distribution. Figure 10 shows the Sharpe ratio distribution of the 100 stocks, and Table 5 shows the statistics of the Sharpe ratio of the 100 stocks for four different strategies.
It indicates that the proposed model outperformed the other strategies, achieving a high Sharpe ratio value of 1.83. Figure 11 shows the maximum drawdown distribution, and Table 6 shows the statistic of the maximum drawdown of the 100 stocks for four different strategies.
It indicates that the proposed model is the least risky strategy, with an average maximum drawdown value of around −0.18 (−18%). Overall, the results indicate that the proposed model is the most reliable and effective strategy compared to the buy-and-hold, optimistic, and article models, with high accuracy, a positive cumulative return, a high Sharpe ratio, and low maximum drawdown values. These results demonstrate the potential of the proposed model for predicting stock prices and supporting trading decisions.

6. Discussion

The simulation results indicate that the proposed model is superior to the prediction approach used by the previous work’s method, which randomly selected technical indicators. The proposed model achieved the highest average prediction accuracy among the strategies, around 57%, with a maximum accuracy of around 74%. While 57% may not seem satisfactory, it is difficult to evaluate the model’s success based on prediction accuracy alone, as it can still achieve a higher investment return if the capital gains from correct predictions are higher than the capital losses from incorrect predictions. Therefore, the proposed model was also evaluated as a trading system using a trading simulation.
The overall portfolio performance comparison between the four strategies shows that the proposed model is the best strategy. It achieved the highest average cumulative return of around 29% across 100 stocks, with a positive cumulative return for 90 stocks, outperforming the previous work’s approach. This is clear evidence that the proposed model can detect the stock movement that leads to high returns. The proposed method also has the lowest risk as measured by the Sharpe ratio and the maximum drawdown. The Sharpe ratio of 1.83 indicates a return of 1.83% per unit of risk taken, while the maximum drawdown of only −18% indicates that the proposed method and strategy experienced the lowest risk in history. Table 7 shows the comparison of the experiment results among the related works and the proposed model.
According to the article model, the average accuracy among the support vector machine, logistic regression, embedded layer LSTM, and optimal LSTM models (article model) is 52.03%, 52.98%, 55.53%, and 59.26%, respectively, using the three Indian stocks [16]. However, the average accuracy of the article model is 41% using 100 stocks in Malaysia, which is 17% lower compared to the article result. On the other hand, the average accuracy of the proposed model is greater than that of the support vector machine, logistic regression, and embedded layer LSTM in the article [16]. In addition, the proposed method has a better performance compared to the CNN + LSTM model and joint learning + LSTM model in article [25], which obtained 51.32% and 55.44%, respectively, of the prediction accuracy. Other than LSTM algorithms, such as ANN, SVM, random forest, etc., in articles [24,26], greater than 70% prediction accuracy was obtained, which is far better than the LSTM performance result.
In conclusion, the proposed model is an effective approach for stock prediction and trading, with superior performance compared to other strategies. It achieved high prediction accuracy and high investment returns while minimizing risks. The simulation results validate the proposed model’s effectiveness in predicting and trading stocks, making it a promising tool for investors and traders in the stock market.

7. Conclusions

In conclusion, this study has provided evidence that involving investors in the data input process can lead to more meaningful stock predictions and trading strategies. By integrating domain knowledge with machine learning techniques, such as the LSTM algorithm, the proposed approach achieved superior results compared to the previous work’s approach of randomly selecting technical indicators. The higher average prediction accuracy, cumulative return, and lower trading risk demonstrated the effectiveness of this approach in detecting stock movements that lead to high returns.
This study highlights the importance of incorporating domain knowledge and the limitations of relying solely on machine learning techniques. Randomly selecting technical indicators as input data could introduce noise and overlook significant indicators, leading to suboptimal performance. Therefore, this approach has the potential to improve the accuracy of prediction models in other domains that require domain knowledge and expertise.
The limitation of this study is that it only performed well in bullish stocks but not in bearish stocks. Therefore, we aimed to investigate and improve the model so that it can generalize well to all stocks, regardless of their future state. On the other hand, this study only tested 100 Malaysian stocks with historical data and 22 technical indicators. The proposed model can be further studied using remaining Malaysian and foreign stocks with additional fundamental indicators, sentiment analysis (e.g., financial news), the gross domestic product index, etc. In this study, prediction accuracy and accumulative return profit are used as evaluation metrics. However, this study does not cover the root-mean-square deviation, mean absolute percentage error, median absolute error, precision, receiver-operating characteristic analysis, etc. Therefore, those metrics should be covered in future studies.
Future studies could further improve the proposed model by allowing investors to customize fundamental indicators such as the PE ratio and EPS. This would provide additional domain knowledge and increase the model’s accuracy in detecting significant movements in the stock market. Additionally, future research could explore the use of other machine learning techniques and their potential integration with domain knowledge to further improve stock prediction and trading strategies.

Author Contributions

Conceptualization, C.S.K., Y.-L.C. and L.Y.P.; methodology, C.S.K. and J.X.; validation, C.S.K., L.Y.P., S.D.C. and H.C.S.; formal analysis, S.D.C. and Y.-L.C.; investigation, C.S.K. and Y.-L.C.; resources, C.S.K., H.C.S. and S.D.C.; data curation, S.D.C. and J.X.; writing—original draft preparation, Y.-L.C. and L.Y.P.; writing—review and editing, Y.-L.C., L.Y.P., H.C.S., C.S.K. and J.X.; visualization, Y.-L.C., C.S.K. and H.C.S.; supervision, C.S.K.; project administration, L.Y.P. All authors have read and agreed to the published version of the manuscript.

Funding

This research was funded by the National Science and Technology Council in Taiwan, grant numbers NSTC-109-2628-E-027-004–MY3, NSTC-111-2218-E-027-003, and NSTC-111-2622-8-027-009, and the Ministry of Education of Taiwan, official document number 1112303249.

Data Availability Statement

Data used for this paper is publicly available on https://sg.finance.yahoo.com/ (accessed on 24 May 2023) and collected using yfinance 0.2.18 (Yahoo! Finance’s API in Python platform) which is available on https://pypi.org/project/yfinance/ (accessed on 24 May 2023).

Conflicts of Interest

The authors declare no conflict of interest.

References

  1. Sawale, G.J.; Rawat, M.K. Stock Market Prediction using Sentiment Analysis and Machine Learning Approach. In Proceedings of the 2022 4th International Conference on Smart Systems and Inventive Technology, Tirunelveli, India, 20–22 January 2022. [Google Scholar]
  2. Li, L.; Wu, Y.; Ou, Y.; Li, Q.; Zhou, Y.; Chen, D. Research on machine learning algorithms and feature extraction for Time Series. In Proceedings of the 2017 IEEE 28th Annual International Symposium on Personal, Indoor, and Mobile Radio Communications, Montreal, QC, Canada, 8–13 October 2017. [Google Scholar]
  3. Wu, T.-Y.; Li, H.; Chu, S.C. CPPE: An Improved Phasmatodea Population Evolution Algorithm with Chaotic Maps. Mathematics 2023, 11, 1977. [Google Scholar]
  4. Chhajer, P.; Shah, M.; Kshirsagar, A. The applications of artificial neural networks, support vector machines, and long–short term memory for stock market prediction. Decis. Anal. J. 2022, 2, 100015. [Google Scholar] [CrossRef]
  5. Wu, M.-E.; Syu, J.-H.; Chen, C.-M. Kelly-based options trading strategies on settlement date via supervised learning algorithms. Comput. Econ. 2022, 59, 1627–1644. [Google Scholar] [CrossRef]
  6. Sezer, O.B.; Ozbayoglu, M.; Dogdu, E. A deep neural-network based stock trading system based on evolutionary optimized technical analysis parameters. Procedia Comput. Sci. 2017, 114, 473–480. [Google Scholar] [CrossRef]
  7. Naik, R.L.; Ramesh, D.; Manjula, B.; Govardhan, A. Prediction of Stock Market Index Using Genetic Algorithm. Comput. Sci. Inf. Syst. 2012, 3, 162–171. [Google Scholar]
  8. Nti, I.K.; Adekoya, A.F.; Weyori, B.A. A systematic review of fundamental and technical analysis of stock market predictions. Artif. Intell. Rev. 2019, 53, 3007–3057. [Google Scholar] [CrossRef]
  9. Zhong, X.; Enke, D. A comprehensive cluster and classification mining procedure for Daily Stock Market Return Forecasting. Neurocomputing 2017, 267, 152–168. [Google Scholar] [CrossRef]
  10. Picasso, A.; Merello, S.; Ma, Y.; Oneto, L.; Cambria, E. Technical analysis and sentiment embeddings for market trend prediction. Expert Syst. Appl. 2019, 135, 60–70. [Google Scholar] [CrossRef]
  11. Kader, A.; Izzati, N. A Review of Long Short-Term Memory Approach for Time Series Analysis and Forecasting. In Proceedings of the 2nd International Conference on Emerging Technologies and Intelligent Systems, 2–3 September 2022. [Google Scholar]
  12. Kumar, S.; Damaraju, A.; Kumar, A.; Kumari, S.; Chen, C.-M. LSTM Network for Transportation Mode Detection. J. Internet Technol. 2021, 22, 891–902. [Google Scholar] [CrossRef]
  13. Moghar, A.; Hamiche, M. Stock market prediction using LSTM recurrent neural network. Procedia Comput. Sci. 2020, 170, 1168–1173. [Google Scholar] [CrossRef]
  14. Understanding LSTM Networks. Available online: https://colah.github.io/posts/2015-08-Understanding-LSTMs/ (accessed on 23 May 2023).
  15. Zhang, S.M.; Su, X.; Jiang, X.-H.; Chen, M.L.; Wu, T.Y. A traffic prediction method of bicycle-sharing based on long and short term memory network. J. Netw. Intel. 2019, 4, 17–29. [Google Scholar]
  16. Agrawal, M.; Khan, A.U.; Shukla, P.K. Stock Price Prediction using Technical Indicators: A Predictive Model using Optimal Deep Learning. Int. J. Recent Technol. Eng. 2019, 8, 2297–2305. [Google Scholar] [CrossRef]
  17. Gao, P.; Zhang, R.; Yang, X. The application of stock index price prediction with neural network. Math. Comput. Appl. 2020, 3, 53. [Google Scholar] [CrossRef]
  18. Joiner, D.; Vezeau, A.; Wong, A.; Hains, G.; Khmelevsky, Y. Algorithmic Trading and Short-term Forecast for Financial Time Series with Machine Learning Models; State of the Art and Perspectives. In Proceedings of the 2022 IEEE International Conference on Recent Advances in Systems Science and Engineering, Tainan, Taiwan, 7–10 November 2022. [Google Scholar]
  19. Kurani, A.; Doshi, P.; Vakharia, A.; Shah, M. A Comprehensive Comparative Study of Artificial Neural Network (ANN) and Support Vector Machines (SVM) on Stock Forecasting. Ann. Data Sci. 2023, 10, 183–208. [Google Scholar] [CrossRef]
  20. Hu, Z.; Zhao, Y.; Matloob, K. A Survey of Forex and Stock Price Prediction Using Deep Learning. Appl. Syst. Innov. 2021, 4, 9. [Google Scholar] [CrossRef]
  21. Sheth, D.; Shah, M. Predicting stock market using machine learning: Best and accurate way to know future stock prices. Int. J. Syst. Assur. Eng. Manag. 2023, 14, 1–18. [Google Scholar] [CrossRef]
  22. Weckman, G.; Lakshminarayanan, S. Identifying Technical Indicators for Stock Market Prediction with Neural Networks. In Proceedings of the IIE Annual Conference, Houston, TX, USA, 15–19 May 2004. [Google Scholar]
  23. Nelson, D.M.; Pereira, A.C.; de Oliveira, R.A. Stock market’s price movement prediction with LSTM neural networks. In Proceedings of the 2017 International Joint Conference on Neural Networks, Anchorage, AK, USA, 14–19 May 2017. [Google Scholar]
  24. Bustos, O.; Pomares, A.; Gonzalez, E. A comparison between SVM and multilayer perceptron in predicting an emerging financial market: Colombian stock market 2017. In Proceedings of the 2017 Congreso Internacional de Innovacion y Tendencias en Ingenieria, Bogota, Colombia, 4–6 October 2017. [Google Scholar]
  25. Liu, Y.; Zeng, Q.; Yang, H.; Carrio, A. Stock Price Movement Prediction from Financial News with Deep Learning and Knowledge Graph Embedding. In Proceedings of the 15th Pacific Rim Knowledge Acquisition Workshop, Nanjing, China, 28–29 August 2018; pp. 102–113. [Google Scholar]
  26. Sakhare, N.N.; Shaik, I.S.; Saha, S. Prediction of stock market movement via technical analysis of stock data stored on blockchain using novel History Bits based machine learning algorithm. IET Softw. 2022. [Google Scholar] [CrossRef]
Figure 1. Single unit of an LSTM cell (folded and unfolded) [14]: (a) recurrent neural networks have loops; (b) the repeating module in an LSTM contains four interacting layers.
Figure 1. Single unit of an LSTM cell (folded and unfolded) [14]: (a) recurrent neural networks have loops; (b) the repeating module in an LSTM contains four interacting layers.
Mathematics 11 02470 g001
Figure 2. Process of obtaining the optimal LSTM model for the proposed model.
Figure 2. Process of obtaining the optimal LSTM model for the proposed model.
Mathematics 11 02470 g002
Figure 3. Time series input format.
Figure 3. Time series input format.
Mathematics 11 02470 g003
Figure 4. Illustration of the buy-and-hold strategy.
Figure 4. Illustration of the buy-and-hold strategy.
Mathematics 11 02470 g004
Figure 5. Illustration of an optimistic strategy.
Figure 5. Illustration of an optimistic strategy.
Mathematics 11 02470 g005
Figure 6. System architecture and design of the stock prediction model.
Figure 6. System architecture and design of the stock prediction model.
Mathematics 11 02470 g006
Figure 7. Simulation of the prediction test procedure for the proposed model.
Figure 7. Simulation of the prediction test procedure for the proposed model.
Mathematics 11 02470 g007
Figure 8. Average accuracy results for 100 stocks for four different strategies.
Figure 8. Average accuracy results for 100 stocks for four different strategies.
Mathematics 11 02470 g008
Figure 9. Average cumulative return of 100 stocks for four different strategies.
Figure 9. Average cumulative return of 100 stocks for four different strategies.
Mathematics 11 02470 g009
Figure 10. Average Sharpe ratio of 100 stocks for four different strategies.
Figure 10. Average Sharpe ratio of 100 stocks for four different strategies.
Mathematics 11 02470 g010
Figure 11. Average maximum drawdown of 100 stocks for four different strategies.
Figure 11. Average maximum drawdown of 100 stocks for four different strategies.
Mathematics 11 02470 g011
Table 1. A list of the 100 selected stocks listed on Bursa Malaysia.
Table 1. A list of the 100 selected stocks listed on Bursa Malaysia.
Stock Listing Code in Bursa Malaysia (.KL)
6888.KL5225.KL6033.KL5139.KL5210.KL5398.KL7153.KL5236.KL5279.KL4588.KL
1023.KL1961.KL4065.KL5099.KL1818.KL0078.KL5878.KL3069.KL5288.KL5005.KL
7277.KL2445.KL8869.KL2488.KL2852.KL2291.KL6633.KL5286.KL7155.KL5292.KL
6947.KL1155.KL1295.KL1015.KL2836.KL0208.KL5284.KL9385.KL8664.KL6963.KL
3182.KL6012.KL1066.KL6399.KL7204.KL5102.KL3859.KL0138.KL5211.KL0097.KL
4715.KL3816.KL4197.KL8176.KL1619.KL3255.KL5264.KL5258.KL5176.KL5246.KL
3034.KL5296.KL5285.KL5106.KL7148.KL3301.KL5014.KL7160.KL7106.KL7293.KL
5168.KL4707.KL4863.KL1562.KL5222.KL5227.KL1171.KL7084.KL6139.KL4677.KL
5819.KL5183.KL5347.KL5248.KL3689.KL3336.KL3867.KL5218.KL5031.KL5109.KL
1082.KL5681.KL7113.KL4162.KL0128.KL0166.KL1651.KL4731.KL5148.KL6742.KL
Table 2. A list of indicators used for the proposed model.
Table 2. A list of indicators used for the proposed model.
IndicatorsFormula
Exponential Moving
Average
f c , N = p r i c e c 2 ( N + 1 ) + f c 1 , N ( 1 2 ( N + 1 ) )
Simple Moving Average f N = 1 N i = 1 N p r i c e i
Sum Over Period f c , N = i = 0 N 1 p r i c e c i
Minimum In Period f c , N = m i n [ p r i c e c , p r i c e c 1 , , p r i c e c N + 1 ]
Maximum In Period f c , N = m a x [ p r i c e c , p r i c e c 1 , , p r i c e c N + 1 ]
Aroon f u p c , N = N m a x [ p r i c e c , p r i c e c 1 , , p r i c e c N + 1 ] N 100
f d o w n c , N = N m i n [ p r i c e c , p r i c e c 1 , , p r i c e c N + 1 ] N 100
Average Directional
Index
h + D I ( c , N ) = i = c N 1 ( h i g h i h i g h i 1 ) i = c N 1 ( h i g h i h i g h i 1 ) N + ( h i g h c h i g h c 1 ) a v e r a g e   t r u e   r a n g e 100
h D I c , N = i = c N 1 ( l o w i 1 l o w i ) i = c N 1 ( l o w i 1 l o w i ) N + ( l o w c 1 l o w c ) a v e r a g e   t r u e   r a n g e 100
g ( c , N ) = h + D I ( c , N ) h D I ( c , N ) h + D I ( c , N ) + h D I ( c , N )
f c , N = a v g [ g c 1 , , g ( c N ) ] ( N 1 ) + g ( c ) N
Moving Average
Convergence Divergence
f c , N 1 , N 2 = g c , N 1 g ( c , N 2 )
g c , N = p r i c e t 2 ( N + 1 ) + f c 1 , N ( 1 2 ( N + 1 ) )
Momentum f c , m = c l o s e c c l o s e c m
Commodity Channel
Index
f N = g N h ( N ) 0.015 i = 1 n g N h ( N ) n N
g N = i = 1 N h i g h i + l o w i + c l o s e i 3
h N = 1 N i = 1 N p r i c e i
Relative Strength Index f c , N = 100 100 1 a v g [ g a i n c , , g a i n c N + 1 ] ( N 1 ) + g a i n c a v g [ l o s s c , , l o s s c N + 1 ] ( N 1 ) + l o s s c
Williams %R f c , N = m a x [ p r i c e c , , p r i c e c N + 1 ] c l o s e c m a x [ p r i c e c , , p r i c e c N + 1 ] m i n [ p r i c e c , , p r i c e c N + 1 ]
Price Rate-Of-Change f c = p r i c e c p r i c e c 1 1 100
Stochastic Relative Strength Index f c , N = g c , N m i n [ g c , N , , g c N + 1 , N ] m a x [ g c , N , , g c N + 1 , N ] m i n [ g c , N , , g c N + 1 , N ]
g c , N = 100 100 1 a v g [ g a i n c , , g a i n c N + 1 ] ( N 1 ) + g a i n c a v g [ l o s s c , , l o s s c N + 1 ] ( N 1 ) + l o s s c
Volatility Ratio f c , N = m a x [ h i g h c l o w c , h i g h c c l o s e c 1 , c l o s e c 1 l o w c ] g ( c , N )
g c , N = p r i c e c 2 ( N + 1 ) + f c 1 ( 1 2 ( N + 1 ) )
Standard Deviation f x , N = i = 1 N ( x i x ) 2 N 1
Variance f ( x , N ) = i = 1 N ( x i x ) 2 N
Standard Error f x , N = i = 1 N ( x i x ) 2 N 1 N
On-Balance Volume f c = f c 1 + v o l u m e , c l o s e c > c l o s e c 1 0 , c l o s e c = c l o s e c 1 v o l u m e , c l o s e c < c l o s e c 1
Bollinger Bands f u p N = g N + k h ( N )
f d o w n N = g N k h ( N )
g N = 1 N i = 1 N h i g h i + l o w i + c l o s e i 3
h N = i = 1 N h i g h i + l o w i + c l o s e i 3 h i g h + l o w + c l o s e 3 2 N 1
Volume Oscillator f N 1 , N 2 = g N 1 g ( N 2 )
g N = 1 N i = 1 N v o l u m e i
Linear Regression Y = a + b X
N = number of days within a period; m = m days ago; c = current; k = number of standard deviations; a = intercept (the value of Y when X = 0); b = the slope of the line; X = the explanatory variable; Y = the dependent variable.
Table 3. Statistics of the accuracy rate of the 100 stocks for four different strategies.
Table 3. Statistics of the accuracy rate of the 100 stocks for four different strategies.
StrategyAccuracy Rate
MeanMax.Min.St. Dev.Skew.Kurt.
Proposed model0.570.74500.0451.292.72
Article model0.540.70390.053−0.060.75
Buy-and-hold0.410.48230.045−1.433.04
Optimistic model0.490.72410.0392.1010.32
Table 4. Statistics of the cumulative return of the 100 stocks for four different strategies.
Table 4. Statistics of the cumulative return of the 100 stocks for four different strategies.
StrategyCumulative Return (%)Number of Stock
MeanMax.Min. St. Dev.Skew.Kurt.Positive
Return
Negative
Return
Proposed model29372−4043.153.8222.949010
Article model10119−7035.110.661.325941
Buy-and-hold12409−9474.162.9312.064159
Optimistic model−3343−8057.852.7212.483070
Table 5. Statistics of the Sharpe ratio of the 100 stocks for four different strategies.
Table 5. Statistics of the Sharpe ratio of the 100 stocks for four different strategies.
StrategySharpe Ratio
MeanMax.Min.St. Dev.Skew.Kurt.
Proposed model1.836.44−6.140.045−0.402.88
Article model0.494.27−4.580.053−0.422.08
Buy-and-hold0.091.51−1.380.045−0.291.10
Optimistic model−0.412.27−4.280.039−0.15−0.12
Table 6. Statistics of the maximum drawdown of the 100 stocks for four different strategies.
Table 6. Statistics of the maximum drawdown of the 100 stocks for four different strategies.
StrategyMaximum Drawdown
MeanMax.Min. St. Dev.Skew.Kurt.
Proposed model−0.18−0.600.000.045−1.070.68
Article model−0.28−0.720.000.053−0.55−0.14
Buy-and-hold−0.46−0.96−0.140.045−0.720.46
Optimistic model−0.40−0.87−0.100.039−0.530.10
Table 7. Comparison of the experiment results among the related works and the proposed model.
Table 7. Comparison of the experiment results among the related works and the proposed model.
ArticleMethodsDatasetElementTrain, Validate and Test Data RatioDataset RecordsAccuracy
[16]SVM3 Indian stocks6 technical indicatorsN/A2 years52.03%
Logistic regression52.98%
Embedded layer LSTM55.53%
Optimal LSTM59.26%
[9]ANNTechnical indicators and fundamental indicators
S&P 500 Index ETF (SPY) return
60 financial and economical features70%:15%:15%377 days58.1%
[24]ANN25 Colombian Stocks9 technical indicators75%:0%:25%372 days76%
SVM78%
[25]Tf-idf algorithm feature extraction + SVMAAPL on S&P 5005 fundamental and 4 technical indicators80%:0%:20%1467 days49.17%
joint learning feature extraction + SVM54.92%
CNN feature extraction + SVM45.60%
CNN feature extraction + LSTM51.32%
joint learning feature extraction + LSTM55.44%
[26]Decision TreeNIFTY 50 Indian stock market index75 technical indicators70%:0%:30%4977 days75.08%
Naïve Bayes71.26%
Multi-Layer Perceptron76.02%
Random Forest80.44%
SVM78.63%
History Bits87.36%
Proposed modelLSTM100 Bursa Malaysia stocks22 technical indicators70%:0%:30%>3000days (depend on the stock listing date)57%
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content.

Share and Cite

MDPI and ACS Style

Ku, C.S.; Xiong, J.; Chen, Y.-L.; Cheah, S.D.; Soong, H.C.; Por, L.Y. Improving Stock Market Predictions: An Equity Forecasting Scanner Using Long Short-Term Memory Method with Dynamic Indicators for Malaysia Stock Market. Mathematics 2023, 11, 2470. https://doi.org/10.3390/math11112470

AMA Style

Ku CS, Xiong J, Chen Y-L, Cheah SD, Soong HC, Por LY. Improving Stock Market Predictions: An Equity Forecasting Scanner Using Long Short-Term Memory Method with Dynamic Indicators for Malaysia Stock Market. Mathematics. 2023; 11(11):2470. https://doi.org/10.3390/math11112470

Chicago/Turabian Style

Ku, Chin Soon, Jiale Xiong, Yen-Lin Chen, Shing Dhee Cheah, Hoong Cheng Soong, and Lip Yee Por. 2023. "Improving Stock Market Predictions: An Equity Forecasting Scanner Using Long Short-Term Memory Method with Dynamic Indicators for Malaysia Stock Market" Mathematics 11, no. 11: 2470. https://doi.org/10.3390/math11112470

Note that from the first issue of 2016, this journal uses article numbers instead of page numbers. See further details here.

Article Metrics

Back to TopTop