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

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

Given different combinations of data sources, previous studies explored the use of deep learning models to predict stock market price/movement. In this section, we summarize the previous studies in a general workflow with four steps that most of the studies follow: Raw Data, Data Processing, Prediction Model and Model Evaluation. In this section, we would discuss each step separately and reveal a general approach that the future work can easily reproduce.

### 4.1 Raw Data

The first step of predicting is to collect proper data as the basis. It could be the intrinsic historical prices with the assumption that history repeats itself, or the extrinsic data sources that affect the stock market. In the efficient-market hypothesis, asset prices already reflect all available information. However, in practice many researchers do not agree with this conclusion, thus many different extrinsic sources of data are used for stock market prediction, e.g., Weng et al. [2017] compares the usage of market data, technical indicators, Wikipedia traffic, Google news counts, and generated features, and Liu et al. [2019b] covers market data, fundamental data, knowledge graph, and news.

#### 4.1.1 Data Types

In this part, we categories the raw data that are commonly used for stock market prediction into seven types:

1. Market data: market data includes all trading activities that happen in a stock market, e.g., open/high/low/close prices, trading volume, etc. It is used as both input features (e.g., the historical prices in a look-back window) and prediction target (e.g., the close price of the next day).

2. Text data: text data refer to the text contributed by individuals, e.g., social media, news, web searches, etc. As a type of alternative data, these data are hard to collect and process, but may provide useful information that is not included in market data. Sentiment analysis can be applied on these text data and produce a sentiment factor (e.g., positive, neural, or negative) that can be further used for prediction.

3. Macroeconomics data: macroeconomics data reflects the economic circumstances of a particular country, region or sector, e.g., Consumer Price Index (CPI), Gross domestic product (GDP), etc. These indicators are related with the stock market in the sense that they indicate how healthy the overall stock market is and can provide confirmation as to the quality of a stock market advance or decline.

4. Knowledge graph data: there are some kind of relationship between different companies and different markets, e.g., the movement of stocks in the same sector may be affected by the same news. Powered by the recently developed graph neural networks, the knowledge graph data from open sources such as FreeBase [ Bollacker et al., 2008 ] and Wikidata 3 3 3 https://www.wikidata.org/ can now be used to improve the prediction performance.

5. Image data: inspired by the success of convolutional neural networks in 2D image processing, e.g., classification and object detection, candlestick charts are used as input images for stock prediction. While satellite and CCTV images or videos are used to monitor the situation of companies and may be helpful for stock price prediction, they are never used in the surveyed papers because of the prohibitive cost of collection and the potential privacy leakage risk.

6. Fundamental data: the most common type of fundamental data is the accounting data, which is reported quarterly, e.g., assets, liabilities, etc. It is less used in studies with deep learning models because the low frequency of reporting and also the inaccuracies of the reporting date, e.g., the fundamental data published is indexed by the last date included in the report and precedes the date of the release, which brings in a risk of using future information.

7. Analytics data: analytics data refers to the data that can be extracted from reports (e.g., recommendation for selling or buying a stock) that are provided by investment banks and research firms, who make an in-depth analysis of companies’ business models, activities, competitions, etc. These reports provide valuation information, while they may be costly and shared among different consumers, who all want to use this information to make a profit.

Different types or raw data are accompanied with different levels of difficulty for obtaining and processing, and the usage of different data types is shown in Figure 3 . For deep learning models, a huge amount of input data is necessary for the training of a complex neural network model. In this case, market data is the best choice and used for the most as it provides the largest amount of data sample, while the other data types usually have a smaller size. Text data is used for the second most, with the popularity of social media and online news website and the easier use of web crawlers to get the text data. An extreme case is the analytics data, which is never used in the surveyed studies, because of both the data sparsity and the high cost to access.

There is also a trend in Figure 3 that more diverse data types are used in 2018 and 2019, compared to the studies in 2017. It indicates the fact that it is harder to get a better prediction result based on only the market data. It also reflects the development of new tools so that new types of data can be used for prediction, e.g., graph neural networks for knowledge graph data.

#### 4.1.2 Data Length

To evaluate the performance of different models, historical data is necessary for evaluation. However, there is a tradeoff of choosing the data length. A short time period of data is not sufficient to show the effective and has a higher risk of overfitting, while a long time period takes the risk of traversing different market styles and present out-of-dated results. Besides, the data availability and cost are factors that needs to be taken into consideration when choosing the data length.

The distribution of time periods of data used in the surveyed papers is shown in Figure 4 . It is more expensive to get intraday data with a good quality and most of the previous studies involving intraday prediction would use a time period less than one year.

For a single prediction, lag is used to denote the time length of the input data to be used by the model, e.g., in the daily prediction, a lag of 30 days means the data in the past 30 days are used to build the input features. For technical indicators, lag is often set as an input parameters and vary a lot in previous studies from 2 to 252 time periods. Correspondingly, horizon is used to denote the time length of the future to be predicted by the model. Most of the studies focus on a short-term prediction horizon, e.g., one day or five minutes, with only a few exceptions for a longer horizon such as five days or ten days.

### 4.2 Data Processing

#### 4.2.1 Missing Data Imputation

The problem of missing data is not as severe as in other domains, e.g., sensor data, because the market data is more reliable and well supported and maintained by the trading markets. However, to align multiple types of data with different sampling frequencies, e.g., market data and fundamental data, the data with a lower sampling frequency should be inserted in a forward way by propagating the last valid observation forward to next valid, to avoid data leakage of the future information.

#### 4.2.2 Denoising

With many irrational behaviors in the stock trading process, the market data is filled with noise, which may misrepresent the trend of price change and misguide the prediction. As a signal processing technique, wavelet transform has been used to eliminate noise in stock price time series [ Bao et al., 2017 , Liang et al., 2019 ] . Another approach to eliminate noisy data in Sun et al. [2017] is the use of the kNN-classifiers, based on two training sets with different labels in a data preparation layer.

#### 4.2.3 Feature Extraction

For machine learning models, feature engineering is the process of extracting input features from raw data based on domain knowledge. Combined with raw data, these handcrafted features are used as input for the prediction models and can substantially boost machine learning model performance.

For market data, technical analysis is a feature extraction approach that builds various indicators for forecasting the direction of prices based on historical prices and volumes, e.g. , moving average, or moving average convergence/divergence (MACD). These technical indicators can be further used to design simple trading strategies. Technical indicators are also used to build image inputs, e.g. , 15 different technical indicators with a 15-days periods are used to construct a 15 × \times 15 sized 2D images in Sezer & Ozbayoglu [2018] .

While the feature extraction techniques represented by technical analysis for market data have been used and validated for many years, the tools for extracting features from text data have made a greater progress in the past few years, owing to the various deep learning models developed for natural language processing. Before the popularity of machine learning models, the bag-of-words (BoW) model [ Harris, 1954 ] is used as a representation of text that describes the occurrence of words within a document. In recent years, machine learning and deep learning models show an improved performance for word embedding. Given the sequence of words, the word2vec model [ Mikolov et al., 2013 ] , which are shallow and two-layer neural networks, can be used to embed each of these words in a vector of real numbers and has been used in Liu et al. [2019a] , Liu et al. [2019c] , Lee & Soo [2017] . Global Vectors for Word Representation (GloVe) [ Pennington et al., 2014 ] is another word embedding method proposed by Stanford University, in which each of the word vectors has a dimension of 50, and has been used in Tang & Chen [2018] .

Stock markets are highly affected by some public events, which can be extracted from online news data and used as input features. Ding et al. [2015] uses a neural tensor network to learn event embeddings for representing news documents. Hu et al. [2018b] uses a news embedding layer to encode each news into a news vector. Wang et al. [2019b] uses a convolution neural network (CNN) layer to extract salient features from transformed event representations.

From sentiment aspect, the text data can be further analyzed and a sentiment vector can depict each word, which may present the positive or negative opinions for the future direction of stock prices. For sentiment analysis, Jin et al. [2019] uses CNN and Mohan et al. [2019] uses Natural Language Toolkit (NLTK) [ Loper & Bird, 2002 ] . Lien Minh et al. [2018] even proposes a sentiment Stock2Vec embedding model trained on both the stock news and the Harvard IV-4 psychological dictionary, which may not be directly related to stock market prediction.

Off-the-shelf commercial software is also available for linguistic features and sentiment analysis. For example, Kumar et al. [2019] employs Linguistic Inquiry and Word Count (LIWC) [ Tausczik & Pennebaker, 2010 ] to find out the linguistic features in the news articles, which includes the text analysis module along with a group of built-in dictionaries to count the percentage of words reflecting different emotions, thinking styles, social concerns, and even parts of speech.

For knowledge graph data used more recently, the TransE model [ Bordes et al., 2013 ] is a computationally efficient predictive model that satisfactorily represents a one-to-one type of relationship and has been used in Liu et al. [2019c] .

Based on the input raw data and extracted features, we show the distribution of different combinations of input features in Figure 5 and the detailed article lists in Table 4 . From Figure 5 , historical prices and technical indicators are the most commonly used input features and followed by text and macroeconomics data. This could be explained by the easier accessing and processing of market data than other data types.

#### 4.2.4 Dimensionality Reduction

It is possible that many features are highly correlated with each other, e.g., the technical indicators which are all calculated from historical open/high/low/close prices and volume. To alleviate the corresponding problem of deep learning model’s overfitting, dimensionality reduction for the input features has been adopted as a preprocessing technique for stock market prediction.

Principal component analysis (PCA) is a commonly used transformation technique that uses Singular Value Decomposition of the input data to project it to a lower dimensional space and has been used in Gao & Chai [2018] , Zhang et al. [2019b] , Zhong & Enke [2017] , Wang & Wang [2015] , Singh & Srivastava [2017] , Chong et al. [2017] . Zhong & Enke [2017] even gives a comparison between different versions of PCA, and finds that the PCA-ANN model give a slightly higher prediction accuracy for the daily direction of SPY for next day, compared to the use of fuzzy robust principal component analysis (FRPCA) and kernel-based principal component analysis (KPCA).

For dimensionality reduction, the other options include independent components analysis (ICA) [ Sethia & Raut, 2019 ] , autoencoder [ Chong et al., 2017 ] , restricted Boltzmann machine [ Chong et al., 2017 ] , empirical mode decomposition (EMD) [ Cao et al., 2019 , Zhou et al., 2019a ] , and sub-mode coordinate algorithm (SMC) [ Huang et al., 2018 ] . Huang et al. [2018] first utilizes tensor to integrate the multi-sourced data and further proposes an improved SMC model to reduce the variance of their subspace in each dimension produced by the tensor decomposition.

Feature selection is another way of dimensionality reduction, by choosing only a subset of input features. Chi-square method [ Zheng et al., 2004 ] and maximum relevance and minimum redundancy (MRMR) [ Peng et al., 2005 ] are two common used feature selection techniques. Chi-square method decides whether a categorical predictor variable and the target class variable are independent or not. High chi-squared values indicate the dependence of the target variable on the predictor variable. Minimum redundancy maximum relevance uses a heuristic to minimize redundancy while maximizing relevance to select promising features for both continuous and discrete inputs, through F-statistic values. Chi-square method is used in Gunduz et al. [2017] , Kumar et al. [2019] and maximum relevance and minimum redundancy is used in Kumar et al. [2019] .

Other options for feature selection include rough set attribute reduction (RSAR) [ Lei, 2018 ] , autocorrelation function (ACF) and partial correlation function (PCF) [ Wu & Gao, 2018 ] , the analysis of variance (ANOVA) [ Niaki & Hoseinzade, 2013 ] , and maximal information coefficient feature selection (MICFS) [ Yang et al., 2018 ] .

#### 4.2.5 Feature Normalization & Standardization