Applications of deep learning in stock market prediction: recent progress — part 4/5

Cleaned-text code points [46792, 62775). Bibliography omitted here; source.md includes it.

1. Generative adversarial network (GAN). GAN is introduced by Goodfellow et al. [2014] , in which a discriminative net D D learns to distinguish whether a given data instance is real or not, and a generative net G G learns to confuse D D by generating high quality fake data. This game between G G and D D would lead to a Nash equilibrium. Since the introduction of GAN, it has been applied in multiple image-related tasks, especially for image generation and enhancement, and generates a large family of variants. Inspired the success of GANs, Zhou et al. [2018] proposes a generic GAN framework employing LSTM and CNN for adversarial training to predict high-frequency stock market.

2. Graph neural network (GNN). GNN is designed to utilize graph-structured data, thus capable of utilizing the network structure to incorporate the interconnectivity of the market and make better predictions, compared to relying solely on the historical stock prices of each individual company or on hand-crafted features [ Matsunaga et al., 2019 ] . Chen et al. [2018c] first constructs a graph including 3,024 listed companies based on investment facts from real market, then learns a distributed representation for each company via node embedding methods applied on the graph, and applies three-layer graph convolutional networks to predict. Kim et al. [2019] uses LSTM for the individual stock prediction task and GRU for the index movement prediction task where an additional graph pooling layer is needed.

3. Capsule Network. Different from the method of CNNs and RNNs, the capsule network increases the weights of similar information through its dynamic routing, which is proposed by Sabour et al. [2017] and displaces the pooling operation used in conventional convolution neural network. Liu et al. [2019a] is the first to introduce the capsule network for the problem of stock movements prediction based on social media and show that the capsule network is effective for this task.

4. Reinforcement learning. Unlike supervised learning, reinforcement learning trains an agent to choose the optimal action given a current state, with the goal to maximize cumulative rewards in the training process. Reinforcement learning can be applied for stock prediction with the advantage of using information from not only the next time step but from all subsequent time steps [ Lee et al., 2019 ] . Reinforcement learning is also used for building algorithmic trading systems [ Deng et al., 2016 ] .

5. Transfer learning. Transfer learning can be used in training deep neural networks with a small amount of training data and a reduced training time, by tuning the pre-trained model on a larger training dataset, e.g. , Nguyen & Yoon [2019] trains a LSTM base model on 50 stocks and transfers parameters for the prediction model on KOSPI 200 or S&P 500.

We show the change trend of models used in the past three years in Figure 7 . RNN Models are used for the most, but the ratio drops with the emerging new models in 2019. We also show the change of common optimizers used in our surveyed papers in Figure 8 , which include Adam [ Kingma & Ba, 2014 ] , stochastic gradient descent (SGD), RMSprop [ Tieleman & Hinton, 2012 ] , AdaDelta [ Zeiler, 2012 ] . Adam has been used the most for stock prediction, which is a combination of RMSprop and stochastic gradient descent with momentum and presents several benefits, e.g. , computationally efficiency and little memory requirement.

For the baselines used in the survey studies, both linear, machine learning and deep learning models are covered. The change of baseline models used is shown in Figure 9 . With the further exploration of deep learning models for stock prediction, their ratio as baselines keeps increasing in the past three years.

### 4.4 Model Evaluation

In this part, we category the evaluation metrics for the prediction models mentioned in the last part into four types:

1. Classification metrics . Classification metrics are used to measure the model’s performance on movement prediction, which is modeled as a classification problem. Common used metrics include accuracy (which is the correct number of prediction for directional change), precision, recall, sensitivity, specificity, F1 score, macro-average F-score, Matthews correlation coefficient (which is a discrete case for Pearson correlation coefficient), average AUC score (area under Receiver Operating Characteristic curves [ Fawcett, 2006 ] ), Theil’s U coefficient, hit ratio, average relative variance, etc. Confusion matrices and boxplots for daily accuracy are also used for classification performance analysis [ Guang et al., 2019 , Zhong & Enke, 2017 , Zhang et al., 2019b ] .

2. Regression metrics. Regression metrics are used to measure the model’s performance on stock/index price prediction, which is modeled as a regression problem. Common used metrics include mean absolute error (MAE), root mean absolute error (RMAE), mean squared error (MSE), normalized MSE (NMSE), root mean squared error (RMSE), relative RMSE, normalized RMSE (NRMSE), mean absolute percentage error (MAPE), root mean squared relative error (RMSRE), mutual information, R 2 R^{2} (which is the coefficient of determination).

3. Profit Analysis. Profit analysis evaluates whether the predicted-based trading strategy can bring a profit or not. It is usually evaluated from two aspects, the return and the risk. The return is the change in value on the stock portfolio and the risk can be evaluated by maximum drawdown [ Zhou et al., 2019a ] , which is the largest peak-to-trough decline in the value of a portfolio and represents the max possible loss, or the annualized volatility [ Karathanasopoulos & Osman, 2019 ] . Sharpe Ratio is a comprehensive metric with both the return and risk into consideration, which is the average return earned in excess of the risk-free per unit of volatility [ Sharpe, 1994 ] . More detailed analysis about the transactions is given in Sezer & Ozbayoglu [2018] , Sezer & Ozbayoglu [2019] .

4. Significance Analysis. In order to determine if there is significant difference in terms of predictions when comparing the deep learning models to the baselines, Kruskal-Wallis [ Kruskal & Wallis, 1952 ] and Diebold-Mariano [ Diebold & Mariano, 2002 ] tests can be used to test the statistical significance, which decides a statistically better model. They are not used often for stock prediction, with only a few studies in 2019 [ Kumar et al., 2019 , Zhang et al., 2019b ] .

The detailed list of studies using each metrics (as well as the metrics’ abbreviations) is shown in Table 10 .

We further show the change of classification and regression metrics in Figure 10 and Figure 11 . For classification metrics, accuracy and F1 score are the most often used, followed by precision, recall, and MCC. For regression metrics, RMSE and MAPE are the most often used, followed by MAE and MSE.

## 5 Implementation and Reproducibility

### 5.1 Implementation

In this section, we pay a special attention to the implementation details of the papers we survey, which is less discussed before in previous surveys.

We firstly investigate the programming language used for the implementation of machine learning and deep learning models. Among them, Python is becoming the dominant choice in the past three years as shown in Figure 12 , which provides a bunch of packages and frameworks for model implementation purpose, e.g., Keras 4 4 4 http://keras.io/ . Keras has been incorporated in TensorFlow 2.0 and higher versions. , TensorFlow 5 5 5 https://www.tensorflow.org/ , PyTorch 6 6 6 https://pytorch.org/ , Theano 7 7 7 http://deeplearning.net/software/theano/ . It is a discontinued project and not recommended for further use. , scikit-learn 8 8 8 https://scikit-learn.org/stable/index.html . Other choices include R, Matlab, Java, etc. We show the specific paper list using different programming languages and frameworks in Table 11 . From Table 11 , Keras and TensorFlow are the dominant frameworks for deep learning-based stock market prediction research. For further reference, the readers may refer to Hatcher & Yu [2018] for a comprehensive introduction of deep learning tools.

Deep learning models require a larger amount of computation for training, and GPU has been used to accelerate the convolutional operations involved. With the need of processing multiple types of input data, especially the text data, the need for GPU would keep increasing in this research area. We give a list of different types of GPU used in the surveyed papers in Table 12 . Cloud computing is another solution when GPU is not available locally. There are many commercial choices of cloud computing services, e.g., Amazon Web Services 9 9 9 https://aws.amazon.com/ , Google Cloud 10 10 10 https://cloud.google.com/ , and Microsoft Azure 11 11 11 https://azure.microsoft.com/ . However, they are not widely adopted in current study of stock market prediction and no previous study covered in this survey mentions the usage of cloud service explicitly.

### 5.2 Result Reproducibility

While deep learning techniques have been proved to be effective in many different problems and most of the previous studies have proven their effectiveness for time series forecasting problems, while there are still doubts and concerns, e.g. , in the M4 open forecasting competition with 100,000 time series which started on Jan 1, 2018 and ended on May 31, 2018, statistical approaches outperform pure ML methods [ Makridakis et al., 2018a ] and there are similar results with the dataset of the earlier M3 competition [ Makridakis et al., 2018b ] . These studies also question the reproducibility and replicability in the previous papers which use ML methods.

While it is beyond the scope of this study to check the result of each paper, we instead investigate the data and code availability of the surveyed papers, which are two important aspects for the result reproducibility. Some of the source journals would require or recommend the data and code submitted as supplementary files for peer review, e.g., PLOS ONE. In other cases, the authors would share their data and code proactively, for the consideration that following works can easily use them as baselines, which gains a higher impact for their publications.

#### 5.2.1 Data Availability

There are many free data sources on the Internet for the research purpose of stock market prediction. For historical price and volume, the first choice should be the widely used Yahoo! Finance 12 12 12 https://finance.yahoo.com/ , which provides free access to data including stock quotes, up-to-date news, international market data, etc., and has been mentioned at least in 25 out of 124 papers. Other similar options include Tushare 13 13 13 https://tushare.pro/ , which can be used to crawl historical data of China stocks. Some stock markets would also provide the download service of historical data on their official websites. For macroeconomic indicators, International Monetary Fund (IMF) 14 14 14 https://www.imf.org/ and World Bank 15 15 15 https://www.worldbank.org/ are good choices to explore. For financial news, previous studies would crawl some major news sources, e.g., CNBC 16 16 16 https://www.cnbc.com/ , Reuters 17 17 17 https://www.reuters.com/ , Wall Street Journal 18 18 18 https://www.wsj.com/ , Fortune 19 19 19 https://fortune.com/ , etc. Social networking websites, e.g., Twitter 20 20 20 https://twitter.com/ and Sina Weibo 21 21 21 https://www.weibo.com/ , provide web Application Programming Interface (API) for the access of their data (usually preprocessed and anonymous). And researchers could filter the financial related tweet using companies’ names as keywords. For relational data, Wikidata 22 22 22 https://www.wikidata.org/wiki/Wikidata:Main_Page provides relations between companies such as supplier-consumer relation and ownership relation.

There are many commercial choices too, e.g., Bloomberg 23 23 23 https://www.bloomberg.com/ , Wind 24 24 24 https://www.wind.com.cn/ , Quantopian 25 25 25 https://www.quantopian.com/ , Investing.com 26 26 26 https://www.investing.com/ . Online brokers such as Interactive Brokers 27 27 27 https://www.interactivebrokers.com/ also provide data-related services. There are also some well-established databases for research purpose and contain many different types of financial data, which can be used for stock market prediction and other financial problems. One example is the CSMAR database 28 28 28 http://us.gtadata.com/ , which provides financial statements and stock trading data for Chinese companies, including balance sheets, income statements, cash flows, stock prices and returns, market returns and indices, and other data on Chinese equities. Another example is Wharton Research Data Services (WRDS) 29 29 29 https://wrds-web.wharton.upenn.edu/ , which provides access to many financial, accounting, banking, economics, marketing, and public policy databases through a uniform, web-based interface.

Data competition websites, e.g., Kaggle 30 30 30 https://www.kaggle.com/ , are also becoming a good choice of data repository for stock market prediction. And quantitative companies could collaborate with these websites to host stock market prediction competitions, e.g., Two Sigma Financial Modeling Challenge 31 31 31 https://www.kaggle.com/c/two-sigma-financial-modeling , which is organized by a hedge fund named Two Sigma 32 32 32 https://www.twosigma.com/ .

Even though most of the data sources are available on the Internet, it would be more convenient for replicability if the authors could release the exact dataset they use. In Table 13 , we list those with the data description and link, for those data which is hosted in software host websites such as Github 33 33 33 https://github.com/ , cloud services, researcher’s own website, and data competition websites such as Kaggle. For the mid-price prediction of limit order book data, there is a benchmark dataset provided by Ntakaris et al. [2017] and has been used in the following studies [ Tran et al., 2018 ] .

#### 5.2.2 Code Availability

Github has been the mainstream platform of hosting source code in the computer science field. However, only a small number of studies would release their code for now, in the area of stock market prediction. In Table 14 , we list the articles with public code repositories. A short description of each method is mentioned, and the details can be found in Section 4 and the original documents.

## 6 Future Directions

Based on our review of recent works, we give some future directions in this section, which aims to bring new insight to interested researchers.

### 6.1 New Models

Different structures of neural networks are not fully studied for stock prediction, especially those who only appear in recent years. There are two steps where deep learning models involve in stock prediction, namely, Data Processing and Prediction Model in Section 4 . While we already covered some latest effort of applying new models in this survey, e.g., the attention mechanism and generative adversarial networks, there are still a huge space to explore for new models. For example, for sentiment analysis of text data, Transformer [ Vaswani et al., 2017 ] and pre-trained BERT (Bidirectional Encoder Representations from Transformers) [ Devlin et al., 2018 ] are widely used in natural language processing, but is less discussed for financial news analysis.

### 6.2 Multiple Data Sources

Observed from our discussion in Section 4 , it is not wise to design a stock prediction solution based on a single data source, e.g., market data, as it has been heavily used in previous studies and it would be very challenging to outperform existing solutions. A better idea is to collect and use multiple data sources, especially those which are less explored in the literature [ Zhou et al., 2019b ] .

### 6.3 Cross-market Analysis