scieee AI-readable full text Open interactive document viewer

A Nonlinear Technical Indicator Selection Approach for Stock Markets. Application to the Chinese Stock Market

Alfonso Pérez, Gerardo; Rodríguez Ramírez, Daniel

Abstract

In this paper we present a combinatorial nonlinear technical indicator approach for the identification of appropriate combinations of stock technical indicators as inputs in non-linear models. This approach is illustrated with the example of Chinese stock indexes and 35 different stock technical indicators using neural networks as the chosen non-linear method. Stock market technical indicators can generate contradictory signals regarding the future performance of the stock analyzed. Furthermore, some non-linear methods, such as neural networks, can have poor generalization power when dealing with problems of high dimensionality due to the issue of local minima. Therefore, non-linear approaches that can identify appropriate combinations of input variables are of clear importance. It will be shown that the proposed approach, when using neural networks as classifiers, generates error rates lower than those using directly neural networks without dimensionality reduction. It will also be shown that merely increasing the number of neurons does not increase the accuracy. The approach proposed in this article is illustrated with an application to the stock market using neural networks but it could be applied to other fields and it can also be used with other non-linear techniques such as for instance support vector machines.

Full text

mathematics Article A Nonlinear Technical Indicator Selection Approach for Stock Markets. Application to the Chinese Stock Market Gerardo Alfonso 1,2,* and Daniel R. Ramirez 2 1Shenwan & Hongyuan Securities Co., Ltd. (SWS), Shanghai 200031, China 2Departamento de Ingeniería de Sistemas y Automática, Universidad de Sevilla, 41092 Sevilla, Spain; [email protected] *Correspondence: [email protected] Received: 1 July 2020; Accepted: 5 August 2020; Published: 6 August 2020 Abstract: In this paper we present a combinatorial nonlinear technical indicator approach for the identification of appropriate combinations of stock technical indicators as inputs in non-linear models. This approach is illustrated with the example of Chinese stock indexes and 35 different stock technical indicators using neural networks as the chosen non-linear method. Stock market technical indicators can generate contradictory signals regarding the future performance of the stock analyzed. Furthermore, some non-linear methods, such as neural networks, can have poor generalization power when dealing with problems of high dimensionality due to the issue of local minima. Therefore, non-linear approaches that can identify appropriate combinations of input variables are of clear importance. It will be shown that the proposed approach, when using neural networks as classifiers, generates error rates lower than those using directly neural networks without dimensionality reduction. It will also be shown that merely increasing the number of neurons does not increase the accuracy. The approach proposed in this article is illustrated with an application to the stock market using neural networks but it could be applied to other fields and it can also be used with other non-linear techniques such as for instance support vector machines. Keywords: feature selection; neural networks; stocks 1. Introduction Over the last few decades there has been an increase in non-linear forecasting techniques, such as for instance neural networks (NN) and support vector machines (SVM). The non-linearity of the stock market performance has been mentioned by many researchers such as for instance Vrbka and Rowland [ 1 ]. In fact, the non-linearity of the stock market was one of the reasons behind choosing neural networks (a non-linear approach) by Vrbka and Rowland [ 1 ] as a model to forecast stocks prices in Prague Stock Exchange. In this paper the authors successfully applied multilayer perceptron and radial basis networks to that particular stock market. While neural networks are an important stock forecasting technique it should be noted that, as in any other technique, it has limitations. Horack and Krulicky [ 2 ] did in this regard an interesting comparison between the exponential time series alignment method and the time series alignment with neural networks method. The authors highlighted the importance of neural networks in the field of stock forecasting mentioning that generally neural networks provide better forecast than traditional methods. However, they also concluded that in their example, applied to a volatile stock, the traditional forecasting method generated better results than the neural network. This highlights the importance of using the appropriate stock forecasting techniques with papers in the existing literature finding less than optimal results for some popular Mathematics 2020,8, 1301; doi:10.3390/math8081301 www.mdpi.com/journal/mathematics Mathematics 2020,8, 1301 2 of 15 techniques. For instance, Groda and Vrbka [ 3 ] concluded that the Box–Jenkins method is not an appropriate method in the case of stocks listed in the Prague Stock Exchange. An important development in recent years is the very large increase in data available in many disciplines. It is relatively frequent to have a high number of variables that can potentially have an impact in non-linear processes, see Guyon and Elisseeff [ 4 ]. There is substantial research covering the topic of variable selection using linear methods, such as for instance Hocking [ 5 ], but these techniques might not be ideal when intended for non-linear modelling. There is relatively little literature covering the issue of variable selection of non-linear processes from a combinatorial approach. The basic assumption is that in non-linear processes the way in which different independent variables interact with each other can be highly complex. Identifying which combination of variables work better for a non-linear problem is clearly not trivial, see Yuan and Lin [ 6 ]. There are some interesting methods, such as for instance Rech and Terasvirt [ 7 ], using polynomial approximation. The drawback of this type of approach is that it is only applicable when there is a relatively small number of variables. Ye and Sun [ 8 ] proposed an iterative method in which starting from all the variables considered one, of the variables is dropped and the resulting set of variables is used, using neural networks, and then the results compared. The stock market, as many other fields, has seen a large increase in the number of data available. More specifically, many researchers and practitioners have developed large amount of technical indicators. Getting into the details of these indicators is beyond the scope of this article but it is important to mention that they are typically constructed using historical data such as for instance the closing price of a stock. A moving average is a well-known technical indicator [ 9 – 15 ]. A simple moving average can be constructed as the average of the closing price of a certain stock or index over a certain period of time. There are multiple different technical indicators and strategies based on those indicators with diverse levels of profitability [ 16 – 19 ]. Neural networks have been applied successfully to the field of stock market forecasting [ 20 – 25 ]. One of the frequently mentioned drawbacks of neural networks is the issue of local minima [ 26 – 29 ] which can cause the neural network to generalize poorly or in other words, generate poor forecast when faced with new data. In this regard there has been a focus on reducing the dimensionality of the data to avoid having the neural network stuck in this local minima [ 30 – 34 ]. In this paper we propose a non-linear combinatorial approach for variable selection applied to stock market technical indicators. Given the number of possible technical indicators that are available today, is clear that not all possible combinations can be tested. In this work we use a pool of 35 technical indicators, so the number of possible combinations is staggering. Because of that the proposed approach resorts to randomization. The algorithm starts by generating a preset number of combinations each with a size of half the number of available indicators. The reason for using such size is because the maximum number of combinations for a given n and k , that is the binomial coefficient n choose k , is attained for k=bn 2c . This is evident by inspecting the Pascal’s Triangle, but can be proved using the properties of the Newton binomial. From this initial set of combinations, new combinations are generated randomly retaining the best ones in an iterative process that ends when the stop condition is met. The proposed method is shown to improve the baseline approach, that is using all the available indicators, when applied to the task of predicting market trends. As a case study for the proposed method, this paper focuses on the chinese stock market. China stock market is a very dynamic and of increasingly importance due to the economic grow of China. The most relevant chinese stock indexes have been considered. The strategy described in this paper has obtained good results and better combinations of technical indicators have been identified for such indexes. The remaining of the paper is organized as follows: Section 2presents the proposed approach. Section 3shows the application of the proposed approach to the China stock market. The results are discussed in Sections 4and 5presents the conclusions of the paper. Mathematics 2020,8, 1301 3 of 15 2. Technical Indicator Selection Approach Let Xi T(t) be tuple of T values of the i -th technical indicator from a pool of up to N nonlinear technical indicators computed at the time period t (usually the time period is measured in days, but could be weeks, months or whatever), such as for instance a moving average: Xi T(t) = {Xi(t−(T−1)),Xi(t−(T−2)), . . . , Xi(t)}(1) where Xi(t)is the value of the i-th technical indicator evaluated at time t. Let RT(t) be a vector that groups the direction of the change of the price of a stock or index, in the period from t−(T− 1 ) to t , that is RT={ 0, 1 }T with 0 meaning that the stock increases or remains constant at the end of a period, 1 meaning otherwise. Additionally, let ˆ φ define a nonlinear mapping from Xi T(t)to RT(t) ˆ φ(X1 T(t),X2 T(t), . . . , XN T(t)) = ˆ RT(t)(2) where ˆT(t) is an estimation of RT(t) . In order to guarantee that an estimator ˆ φ can be found is necessary to assume the following: Assumption 1 (Ground truth function existence) . It is assumed that, φ , a mapping from Xi T(t) to RT(t)exists. Technical indicators in the stock market can produce contradictory signals and some non-linear techniques can have local minima issues when using high dimensionality input variables, (large N or T value). Therefore it might be convenient to find a combination of the technical indicators Xi T rather than using all N available indicators. We present a combinatorial selection approach for technical indicators that do not have to be linear variable combination in non-linear processes. The steps are as follows: 1. Split the available instances of Xi T(t) and RT(t) data into two subsets, an estimation subset Se,{Xi T,e(t) , RT,e(t)} and a validation (To keep the notation as clear as possible we use here the term “validation” with the meaning of test) subset Sv,{Xi T,v(t),RT,v(t)}. 2. Generate Cs , a set of M combinations of bN 2c random numbers in the range { 1, 2, . . . , N} denoted from i1 to ibN 2c . Check for repetition within each combination. If there is repetition, leave out the repeated numbers and keep generating random numbers in the aforementioned range until there is no repetition. Similarly, check that there are no repeated combinations and proceed to replace the redundant ones. 3. For each of the Mcombinations in Cs, denoted as I∈Cs, perform the following steps: (3a) Compute ˆ φ , i.e., the estimated non-linear classification mapping, using any technique of choice. In this case, the nonlinear mapping will have as arguments Xi T(t) , ∀i∈I . Using neural networks as an example, this step involves training a neural network with the training data set {Xi T,e(t),RT,e(t)}with i∈I. (3b) Evaluate ˆ φ over the validation set. Let ˆ RT,v denote the estimated classification output of RT,v. (3c) Calculate the error ξT(t) of the non-linear classification approach for each instance in the validation set, so that ξT(t) = (0 if ˆ RT,v(t) = RT,v(t), 1 Otherwise with the resulting total error being: ξTotal =∑∀t∈SvξT(t) card(Sv)(3) Mathematics 2020,8, 1301 4 of 15 where card(Sv) denotes the cardinality of Sv . This is therefore the total error for the initial random combination of technical indicators chosen in step 2. (3d) Randomly generate a single value ia∈ { 1, 2, ..., N} that would denote a technical indicator candidate to be added to the combination chosen in step 2. Check for repetition with the previously generated N 2 values. If there is repetition, randomly generate another value ia . Repeat this step until there is no repetition. (3e) Randomly generate a single value ir∈ {i1 , . . . , iN 2} . This value will be used later to denote a technical indicator to be removed from the combination chosen in step 2. (3f) Form a new combination of technical indicator indexes Iup as Iup ,I∪ {ia} . In the same fashion, form a new combination Idown as Idown ,I− {ir}. If some of these combinations are already in Cs repeat either step 3d or 3e until a combination different from those of Cs is obtained. (3g) As in step 3a, compute two new mappings, denoted ˆ φup and ˆ φdown using this case as inputs arguments the technical indicators given by the index combinations Iup and Idown respectively. (3h) As in step 3c compute the resulting total error of evaluating the two mappings computed in the previous step over the validation set. Denote these total errors as ξTotal up and ξTotal down. (3i) Given the three previous index combinations I , Iup , Idown and their resulting total errors ξTotal,ξTotal up and ξTotal down pick the two combinations with the smallest error. (3j) Substitute the initial combination I by the two combinations picked in the previous step. This will double the number of combinations in set Cs , i.e., Cs will contain 2 M combinations after this step. 4. Retain the M combinations in Cs with the smallest error and discard the remaining M combinations with greatest error. 5. Find the minimum ξTotal of all the combinations I∈CS. 6. Repeat step 3starting from 3d until a certain stop condition is met. Here it is proposed to check if a certain objective error is achieved or a maximum number of iterations is met, so that an infinite loop is avoided. Remark 1. This strategy can be easily parallelized as the tasks in step 3can be done independently for each combination, hence can be done in parallel, with one exception. The latter part of step 3f, that is the rejection of repeated combinations, cannot be done in parallel and must be done sequentially in a separate step outside of step 3. Remark 2. The number of combinations in Cs , that is M , and the number of iterations are related in the sense that similar performances can be achieved by using a greater M and fewer iterations or vice versa. Besides the differences in performance due to the randomized nature of the proposed strategy, a practical difference can lead to one choice or the other. With a greater M one can exploit the parallelizable nature of the algorithm, whereas in the case of a high number of iterations that cannot be made. To illustrate the proposed approach consider a simple example with just two combinations (i.e., M=2) and one iteration. If for instance, we assume that we have a total of 6 technical indicators to choose from, i.e., {X1 5 , X2 5 , X3 5 , X4 5 , X5 5 , X6 5} , where the sub-index 5 means that each of the indicators are evaluated over five periods of time. There is also a related classification vector R5 identifying up and down movements in the stock at each time t (in this case R5∈ { 0, 1 }5 ). First, the algorithm selects randomly 2 combinations of 3 initial technical indicator indexes. For example: Cs={I1,I2}={{3, 5, 6},{1, 2, 3}} Mathematics 2020,8, 1301 5 of 15 Then the non-linear classification error is estimated for this configuration; let us assume that the obtained value is (with a slight abuse of notation the parameters of each combination will denote in this example the set of the parameters of both combinations): ξTotal ={0.6, 0.5} Then the indexes iaand irare computed for each combination: ia={1, 4}ir={6, 2}. The addition of the new technical indicator index is done randomly, ensuring that there is no repetition, i.e., each input variable (technical indicator) is used only once. The index removed is also computed randomly. Then the combinations Iup and Idown are formed: Iup ={Iup 1,Iup 2}={{3, 5, 6, 1},{1, 2, 3, 4}} Idown ={Idown 1,Idown 2}={{3, 5},{1, 3}} Note that in every combination generated so far no index is repeated and that there are not repeated combinations. Once the new combinations are formed, their total classifying errors are computed: ξTotal up ={0.7, 0.3} ξTotal down ={0.4, 0.2} ξTotal ={0.6, 0.5} For every combination in Cs we choose the two combinations (from I , Iup and Idown ) with the smallest error. From the fist combination we choose then, Idown 1 and I1 . On the other hand, from the second combination we choose Iup 2and Idown 2. Therefore, the augmented Cswill consists of: Cs={Idown 1,I1,Iup 2,Idown 2} with their errors: ξ={0.4, 0.6, 0.3, 0.2} We order the combinations using the error as sort criterion: Cs={Idown 2,Iup 2,Idown 1,I1} ξ={0.2, 0.3, 0.4, 0.6} Now we can reduce the numbers of combinations to its original number ( M= 2) picking the two with the smallest error: Cs={Idown 2,Iup 2} with errors: ξ={0.2, 0.3} Then at the end of this first iteration the algorithm would pick the combination Idown 2 as the best technical indicator combination, as it has the lowest error (0.2). Thus, the technical indicators proposed to forecast the direction of the change of price will be {X1 5,X3 5}. In practice, the number of combinations and iterations will be determined by the computing power available. The process thus will be repeated until a stop criteria is reached (that is, a maximum number of iterations or a target classification error). Mathematics 2020,8, 1301 6 of 15 3. Chinese Equity Market Application 3.1. Data and Methodology The Chinese equity market is an increasingly important market propelled by the large economic expansion of the Chinese economy over the last few decades. The Chinese equity market is divided into two major stock exchanges. The Shanghai and the Shenzhen Stock Exchange with several major stock indexes describing the performance of those markets. We used 6 different stock indexes describing the Chinese stock. For completeness purposes, and to exclude some form of regional bias in the results, we also used to other international (non-Chinese) stock indexes (see Table 1). Table 1. Stock indexes. Indexes A50 FTSE China A50 index composed of the largest chinese companies. CSI 300 Largest 300 companies listed in the Shenzhen and Shanghai Stock Exchanges CSI 800 Largest 800 companies listed in the Shenzhen and Shanghai Stock Exchanges Shanghai Composite Index composed of all the stocks listed in the Shanghai Stock Exchange Shenzhen Component Index composed of the largest 500 companies in the Shenzhen Stock Exchange SSE 50 Index composed of the largest 50 companies in the Shanghai Stock Exchange Euro Stoxx 50 Index composed by 50 of the largest companies from 11 Euro zone countries New York Composite Index composed of all the stocks listed in the New York Stock Exchange As described in the previous section the selection approach is used to forecast the direction of the movement of the stock index (up or down) in the next time period rather than the exact end price for that period. Daily closing prices for all the indexes mentioned in Table 1were collected from the Bloomberg database for the period from 14 February 2007 to 30 March 2020. The returns of those index can be seen in Figure 1. Positive or zero returns will result in an RTvalue of 0 and 1 otherwise. Figure 1. Returns of the indexes (measured in percentages). Mathematics 2020,8, 1301 7 of 15 The proposed approach was used to identify an appropriate combination of technical indicators trying to describe the performance of the equity market. Stock technical indicators are indicators typically based on historical performance of the stock as well as the traded volume of that stock. There is an ever increasing amount of technical indicators in the existing literature which can generate contradictory signals. We used 35 commonly used stock technical indicators (see Table 2) extracted from the database Bloomberg. Table 2. Technical indicators. Ct denotes the current price and Lt and Ht are the minimum and maximum prices in period t and MA means moving average. The exact formulas for some of the indexes are proprietary with the indicators for specific stocks obtainable from databases such as Bloomberg. Source: Blomberg, Kim [35]. N Indicator Description 1 SMAVG (50) 50 days simple MA. ∑49 i=0Ct−i 50 2 SMAVG (100) 100 days simple MA. ∑99 i=0Ct−i 100 3 SMAVG (200) 200 days simple MA. ∑199 i=0Ct−i 200 4 Volume Total traded volume 5 Stochastic %K (14-day) Ct−min(Lt−n,∀n∈{1,...,14}) max(Ht−n,∀n∈{1,...,14})−min(Lt−n,∀n∈{1,...,14}) 6 %D (3-day) 3 days MA of stochastic %K. ∑2 i=0Kt−i 3 7 %D (5-day) 5 days MA of stochastic %K. ∑4 i=0Kt−i 5 8 Slow %D (3-day) MA of the 3 days %D.∑2 i=0Dt−i 3 9 Slow %D (5-day) MA of the 5 days %D. ∑4 i=0Dt−i 5 10 Momentum (10-day) Change in price over a 10 days period. Ct−Ct−10 11 Moving average (5D) 5 days MA of 10-day Momemtum.∑4 i=0Mt−i 5 of Momentum (10-day) 12 ROC (daily) Change in price in % over 1 day period. Ct Ct−1100 13 Moving average (5D) of ROC 5 days MA of ROC. ∑4 i=0ROCt−i 5 14 Williams (14) 14 days Williams’ indicator. max(Hn,∀n∈{1,...,14})−Ct max(Hn,∀n∈{1,...,14})−min(Ln,∀n∈{1,...,14}) 15 A/D oscillator Accumulation distribution indicator. Ht−Ct−1 Ht−Lt 16 MA (5) 5 days moving average. ∑4 i=0Ct−i 5 17 MA (10) 10 days moving average. ∑9 i=0Ct−i 10 18 Disparity 5 Ct MAt 19 Disparity 10 Ct MAt 20 OSCP MAt−MAn MAt 21 CMCI (13) (Ht+Lt+Ct)/3−∑(Ht−i+1+Lt−i+1+Ct−i+1) 3n 0.015(∑|Ht−i+1+Lt−i+1+Ct−i+1−∑((Ht+Lt+Ct)/3)| n ) 22 RSI (14) on Close Relative strength index. 100 −100 1+Average up Average down 23 MA (250) 250 days simple MA. ∑249 i=0Ct−i 250 24 Z-score Distance in standard deviations from MA 25 AMAVG(14,2,30) Exponential MA 26 EMAVG (5) on Close 5 days exponential moving average with exponential term 2 t+1 27 TMAVG (5) on Close 5 days triangular moving average with factor t+1 2 28 VMAVG (5) on Close Variable MA with smoothing based in volatility 29 MACD(12,26) T1exponential MA (fast) −T2exponential MA (slow) 30 Hurst(25) Exponential MA with mean reversion assumption. 31 FG(5) Ratio of buying and selling strength (5 days) 32 Kairi (Simple,25) Deviation of prices from its MA 33 Elder Force Index Relationship between price and trading volume movements 34 JKHL Index Relationship between new high and lows smoothed by two MA. 35 RMI(Close,14,10) Relationship between overbought and oversold levels Mathematics 2020,8, 1301 8 of 15 The main hypothesis is that it is possible to construct an algorithm that estimates an appropriate combination of inputs (technical indicators) for non-linear forecasting tools, generating lower error rates when forecasting the direction of stock movements than using directly all the technical indicators available. Another hypothesis is that on average such algorithm generates lower error rates than completely random combinations of the input variables (technical indicators). The proposed approach was implemented in Matlab using neural networks as classifiers. 100 initial configurations times 2500 iterations were carried out for each index, which translates in 250,000 neural networks per index and a total of 2,000,000 neural networks (8 indexes). The neural networks used were back propagation classification neural networks with one hidden layer with 25 neurons and trained with the Levenberg-Marquardt rule. The value for the number of neurons was chosen as a result of the preliminary sensitivity analysis on the number of neurons presented in Section 3.2. 3.2. Results Previously to testing the proposed strategy, a preliminary sensitivity analysis on the number of neurons has been carried out to find the most convenient number of neurons in the hidden layer. The full set of 35 technical indicators was used, and the number of neurons in the hidden layer was increased from 25 to 25,000 in steps of 25 neurons. Simply increasing the number of neurons did not appear to increase the classification accuracy of neural networks for the performance on stock index in the following period (t+1) (see Figure 2) for any of the six indexes analyzed. Figure 2. Sensitivity analysis of the error rate (using directly neural networks) as the number of neurons is increased. Mathematics 2020,8, 1301 9 of 15 On the other hand, Figure 3shows an example of the evolution of the error rate (misclassification of up/down days) in the training of one the neural networks. It can be seen that training improves the fitting to the data up to a significant number of training iterations, showing that the NN is really learning the ground truth function φ. Figure 3. Example of the evolution of the error rate as the number of iterations increases. The indicator selection approach is a combinatorial approach that can be used to select an appropriate combination of variables in non-linear models, using techniques such as neural networks. In the example illustrated in this article the proposed approach was implemented in six different Chinese stock indexes plus two world indexes. The error rate obtained using the algorithm in combination with neural networks was lower than the error rate obtained using directly neural networks including all the 35 available variables, see Table 3. The average improvement in the error rate (over all the considered indexes) was 9.1%. It turns out that this is a very good result considering how difficult is the task of predicting the movements of the market and the great amount of benefits that can be realized even with a small improvement in the forecasting. Moreover, in some of the indexes the improvement is quite high, in excess of 11% (A50, Shanghai Composite and SSE50). A very interesting finding is that the baseline approach, that is, considering all the technical indicators available for forecasting yields error rates greater than 50% in some cases (A50, CSI800, Shanghai Composite, SSE 50 and Euro Stoxx 50). This means that tossing a coin produces better results than using the full pool of indicators. The reason for that is that, as pointed out in Section 3.1, some of the technical indicators produce contradictory signals. Table 3. Classification errors (up and down index movements) of the proposed approach using neural networks compared to the direct application of neural networks using all the 35 technical indicators. Index Direct Proposed Improv. Combinations (Error %) (Error %) (%) A50 54.0 41.2 12.8 (1,2,4,6,7,10,12,13,14,15,19,21,23,25,34,35) CSI 300 46.9 40.3 6.6 (2,3,4,7,8,11,12,13,15,19,21,25,26,29,34) CSI 800 50.7 41.1 9.6 (2,4,5,6,9,12,13,16,17,20,22,28,30,32,33,34) Shanghai Composite 52.3 40.1 12.2 (1,2,4,5,6,9,10,12,13,15,16,18,19,20,21,22,24,33) Shenzhen Component 45.6 40.7 4.9 (2,4,5,8,10,12,14,19,21,22,25,28,29,30,33,34,35) SSE 50 51.0 39.6 11.4 (1,2,3,7,9,10,11,12,20,21,22,24,25,27,28,30,32,35) Euro Stoxx 50 50.1 41.8 8.3 (3,4,7,11,17,18,20,22,25,27,28,31,33,34) New York Composite 47.2 40.7 9.0 (1,3,7,8,9,11,14,15,17,19,20,25,27,28,29,33,34) Average 49.7 41.0 9.1