Open access peer-reviewed chapter - ONLINE FIRST

Stock and Futures Market Prediction Using Deep Learning Approach

Written By

Min-Hsuan Fan, Jing-Long Huang and Mu-Yen Chen

Submitted: 28 February 2023 Reviewed: 14 December 2023 Published: 28 March 2024

DOI: 10.5772/intechopen.114116

Investment Strategies - New Advances and Challenges IntechOpen
Investment Strategies - New Advances and Challenges Edited by Gabriela Prelipcean

From the Edited Volume

Investment Strategies - New Advances and Challenges [Working Title]

Dr. Gabriela Prelipcean and Dr. Mircea Boscoianu

Chapter metrics overview

26 Chapter Downloads

View Full Metrics

Abstract

In recent years, numerous studies have been devoted to predict the price fluctuations of financial markets. Taiwan 50 Exchange Traded Funds (ETF) is one of the important indicators to measure the volatility of the component stocks of the Taiwan 50 Index. With the development of the financial market, the trading volume of Taiwan Stock Index Futures is also increasing. The three markets play the important roles of economic development in the Taiwan. This study predicts the trend of Taiwan 50 ETF and Taiwan index futures applying machine learning and deep learning approaches which have excellent data exploration capabilities. This study applies the support vector regression (SVR), artificial neural networks (ANN), recurrent neural network (RNN), and long short-term memory network (LSTM) to predict the trend of the Taiwan stock market. This study uses various financial and technical factors as inputs, and extract variables from the factors affecting Taiwan’s economy to build models, and compares the benefits between models to explore future market.

Keywords

  • deep learning
  • machine learning
  • stock market
  • foreign exchange market
  • technical indices

1. Introduction

Stock market prediction has been commonly regarded as a challenging topic. Various econometric or statistical models were widely used in the prior studies [1, 2]. Although the prediction of stock market returns is a non-linear problem, many studies have proved that the non-linear models are not necessarily superior to the linear models [3, 4, 5]. Moreover, the linear technical indices are proved to help investors make investment strategies to improve investment performance. Zhu et al. used the variable moving average (VMA) on the basis of the moving average (MA) to successfully predict the stock price trends of Shanghai Stock Exchange Composite Index (SSEC) and the Shenzhen Stock Exchange Component Index (SZSE) [6].

Recent studies used the machine learning methods to solve the non-linear problems to capture the fluctuation of stock price. Chen and Hao proposed the hybridized framework of the feature weighted support vector machine (FWSVM) and the feature weighted K-nearest neighbor (FWKNN) to effectively predict the stock market indices of the SSEC and the SZSE [7]. They found that that these models can achieve a better prediction capability to both the SSEC and the SZSE in the short, medium and long term. Paiva et al. embedded support vector machine into an investment decision to predict the São Paulo Stock Exchange Index (Ibovespa) [8]. However, machine learning would require taking a lot of time in feature extraction, regularizing the extracted features, and then interpreting the roles through the expert knowledge.

Compared with the machine learning, deep learning autonomously regularizes the information features to reduce many steps in the machine learning process, and thus greatly saving labor costs and time. Recurrent neural network (RNN) which is on approach of deep learning approach is specifically suitable for dealing with the time series issues. Chen et al. proposed a hybrid model combining the RNN and the adaptive boosting (AdaBoost) to predict the stock indices, where the experiment results showed that the model has good prediction performance [9].

Taiwan 50 Exchange Traded Funds (ETF) was founded by the Yuanta Funds in 2003, consisting of 50 largest stocks by market value of the Taiwan Stock Exchange Corporation (TSEC). The Taiwan Stock Exchange Index Futures (FITX) was first launched by the Taiwan Futures Exchange (TAIFEX) in 1998, targeting on the weighted stock index issued by the TSEC, and changing in accordance with the fluctuation of the weighted stock index. The FITX has always been the largest trading commodity in Taiwan’s future market. This study applies the support vector regression (SVR), the artificial neural networks (ANN), the RNN and the long short-term memory network (LSTM) to predict the trend of the Taiwan stock market. The trained models are not only used to predict the fluctuation trend of the stock market, but also compared to decide which one has the best performance. In this study, the Taiwan 50 ETF and the FITX are taken as the study samples. This study calculates the technical indices based on the stock data provided by the Taiwan Economic Journal (TEJ).

The remainders of this study are organized as follows. The literatures are reviewed in the Section 2. In Section 3, this study develops data collection and research models. Section 4 describes the experiment results and performance evaluation. The Section 5 concludes this work.

Advertisement

2. Literature review

2.1 Stock market and foreign exchange market

The three major institutional traders in Taiwan stock market refer to the foreign investors, the investment trusts and the dealers. Foreign investors specifically refer to the investors of the foreign stock markets except Taiwan, the investment trusts stand for the securities investment companies, and the dealers shall be the securities companies certified by the government to use their own company capital to trade on the TSEC. Wang analyzed the impact of institutional investors’ sentiment on the stock market trading, and used four volatility models to analyze the stocks on the American Stock Exchange (AMEX) [10]. They found that the institutional investors take lower investment risks when they are pessimistic; on the contrary, they are take higher risks when they are optimistic about the stock market.

The foreign exchange market is a financial market distributed among countries to trade currencies. Except for the holidays and major festivals, the foreign exchange markets continuously operate and trade various currencies throughout the day. The foreign exchange rates fluctuate complexly as the foreign exchange market would be affected by various external factors, making it not easy to predict the currency exchange rates. Yong et al. proposed the Gaussian mixture model initialized neuro fuzzy (GMMINF) model to predict the exchange rates of the Australian dollar, the euro and the British pound against the US dollar, and obtain good prediction results at the closing price [11]. Henryíquez and Kristjanpoller suggested a hybrid model of an independent component analysis in combination with the neural network to predict the exchange rates of the euro, the British pound, the Japanese dollar, the Swiss franc and the Canadian dollar against the US dollar, where the results showed that the accuracy of the proposed hybrid model is higher than other econometric models [12].

2.2 Technical indices

Grodinsky proposed fundamental analysis and technical analysis to analyze the stock market price. Investors can use the fundamental analysis to evaluate the firm value or predict the fluctuation of the financial market through the economic theories and the financial statements analysis [13]. The fundamental indicators include earnings per share (EPS), price-to-earnings ratio (PER), price-book ratio (PBR), earnings before interest and tax (EBIT) and return on equity (ROE). Bunea et al. used the linear regression model to observe the financial statements of 1253 firms in Romania, where the results showed that the asset turnover and the PER have the greatest impact on the stock return [14]. Lončarski and Vidovič used the principal component analysis (PCA) to analyze the financial statements of the companies in the S & P 500 index, where the profitability, the growth prospects and the risk can be effectively reflected through the analysis of the financial statements [15].

The technical analysis was originated from the Dow Theory of Robert [16], where the theory proposed that the stock prices will fluctuate with the stock market. Elliott subsequently suggested the Elliott Wave Theory, explaining that the end time of the trend can be predicted [17]. Afterwards, Granville mentioned the moving average, providing the basis for most of the technical indices [18]. Common technical indices are also the moving average convergence diversity (MACD), the relative strength index (RSI) and the stochastic oscillator (KD).

Lin used 14 technical indices calculated to predict the fluctuation of the stock market, and regression analysis was used to analyze their relationship [19]. He found that the technical analysis can significantly improve the predictability of the stock price from the investment portfolio. Jiang et al. used the technical indices and macroeconomic characteristics as the inputs, and used the decision tree algorithms and deep learning to predict the S & P 500, the Dow 300 and the Nasdaq 100 indices, where the results showed that these models have achieved good performance [20]. Picasso et al. used 10 technical indices from the Nasdaq 100 index and the financial news related to the Nasdaq 100 index from the Intrinio API, where the emotional features were extracted from the texts, and were further combined with the technical indices as the training variable inputs to the Random Forest, SVM, feed forward neural network models [21]. The results showed that the proposed method can effectively classify the uptrend and downtrend in the stock portfolio.

2.3 Support vector regression

Machine learning is an innovative method combining statistics and computer science, by which allows the machine to learn from the past data and experience, find out the rules and make its learning as smart as the human beings. Nowadays, it has become popular in various application fields, such as visual images, natural language processing, search engine, voice handwriting recognition, data exploration and securities market analysis and prediction. In terms of securities market analysis and prediction, Patel et al. compared four models trained by the artificial neural network, the SVM, the Random Forest and the Bayesian in combination with the technical indices, where the results showed that the Random Forest has higher accuracy than the other models [22]. Lee et al. proposed the financial network index of investment strategy, using the logical regression, the SVM and the Random Forest, which justified that the proposed scheme can effectively predict the fluctuation of the stock market, specifically with the best performance in the short-term investment [23].

The support vector machine (SVM) was derived by Vapnik and Chervonenkis [24]. It is a supervised learning algorithm combined with classification and regression. In this study, the support vector regression (SVR), an extension of the SVM, is used. SVR has the capable of processing continuous data, and is suitable for deal with the time series data of stocks. Lahmiri used the SVR to analyze the stock data of a listed personal computer company, and the results showed that the accuracy of the model trained by the SVR is higher than other fundamental analysis models [25]. Mishra and Padhy selected 92 stocks in the Indian stock market, and used SVR to predict the stock market prices, where the results showed that the predicted prices are close to the actual prices, and the investment transactions of the selected stocks have high returns [26].

2.4 Artificial neural network and deep learning

Artificial neural network (ANN) is one kind of the machine learning, and simulates the human brain to make judgment. Rezaee et al. integrated the Fuzzy C-Means, the data envelopment analysis and the ANN to analyze the listed company data of the Tehran Stock Exchange (TSE) in Iran, where the results showed this method can help investors make decisions fast [27]. Wang et al. combined price volatility network with ANN to predict the copper price in the New York Mercantile Exchange (NYMEX), where the results showed that the proposed hybrid technology is more accurate than the traditional neural network in terms of the price prediction [10].

Deep learning extends from ANN, the continuously increases its hidden layers in addition to the input layer, the hidden layer and the output layer constituting the traditional ANN. LeCun et al. [28] proposed convolutional neural network (CNN) to process pictures, while Williams and Zipser [29] proposed RNN to deal with texts. Gunduz et al. [30] used the CNN to predict the stock price of the Borsa Istanbul Stock Exchange (BIST) in Turkey, where the results showed that it can successfully capture the hourly fluctuation of the stocks. Xu et al. used the RNN to classify the features of China Securities Index 300 (CSI 300) [31]. Chen et.al proposed a hybrid model combined with the RNN and the adaptive boosting to predict the CSI 300 Index, where the results showed that the hybrid model is superior to ANN and SVR [9].

The long short-term memory (LSTM) is an artificial recurrent neural network (RNN) architecture. The first RNN was proposed by Williams and Zipser [29]. When the first sequence of the RNN is performing the output operation, an additional set of vector information is also being output concurrently as the input to the subsequent sequence point. Therefore, the second sequence point have the previous sequence point and its own set of vector information. These two sets of vector information are subject to certain calculation before being output, which means that in addition to the latest information, the RNN model would simultaneously receive the previous information to achieve the effect of memory. Nevertheless, the RNN has one drawback—although this model has the effect of memory, it cannot keep long-term memory but only short-term memory. To resolve the aforesaid problem, Hochreiter and Schmiduber proposed an artificial neural network named LSTM [32]. The biggest difference between the LSTM and the RNN lies that the LSTM has many cell states, which can receive the long-term memories of the past. Fischer and Krauss used the LSTM, an ANN for sequence learning, to predict the S & P 500 index, where the results showed that the accuracy of the model was higher than that of the machine learning [33]. Cao et al. proposed a hybrid model combined with the empirical mode decomposition (EMD) and the LSTM to predict the stock prices using four stock market indices in the United States, where the results showed that the proposed model performs better than the fundamental analysis model [34].

Advertisement

3. Research methodology

According to prior literature, this study chooses the technical indices, the institutional investor and the foreign exchange market of Taiwan 50 ETF and the Taiwan Stock Exchange Index Futures (FITX), and then reduce these data dimensionalities to create the input variables. After training by the SVR, ANN, RNN and LSTM respectively, this study obtains the best model to predict the stock price fluctuation, and further verify the accuracy of each model to judge which model has high accuracy for the stock prediction.

3.1 Research framework

This study classifies each of Taiwan 50 ETF and the FITX into its own control group and experimental group. The control group is the fundamental data, while the experimental group includes the foreign exchange, the major institutional traders and the technical index. This study investigates the correlation of the research object against its own individual inputs, select the best model by analyzing the training results, use the best model to predict the price fluctuation of the research objects, and then evaluate the performance of the model. The details for the experimental design are illustrated in the following Figures 1 and 2.

Figure 1.

The experimental design for Taiwan 50 ETF.

Figure 2.

The experimental design for FITX.

3.2 Datasets collection

This study use the data of Taiwan 50 ETF, the FITX, the foreign exchange rate, the technical indices and the three major institutional traders. The research period is from 2015 to 2018.

All data related to the Taiwan 50 ETF and the FITX come from TEJ database. According to Cao et al. [34], Xu et al. [31] as well as Mishra and Padhy [26], we use the opening price, the highest price, the lowest price and the closing price for the Taiwan 50 ETF and the FITX.

For the exchange rates of the foreign exchange market, this study uses the six foreign currencies are converted to the TWD in terms of the cash exchange rate and the spot exchange rate respectively, thereby a total of 12 variables. According to Yong et al. [11] and Baffour et al. [35], the exchange rates of the euro, the British pound and the US dollar were selected as the variables. The renminbi (CNY), the Japanese yuan (JPY) and the Hong Kong dollar (HKD) circulating in the regions near Taiwan are also included.

For the technical index, this study also applies eight parameters from KD, MACD and RSI. Jiang et al [20] and Picasso et al. [21] suggested that KD, MACD and RSI are important technical indexes. The eight parameters include RSV, K, D, EMA12, EMA26, DIF, MACD and RSI.

For the three major institutional traders, the data come from the TAIFEX, and include six variables. The three major institutional traders are defined as the dealers, the investment trusts and the foreign investors. Only the long and short trading volumes of the three institutional traders are selected as the input variables of the model. This study only selects trading volume because that the trading volume positively correlates with the contract value.

3.3 Dimensionality reduction and feature selection

All data are subject to the dimensionality reduction suggested by Noryani et al. [36] and normalization according to Cao et al. [34] before using as the inputs of the models.

To avoid decrease the accuracy of model, we adopt the stepwise regressions that for dimensionality reduction. The selection criterion is the group with the largest value of adjusted R square. In the models, we use current dependent variables, but use lagged independent variables. Finally, we select 53 variables, including 13 variables for the opening prices of the Taiwan 50 ETF, 14 variables for the closing prices of the Taiwan 50 ETF, 13 variables for the opening prices of the FITX, and 13 variables for the closing prices of the FITX.

Regarding the Taiwan 50 ETF, the variables of opening prices refer to five variables related to foreign exchanges (HKD, GBP, EUR, JPY, and CNY), two variables related to three major institutional traders (Long trading volumes of the foreign investors and short trading volumes of the dealers), and six variables related to technical indices (EMA26, MACD, EMA12, RSI, RSV, and D). This study adds USD into the variables of closing prices of the Taiwan 50 ETF, others are similar to the opening prices of the Taiwan 50 ETF.

Regarding the FITX, the variables of opening prices refer to fix variables related to foreign exchanges (HKD, GBP, EUR, JPY, CNY and USD), two variables related to three major institutional traders (Long trading volumes of the foreign investors and short trading volumes of the dealers), and five variables related to technical indices (MACD, EMA12, RSI, RSV, and D). The variables for closing prices of the FITX are the same as for opening prices of the FITX.

Advertisement

4. Experimental results and performance evaluation

4.1 Experimental environment

The experimental environment of this study was developed under the Windows 10 system (i7 CPU, 16G RAM); the application was programmed with the Python, while the stepwise regression analysis in the SPSS (Statistical Product and Service Solutions) was selected to perform the dimensionality reduction of the data; the free value-added open source version of Anaconda software was used to create the artificial intelligence model, under which the Tensorflow environment was established; the Keras kit was used to create the models with the ANN, the RNN and the LSTM, while the machine learning model was built with the Scikit-Learn kit to create the SVR model.

4.2 Parameters setting and performance evaluation index

This study chooses the linear kernel function with the C (cost) adjusted to 10 and the learning rate of kernel algorithm adjusted to 0.001. Except for the kernel function, the other parameters were tested by trial and error method. The ANN is divided into four layers, one of which was the input layer, two the hidden layers, and one the output layer. The number of iterations is 200. This study uses the adaptive moment estimation (ADAM) as the optimizer and the MAE in the Loss equation with the learning rate 0.001 and the activation function Linear. All the parameter settings are also tested by trial and error method.

In the RNN model, there are five layers, one of which was the input layer, two the RNN layers, one the fully connected layer, and one the output layer. The number of layers is set according to Jiang et al. [20]. The number of iterations is 200. We select the ADAM as the optimizer and the MAE in the Loss equation with the learning rate 0.001 and the time step 3. The activation function of the RNN layer is Tanh, and the activation function of the output layer is Linear. All the parameter settings are tested by trial and error method.

In the LSTM model, there are also five layers, one of which was the input layer, two the LSTM layers, one the fully connected layer, and one the output layer. The number of layers is set according to Cao et al. [34]. The number of iterations is 200. Again, we select the ADAM as the optimizer and the MAE in the Loss equation with the learning rate 0.001 and the time step 3. The activation functions of the LSTM layer are Sigmoid and Tanh, and output layer activation functions is Linear. All the parameter settings are tested by trial and error method.

This study selects the mean absolute error (MAE), the mean square error (MSE) and the mean absolute percent error (MAPE) as the evaluation indices, where the formulas are listed as follows:

MAE=1ni=1nyiŷE1
MSE=1ni=1nyiŷ2E2
MAPE=1ni=1nyiŷyiE3

Where yi is the actual value, ŷ the predicted value, n the total number of data, i a certain amount of data. The smaller the values of MAE, MSE and MAPE are, the better the accuracy of the predictive model.

4.3 Experimental results

In the experimental results of this study, the mean absolute error (MAE), the mean square error (MSE) and the mean absolute percent error (MAPE) were selected as the evaluation indices of the model, where the smaller the values of MAE, MSE and MAPE are, the better the accuracy of the predictive model.

Tables 14 show the results of the Taiwan 50 ETF. This study gets the different results among fundamental data, foreign exchange, the technical indices and the major institutional traders. For the fundamental data, the LSTM gives the best predictive power, followed by the RNN, and finally the ANN. Figures 3 and 4 illustrates the trend prediction for the closing price and opening price with different machine learning and deep learning approaches, respectively. For the foreign exchange and the technical indices, the ANN exhibits the best predictive power, followed by the LSTM, and finally the RNN. Figures 5 and 6 illustrates the foreign exchange trend prediction for the closing price and opening price with different machine learning and deep learning approaches, respectively. Figures 7 and 8 are represented for the closing price and opening price with technical indices. For the major institutional traders, the LSTM presents the best results, followed by the ANN, and finally the RNN. The details are also illustrated in Figures 9 and 10.

ModelsPredictionMAEMSEMAPE
SVRClosing price1.9844.5872.406
ANNClosing price0.6280.7880.772
RNNClosing price0.6270.7720.769
LSTMClosing price0.6200.7630.765
SVROpening price4.69623.2985.699
ANNOpening price0.4130.3790.497
RNNOpening price0.4090.3670.493
LSTMOpening price0.4030.3780.488

Table 1.

The results of the fundamental data of the Taiwan 50 ETF.

ModelsPredictionMAEMSEMAPE
SVRClosing price3.30616.0544.032
ANNClosing price0.6030.7320.743
RNNClosing price0.6180.7560.753
LSTMClosing price0.6100.7430.751
SVROpening price5.13732.2846.126
ANNOpening price0.3860.3590.478
RNNOpening price0.3980.3840.488
LSTMOpening price0.3910.3730.481

Table 2.

The results of the foreign exchange of the Taiwan 50 ETF.

ModelsPredictionMAEMSEMAPE
SVRClosing price3.16410.9283.842
ANNClosing price0.6380.7590.783
RNNClosing price0.6740.8290.832
LSTMClosing price0.6330.7480.767
SVROpening price4.93725.6235.897
ANNOpening price0.4210.3800.512
RNNOpening price0.4880.4690.604
LSTMOpening price0.4190.3810.510

Table 3.

The results of the major institutional traders of the Taiwan 50 ETF.

ModelsPredictionMAEMSEMAPE
SVRClosing price3.93416.5964.796
ANNClosing price0.6080.7210.751
RNNClosing price0.6210.7460.761
LSTMClosing price0.6110.8290.776
SVROpening price5.30329.2906.447
ANNOpening price0.3830.3460.474
RNNOpening price0.3930.3680.491
LSTMOpening price0.3880.3560.484

Table 4.

The results of the technical indices of the Taiwan 50 ETF.

Figure 3.

The prediction of the Taiwan 50 ETF closing price of the fundamental data. (a) SVR, (b) ANN, (c) RNN and (d) LSTM.

Figure 4.

The prediction of the Taiwan 50 ETF opening price of the fundamental data. (a) SVR, (b) ANN, (c) RNN and (d) LSTM.

Figure 5.

The prediction of the closing price of the foreign exchange rate. (a) SVR, (b) ANN, (c) RNN and (d) LSTM.

Figure 6.

The prediction of the opening price of the foreign exchange rate. (a) SVR, (b) ANN, (c) RNN and (d) LSTM.

Figure 7.

The prediction of the closing price of the technical indices. (a) SVR, (b) ANN, (c) RNN and (d) LSTM.

Figure 8.

The prediction of the opening price of the technical indices. (a) SVR, (b) ANN, (c) RNN and (d) LSTM.

Figure 9.

The prediction of the closing price of the major institutional traders. (a) SVR, (b) ANN, (c) RNN and (d) LSTM.

Figure 10.

The prediction of the opening price of the major institutional trader group. (a) SVR, (b) ANN, (c) RNN and (d) LSTM.

Tables 58 present show the results of the FITX. For the fundamental data, the LSTM gives the best predictive power, followed by the RNN, and finally the ANN. Besides, fundamental data, foreign exchange, the technical indices and the major institutional traders have the same priority of predictive power. This study finds that the LSTM exhibits the best results, followed by the ANN and finally the RNN. The details are also illustrated in Figures 1118.

ModelsPredictionMAEMSEMAPE
SVRClosing price205.68351803.421.925
ANNClosing price82.63513881.7820.794
RNNClosing price81.35113511.30.786
LSTMClosing price80.89313315.750.770
SVROpening price406.140180288.43.822
ANNOpening price55.2146979.8520.531
RNNOpening price54.5206807.4140.523
LSTMOpening price53.9606701.9420.518

Table 5.

The results of the fundamental data of the FITX.

ModelPredictionMAEMSEMAPE
SVRClosing price385.580168158.33.065
ANNClosing price79.32512857.620.758
RNNClosing price80.15013731.320.761
LSTMClosing price78.08711314.080.743
SVROpening price180.46746233.911.604
ANNOpening price51.5916326.6610.483
RNNOpening price53.6646724.0120.520
LSTMOpening price52.1176865.4730.495

Table 6.

The results of the foreign exchange of the FITX.

ModelPredictionMAEMSEMAPE
SVRClosing price199.59149900.011.873
ANNClosing price84.65414017.210.828
RNNClosing price85.68114851.940.823
LSTMClosing price82.74213731.180.803
SVROpening price413.321184692.33.903
ANNOpening price57.7316659.9280.552
RNNOpening price59.9277734.2020.621
LSTMOpening price55.9756390.7680.536

Table 7.

The results of the major institutional traders of the FITX.

ModelPredictionMAEMSEMAPE
SVRClosing price273.91986916.052.586
ANNClosing price79.08712014.090.746
RNNClosing price80.30113448.050.765
LSTMClosing price79.15312442.9420.748
SVROpening price500.666265107.24.734
ANNOpening price53.5466435.2250.514
RNNOpening price53.1536411.5620.511
LSTMOpening price52.3446433.1980.499

Table 8.

The results of the technical indices of the FITX.

Figure 11.

The prediction of the FITX closing price of the fundamental data. (a) SVR, (b) ANN, (c) RNN and (d) LSTM.

Figure 12.

The prediction of the FITX opening price of the fundamental data. (a) SVR, (b) ANN, (c) RNN and (d) LSTM.

Figure 13.

The prediction of the FITX closing price of the foreign exchange rate. (a) SVR, (b) ANN, (c) RNN and (d) LSTM.

Figure 14.

The prediction of the FITX opening price of the foreign exchange rate. (a) SVR, (b) ANN, (c) RNN and (d) LSTM.

Figure 15.

The prediction of the FITX closing price of the major institutional traders. (a) SVR, (b) ANN, (c) RNN and (d) LSTM.

Figure 16.

The prediction of the FITX opening price of the major institutional traders. (a) SVR, (b) ANN, (c) RNN and (d) LSTM.

Figure 17.

The prediction of the FITX closing price of the technical indices. (a) SVR, (b) ANN, (c) RNN and (d) LSTM.

Figure 18.

The prediction of the FITX opening price of the technical indices. (a) SVR, (b) ANN, (c) RNN and (d) LSTM.

4.4 Prediction of the price fluctuation

Finally, this study picks out the model with the best training performance according to the above results. This study then further predicts the price fluctuation of 2018 for all trained models with the same parameter settings. The trading results are converted into a confusion matrix, whose equations are listed as follows:

Precision=TP/TP+FPE4
Recall=TP/TP+FNE5
F1score=2×TP/2TP+FP+FNE6
Accuracy=TP+TN/TP+FP+TN+FNE7

The TP herein is defined as True Positive, FP as False Positive, TN as True Negative, and FN as False Negative. Where TP represent that the actual value is correct and the predicted value is correct, FP the actual value wrong and the predicted value correct, TN the actual value wrong and the predicted value wrong, as well as FN the actual value correct and the predicted value wrong. The precision, the recall, the F1-score and the accuracy are the evaluation indices of the confusion matrix, where the larger the value of the evaluation index, the better the accuracy of the model.

Tables 9 and 10 show the model with the highest confusion matrix values of Taiwan 50 ETF and FITX respectively, and are further used to predict the price fluctuation of the next day. This study takes the Taiwan 50 ETF and the FITX as the targets. TP represents that the price rises actually and is predicted to rise, FP represents that the price falls actually but is predicted to rise, TN represents that the price falls actually and is predicted to fall, and FN represents that the price rises actually but is predicted to fall. In Table 9, the experimental results find that the prediction accuracies of fluctuation for Taiwan 50 ETF are about 70%, which proves that this prediction of the price fluctuation is successful. In Table 10, the experimental results also find that the prediction accuracies of price fluctuation for the FITX are about 70%, which again proves that this prediction of the price fluctuation is successful and is of certain commercial value.

GroupModelBenchmarkPrecisionRecallF1-scoreAccuracy
FundamentalLSTMOpening price0.7330.6870.7090.707
Foreign exchangeANNOpening price0.7580.6940.7250.731
Major institutional traderLSTMOpening price0.6860.6480.6660.668
Technical indexANNOpening price0.7750.7200.7460.743

Table 9.

The confusion matrix of Taiwan 50 ETF.

GroupModelBenchmarkPrecisionRecallF1-scoreAccuracy
FundamentalLSTMOpening price0.6110.7380.6690.670
Foreign exchangeANNOpening price0.6640.7730.7140.711
Major institutional traderLSTMOpening price0.5970.7200.6530.654
Technical indexLSTMOpening price0.6560.80.7210.723

Table 10.

The confusion matrix of FITX.

Advertisement

5. Conclusion

In this study, there are three findings. After using the stepwise regression method for data dimensionality to reduce by select the variables, the first experimental results showed that the foreign exchange and the technical indices are superior to the fundamental data, and the major institutional traders is inferior to the fundamental data. Secondly, this study compares the results of SVR, the ANN, the RNN and the LSTM models, and then use them to predict the stock market dynamics. The experimental results find that the SVR performs the worst. Specifically, the LSTM has the highest model accuracy in the control group, and the highest accuracy is given mostly by the LSTM but partly by the ANN in the experimental group. Thirdly, this study predicts the price fluctuation and obtains the accuracy about 70%.

5.1 Dimensionality reduction and feature selection

In this study, an experimental group and a control group are distinguished. In the experiments, stepwise regression analysis is used to select important variables from each data to achieve data dimensionality reduction. In the experimental group, basic stock market information is combined with many additional variables in an attempt to improve the accuracy of the model. The control group used the basic information of the stock market to compare the results with the experimental group. The experimental results showed that the model accuracy of the foreign exchange group and the major institutional trader group was higher than that of the basic group, while the major institutional trader group was lower than that of the basic group, which means that this experiment is successful. The additional variables of the foreign exchange group and the major institutional trader group help to increase the accuracy of the model, but adding the major institutional trader group actually reduces it. According to the study Abdioglu et al. [1], it shows that the three major legal institutional trader exist among the investors. Information asymmetries may cause the legal team to be unable to learn effectively during training.

5.2 Models comparison

This study uses SVR, ANN, RNN, and LSTM models to predict the stock market dynamics. The experimental results show that SVR is the worst among all testing results. It is speculated that SVR may not be able to adapt to this data. In the control group, the LSTM in predicting the opening price and closing price, both models have the highest accuracy. The experimental results show that consistent with Fischer and Krauss [33], LSTM has the best learning effect. In the experimental group, most of the LSTM models have the highest accuracy, but partly the ANN model is the highest. Overall, except for SVR, the ANN, RNN, and LSTM all perform well in predicting prices.

5.3 Forecast of uptrend and downtrend

This study predicts the price fluctuation. The price fluctuation prediction for the fundamental data, the foreign exchange, the technical indices and the major institutional traders are all have the accuracy about 70%, which is of a certain commercial value.

According to the final experimental results of this study, it can be found that the trend of uptrend and downtrend can be grasped in 2018. In the future, this study will continue to update the dataset with different time period to see whether the accuracy of the future model is as good as now. In addition, according to the parameters setting of this study, the method of predicting the opening and closing prices of the stock market was adopted. The method can also be redesigned to directly predict the future rise and fall of the stock market to explore Taiwan’s financial market. It can also be used from another deep learning methodology—CNN model in the form of pictures to predict the Taiwan’s future financial market trends.

There is still the following limitation in the experiments of this study. The simulated trading set in this study is sort of simplified without considering the actual trading situations, such as the transaction fee, the change of position and the emergency conditions, leading to the final trading results which might be slightly changed. This study provides a method to predict the fluctuation of the financial market. In the future, other scholars may take into account the conditions which will be encounter during the actual investment behavior and develop a real-time trading system.

Advertisement

Acknowledgments

This work was supported by the Ministry of Science and Technology, Taiwan, under Grant MOST 109-2410-H-006-116-MY2, Grant MOST110-2511-H-006-013-MY3, and Grant MOST 109-2410-H-025-016-MY2; and in part by the Higher Education Sprout Project, Ministry of Education to the Headquarters of University Advancement at National Cheng Kung University (NCKU).

Advertisement

Conflict of interest

The authors declare no conflict of interest.

References

  1. 1. Abdioglu N, Bamiatzi V, Cavusgil ST, Khurshed A, Stathopoulos K. Information asymmetry, disclosure and foreign institutional investment: An empirical investigation of the impact of the Sarbanes-Oxley Act. International Business Review. 2015;24(5):902-915
  2. 2. Armano G, Marchesi M, Murru A. A hybrid genetic-neural architecture for stock indexes forecasting. Information Sciences. 2005;170(1):3-33
  3. 3. Atsalakis GS, Valavanis KP. Surveying stock market forecasting techniques–Part II: Soft computing methods. Expert Systems with Applications. 2009;36(3):5932-5941
  4. 4. Enke D, Mehdiyev N. Stock market prediction using a combination of stepwise regression analysis, differential evolution-based fuzzy clustering, and a fuzzy inference neural network. Intelligent Automation & Soft Computing. 2013;19(4):636-648
  5. 5. Rather AM, Agarwal A, Sastry V. Recurrent neural network and a hybrid model for prediction of stock returns. Expert Systems with Applications. 2015;42(6):3234-3241
  6. 6. Zhu H, Jiang ZQ, Li SP, Zhou WX. Profitability of simple technical trading rules of Chinese stock exchange indexes. Physica A: Statistical Mechanics and Its Applications. 2015;439:75-84
  7. 7. Chen Y, Hao Y. A feature weighted support vector machine and K-nearest neighbor algorithm for stock market indices prediction. Expert Systems with Applications. 2017;80:340-355
  8. 8. Paiva FD, Cardoso RTN, Hanaoka GP, Duarte WM. Decision-making for financial trading: A fusion approach of machine learning and portfolio selection. Expert Systems with Applications. 2019;115:635-655
  9. 9. Chen W, Yeo CK, Lau CT, Lee BS. Leveraging social media news to predict stock index movement using RNN-boost. Data & Knowledge Engineering. 2018;118:14-24
  10. 10. Wang C, Zhang X, Wang M, Lim MK, Ghadimi P. Predictive analytics of the copper spot price by utilizing complex network and artificial neural network techniques. Resources Policy. 2019;63:101414
  11. 11. Yong YL, Lee Y, Gu X, Angelov PP, Ngo DCL, Shafipour E. Foreign currency exchange rate prediction using neuro-fuzzy systems. Procedia Computer Science. 2018;144:232-238
  12. 12. Henríquez J, Kristjanpoller W. A combined independent component analysis–Neural network model for forecasting exchange rate variation. Applied Soft Computing. 2019;83:105654
  13. 13. Grodinsky J. Investments. New York: Ronald Press Company; 1953
  14. 14. Bunea OI, Corbos RA, Popescu RI. Influence of some financial indicators on return on equity ratio in the Romanian energy sector-A competitive approach using a DuPont-based analysis. Energy. 2019;189:116251
  15. 15. Lončarski I, Vidovič L. Sorting out the financials: Making economic sense out of statistical factors. Finance Research Letters. 2019;31:110-118
  16. 16. Robert R. Dow Theory: An Explanation of Its Development and An Attempt to Define Its Usefulness as An Aid in Speculation. New York: Baron’s; 1932
  17. 17. Elliott RN. The Wave Principle. Los Angeles: Alanpuri Trading; 1938
  18. 18. Granville JE. A Strategy of Daily Stock Market Timing for Maximum Profit. Englewood Cliffs, N.J.: Prentice-Hall; 1960
  19. 19. Lin Q. Technical analysis and stock return predictability: An aligned approach. Journal of Financial Markets. 2018;38:103-123
  20. 20. Jiang M, Liu J, Zhang L. An improved stacking framework for stock index prediction by leveraging tree-based ensemble models and deep learning algorithms. Physica A: Statistical Mechanics and Its Applications. 2019;541:122272
  21. 21. Picasso A, Merello S, Ma Y, Oneto L, Cambria E. Technical analysis and sentiment embeddings for market trend prediction. Expert Systems with Applications. 2019;135:60-70
  22. 22. Patel J, Shah S, Thakkar P, Kotecha K. Predicting stock and stock price index movement using trend deterministic data preparation and machine learning techniques. Expert Systems with Applications. 2015;42(1):259-268
  23. 23. Lee TK, Cho JH, Kwon DS, Sohn SY. Global stock market investment strategies based on financial network indicators using machine learning techniques. Expert Systems with Applications. 2019;117:228-242
  24. 24. Vapnik V, Chervonenkis A. Theory of Pattern Recognition. Moscow: Nauka; 1974
  25. 25. Lahmiri S. Minute-ahead stock price forecasting based on singular spectrum analysis and support vector regression. Applied Mathematics and Computation. 2018;320:444-451
  26. 26. Mishra S, Padhy S. An efficient portfolio construction model using stock price predicted by support vector regression. The North American Journal of Economics and Finance. 2019;50:101027
  27. 27. Rezaee MJ, Jozmaleki M, Valipour M. Integrating dynamic fuzzy C-means, data envelopment analysis and artificial neural network to online prediction performance of companies in stock exchange. Physica A: Statistical Mechanics and Its Applications. 2018;489:78-93
  28. 28. LeCun Y, Boser B, Denker JS, Henderson D, Howard RE, Hubbard W, et al. Backpropagation applied to handwritten zip code recognition. Neural Computation. 1989;1(4):541-551
  29. 29. Williams RJ, Zipser D. A learning algorithm for continually running fully recurrent neural networks. Neural Computation. 1989;1(2):270-280
  30. 30. Gunduz H, Yaslan Y, Cataltepe Z. Intraday prediction of Borsa Istanbul using convolutional neural networks and feature correlations. Knowledge-Based Systems. 2017;137:138-148
  31. 31. Xu B, Zhang D, Zhang S, Li H, Lin H. Stock Market Trend Prediction Using Recurrent Convolutional Neural Networks. Lecture Notes in Computer Science. LNAI 11109. 2018. pp. 166-177
  32. 32. Hochreiter S, Schmidhuber J. Long short-term memory. Neural Computation. 1997;9(8):1735-1780
  33. 33. Fischer T, Krauss C. Deep learning with long short-term memory networks for financial market predictions. European Journal of Operational Research. 2018;270(2):654-669
  34. 34. Cao J, Li Z, Li J. Financial time series forecasting model based on CEEMDAN and LSTM. Physica A: Statistical Mechanics and Its Applications. 2019;519:127-139
  35. 35. Baffour AA, Feng J, Taylor EK. A hybrid artificial neural network-GJR modeling approach to forecasting currency exchange rate volatility. Neurocomputing. 2019;365:285-301
  36. 36. Noryani M, Sapuan SM, Mastura MT, Zuhri MYM, Zainudin ES. Material selection of natural fibre using a stepwise regression model with error analysis. Journal of Materials Research and Technology. 2019;8(3):2865-2879

Written By

Min-Hsuan Fan, Jing-Long Huang and Mu-Yen Chen

Submitted: 28 February 2023 Reviewed: 14 December 2023 Published: 28 March 2024