Prediction of European Stock Indexes Using Neuro-fuzzy Technique

Purpose of the article: The paper is focused on the forecast of stock markets of the Central European countries, known as V4, by means of soft computing. The tested model is constructed by a combination of fuzzy logic and artificial neural networks. A total of four SAX, PX, BUX, WIG stock indices differing in their liquidity and efficiency are selected for the forecast. Methodology/methods: The methods of analysis, synthesis and techniques of mathematical neuro-fuzzy modelling were used to achieve this goal. The proposed neuro-fuzzy decision-making model consists of 3 input variables, one block of rules (with 21 fuzzy rules) and one output variable predicting the normalized price of stock indexes of the selected countries. The input variables have three attributes (L – large, M – medium, and S – small). Scientific aim: The aim of the paper is to create a suitable model that will be used to forecast stock indices of the Central European countries with a relatively low error. Findings: The developed ANFIS model is a suitable tool for predicting stock indexes. The importance of the neuro-fuzzy model can be seen especially in the fact that it shows a strong predictive capacity of both efficient and less efficient stock markets. Conclusions: The paper discussed the design of the neuro-fuzzy model as a supporting tool for predicting the selected stock indexes listed on the European stock markets. For further research, it would be appropriate to extend the proposed model with other significant fundamental indicators, or to incorporate technical and psychological indicators and to monitor the strength of the revised model also in several stock markets, for example according to the geographical distribution.


Introduction
Stock markets are an inherent part of all national economies. According to Billah et al. (2016), it is actually the most important way of acquiring capital. It is a big challenge for financial analysts, traders and brokers to identify the best moment for purchase or sale of equity instruments. Rajab, Sharm (2019) mention that stock price forecasting is a complicated and difficult task due to the chaotic behaviour and a high level of uncertainty of equity instrument prices in the market. The proposal of a highly accurate, simple and comprehensible forecasting model is of utmost importance in this area. Chen et al. (2016) add the numerous factors potentially affecting stock prices in the stock markets need to be considered. Every trader attempts to make their own forecasts, either subjectively, i.e. through models based on their personal feelings and experience, or objectively using various types of software. Although a number of techniques for improving the stock index forecasts have been developed, there is no universal model yet that would be suitable for various types of data and applications. Even a slight improvement of forecast accuracy may bring considerably higher returns to investors. A huge amount of research and scientific works have been published recently, searching for optimal forecasting models for the stock markets. The majority of research works focused on forecasts use the statistical methods of time series analysis. However, these models are considerably restricted, in particular when applied to seasonal and non-linear problems related to uncertainty. For this reason, non-linear methods such as neural networks, fuzzy logic and genetic algorithms have been attracting increased attention.
Tung, Le (2017) state that fuzzy logic and artificial neural network represent a method with a wide range of application in forecasting future changes of stock prices, exchange rates, commodities, and other financial instruments. Fuzzy logic allows definitive conclusions to be drawn from unclear, ambiguous or inaccurate information. The artificial neural network has been widely accepted mostly for its capacity to learn to reveal the relationships between non-linear variables. The artificial neural network primarily overcomes the statistical regression models and allows a deeper analysis of large data sets. A hybrid neuro-fuzzy system was created by a combination of artificial neural networks and fuzzy logic. The system strives to use the advantages of both artificial intelligence methods. Negnevitsky (2002) emphasises that the adaptive neuro-fuzzy inference system (ANFIS) has become one of the widespread neuro-fuzzy systems. The aim of the paper is to create an ANFIS model for modelling and forecasting the development of stock index return of a financial market with limited liquidity and thus use the advantages of both the neural network and fuzzy logic. The ANFIS model, as explained by Cheng et al. (2007), has been selected for its strong capability of modelling and computing flexibility, therefore also for its suitability for modelling the systems of complex, dynamic and non--linear relationships common in the financial markets. Cheng et al. (2007) use the adaptive neuro--fuzzy inference system for forecasting investors' behaviour (when and whether to buy or sell) in the stock market in expectations of significant interest rate changes or political election results, for instance. The selected input variables are the DJIA, Nikkei 225, and FTSE indexes, NYSE market turnover, discount rate changes, results of S&P 500 and political events. Their research findings show the forecasting potential of the ANFIS in financial applications but at the same time, they suggest that certain market behaviours are too complex to be predicted. Abbasi, Abouec (2008) explore the current stock price trend using the adaptive neuro-fuzzy inference system in the Tehran exchange. The study results show that the development of stock prices in the market can be forecasted with a low error rate. In their article, Boyacioglu, Avci (2010) present the ANFIS model for forecasting the Corbex index in the Zagreb exchange. The input data are monthly macroeconomic indicators, namely the DJI, DAX and BOVESPA indexes and the return of ISE National 100. The selected data set covers the period from 1990 to 2008. The set is divided into two parts and the first data set (122 observations) is used for model testing. The second data set (106 observations) is used for training of the designed model. According to the authors, this approach is useful for forecasting in the stock market within its limits.

Literature Review
Esfahanipour, Aghamiri (2010) developed a neuro-fuzzy inference system for forecasting the prices of equity instruments based on the Takagi-Sugeno-Kang rule based system. The created model applies a technical index as an input variable. The authors implement fuzzy c-mean clustering for identification of the number of rules. The Gaussian membership function has been selected. The proposed model is tested on the Tehran stock exchange index (TEPIX). This index was successful in forecasting the index development with high accuracy of 97.8% in several experimental tests. Wei et al. (2011) propose a hybrid model for forecasting the prices of equity instruments of the TAIEX index that uses technical indicators as forecast factors and in the intelligent inference system as a forecast algorithm, which provides comprehensive rules to ordinary investors. The authors selected the technical indicators based on a correlation matrix and then used the method of subtractive clustering to granulate the data set of the basic technical indicators to a set of data on language variables and used FIS for extracting non-linear relationships (rules) among the data in the set.
Finally, they applied an adaptive network for optimization of FIS parameters to improve the forecast accuracy and create comprehensive rules.
On the other hand, the research of Chen et al. (2013) focused on the fundamental powers affecting the return of equity instruments and volatility across domestic and foreign stock markets. The authors examined the correlation of other markets with the stock market in Taiwan. Highly correlated markets were selected as the input variables for the ANFIS prediction model. In their article, Chakraborty et al. (2016) accepted a fuzzy approach based on grid partition, discussing the factors of uncertainty in forecasting stock of any company. The parameters of the determination rules are optimised adaptively using a hybrid neural network mechanism. This ANFIS model focuses on solving the problem of stock price prediction with 94-95% accuracy. In their study, Trinato et al. (2015) perform the prediction of three blue chip shares of an Indonesian bank using an adaptive neuro-fuzzy inference system with Takagi-Sugeno rules and generalized bell membership function. The study results show that the ANFIS performed a good prediction of the selected shares. Chandar (2016) proposed a neuro-fuzzy approach based on subtractive clustering for prediction of prices of the Apple stock. The author used technical indicators as input variables. The simulation results show his model was considerably better than the ANFIS or sole subtractive clustering. Atsalakis et al. (2016) present a model based on the neuro-fuzzy approach for forecasting short-term stock trends in turbulent times of the stock market. The proposed methodology is tested and evaluated using the data on shares from the New York Stock Exchange. The data set demonstrates transactions that took place in the course of four turbulent market periods. Their model proved useful in business simulations and provides better results than the Buy and Hold strategy.
In the proposed model, Chen et al. (2016) first applied the gradual regression analysis to ensure the objective selection of technical indicators and then created a forecast model in combination with the ANFIS. The results show the superiority of the proposed combined model that surpassed other models in terms of the RMSE and profitability. Vlasenko et al. (2018) proposed a hybrid five-layer neuro-fuzzy model and a corresponding learning algorithm with the application in prediction tasks of stock market time series. The key difference between the conventional ANFIS architecture and the proposed model is in the fourth layer, where the multi-dimensional Gaussian function is used instead of the polynomials to achieve better computing performance and representation capacity in the processing of highly non-linear and volatile data sets. The experimental research results showed obvious advantages of the described model. Rajab, Sharma (2019) propose an effective and easily interpretable ANFIS for prediction of share prices using multiple technical indicators. The interpretability is ensured by reducing basic rules. Moreover, learning during the model optimisation phase is restricted so that simple restrictions affect the updates of the fuzzy set parameters so that it remains easily interpretable and the prediction accuracy is not threatened. The authors use the Bombay stock exchange index, CNX Nifty and S&P 500. The simulation results show that the proposed system achieves better balance between accuracy and interpretability compared to other methods.

Adaptive Neuro-Fuzzy Inference System
Adaptive neuro-fuzzy inference system (AN-FIS) is a combination of an artificial neural network (ANN) and fuzzy inference system (FIS). Thanks to its design, the ANFIS can benefit from both soft computing techniques, but also overcome their shortcomings. Compared to ANN, the ANFIS model is more transparent to users and causes fewer errors in remembering. As a result, there are several advantages of the ANFIS, including adaptive ability, nonlinear ability and rapid learning capability. Neural networks can easily learn from data. However, it is difficult to interpret the acquired knowledge as a meaning associated with every neuron and every mass that is quite difficult to understand. In contrast, as described by Mathur et al. (2016), fuzzy logic itself cannot learn from the data. However, fuzzy models are easy to understand because they use linguistic terms rather than numeric and IF-THEN rules structure. Language variables are defined as variables whose values are words or sentences in natural language with associated degrees of membership. The fuzzy set to which the linguistic variables belong is an extension of the crisp set where the element can have full or no membership. However, fuzzy sets also allow for partial membership, which means that an element may partially belong to more than one set. The ANFIS constructs a fuzzy inference system (FIS) whose parameters of the membership function are derived from training examples. The most commonly used fuzzy inference systems are Mamdani and Sugeno. The main difference between Mamdani and Sugeno is that the output function of the Sugeno membership is either linear or constant (Arkhipov et al., 2008). However, the output functions of the Mamdani membership may be triangular, Gaussian, etc. In this study, the Sugeno type fuzzy inference system was used, as the Sugeno system is more computationally efficient than the Mamdani type. Mamdani is more dependent on expertise. However, the Sugeno type is trained with real data, as added by Şahin, Erol (2017). Mathur et al. (2016) describe the ANFIS model. In the ANFIS, the crisp input signal is converted to fuzzy inputs using the membership function. The fuzzy input together with the membership function is then fed to the neural network block. A neural network block consists of a rule base that is connected to an inference engine. The back propagation algorithm is used to train the inference engine to select the right rule base. After the training, appropriate rules can be generated and omitted from the neural network block to provide an optimal output. The language output from the neural network block is then converted to a crisp output by means of a decryption unit. The structure of the neuro--fuzzy model consists of different adaptive layers. Each of these layers has nodes with an associated network of transfer functions through which the fuzzy inputs are processed. The output from these nodes is then merged to give a single crisp output, since the ANFIS configuration allows only one model output. This crisp output is feedback as an input to the model and compared to the set value. If any deviation occurs, the error signal thus generated becomes an input to the ANFIS, maintaining stability in the system. Yilmaz (2003) describes the ANFIS structure as follows: A neural network consists of 5 layers in addition to the input layer (Layer 0).
Layer 0: The input layer has n nodes, where n is the number of inputs to the system. Layer 1: A fuzzification layer in which each node represents a value of membership to a linguistic concept represented by a mean value membership function: Where ai, bi, ciare the parameters of the membership function. These are adaptive parameters. Their values are adjusted through the back propagation algorithm during the learning phase.  (2) Figure. 1. Basic structure of the ANFIS. Source: Salleh et al., 2018. Layer 3: Is a normalization layer that normalizes the strength of all rules according to the following equation: Where wi is the force i th of the rule that was calculated in layer 2. The node i calculates the ratio of the force of this rule to the sum of all the rules. In this layer there are nodes p n .
Layer 4: Is a layer of adaptive nodes. Each node in this layer calculates a linear function where the coefficients are adjusted using a multi-layer feed-forward neural network.
p i 's are the parameters where i = n + 1 and n is the number of inputs to the system (i.e. the number of nodes in layer 0). This equation was given for two inputs. Finally w i is the output from layer 3. These parameters are updated by the learning step. The least squares approximation is used in ANFIS. In the temporal model, back-propagation algorithm is used for training. Layer 5: The output layer whose function is the sum of the net outputs of nodes in layer 4. The output is calculated according to: Where wifi is the output of node i in layer 4. This indicates the consequent part of rule i. The overall output of the neuro-fuzzy system is a summary of rule consequents.
Among the advantages of the ANFIS is the robustness of the results generated by the model. The ANFIS, like neural networks, is capable of generalization. Also, the ANFIS is able to take crisp output and represent it in the form of membership and fuzzy rule functions, from which it generates crisp output. It is a very promising tool that needs to be explored in solving various non-linear and complex problems. However, as further described by Salleh et al. (2017), the ANFIS computational costs are high due to complex structure and gradient learning. This is a significant problem especially for large input applications. In general, the constraints are: a) the type and number of membership functions, b) the location of membership function, and c) the curse of dimensionality. In addition, a compromise between interpretability and accuracy is considered a major problem with this system. In the context of the AN-FIS's interpretability with grid partitioning, it creates a large number of rules that model users may not understand easily and easily. The interpretability is therefore compromised, although a large number of rules contribute to improving the model accuracy. As the authors further state, the ANFIS works well when there are no more than five inputs.     this stock index dates back to 1991. Currently, the WIG contains over 300 companies. The Budapest Stock Exchange is the second largest stock exchange in Central Europe in terms of market capitalization and liquidity. The official index of this exchange is the BUX stock index. This index consists of approximately 20 shares of blue chips listed on the Budapest Stock Exchange.

Proposed model
Daily stock indexes closing rates for the selected period 2014 to 2018 are used. Since the stock index value is relatively large and the index differences are significant, which may have a negative impact on the model performance, it is necessary to pre-process the original data using the following standardization procedures used in Li, Xionga (2005) and Zhai et al. (2010): where x t is the closing daily price of the stock index at time t, Then the vector of the variables entering the model is defined as follows: The ANFIS model can be built by dividing the input and output data into rules. This can be achieved using a number of methods. The grid partition method has been selected for this paper. The grid partition technique has been applied to generate FIS by using given training data set therefore based on the total amount and category of the membership function. The grid partition approach divides data space into grids as mentioned by Talpur et al. (2017). A fuzzy inference system (FIS) type Takagi-Sugeno is created with three input variables and one output variable predicting the normalized price of selected stock indices of the Central European countries. Given the nature of the data coming from the stock market, Gaussian membership functions have been chosen that best fit their nature. This type of the membership function is also recommended by Talpur et al. (2017).   The created FIS is divided into three attributes (LOW, MEDIUM, HIGH). The actual structure of the FIS model is shown in Figure 6. The proposed model uses Takagi-Sugeno rules in the form of IF-THEN, generated by the adaptive neuro-fuzzy inference system. The ANFIS created a total of 27 rules. Figures 7 to 10  The created ANFIS model uses the hybrid--learning (training) algorithm. This learning algorithm, as reported by Loganathan, Girija (2013), combines the least-squares estimator and gradient descent method. Initially, each fuzzification neuron is assigned initial functions in the form of Gaussian distribution with certain parameters. During the training process, the training data set is presented to the ANFIS cyclically. Each cycle through all the training examples is called an epoch. In the ANFIS learning algorithm, each epoch comprises of a forward pass and a backward pass. The purpose of the forward pass is to form and adjust the consequent parameters, while that of the backward pass is to adjust the parameters of the activation functions. For this model, the number of training epochs is 30 and training error tolerance is set to zero. Setting the training error tolerance to zero is recommended in specialised literature such as Azar (2010) or Bohra, Bhatia (2012) and many others because of the uncertainty of behavioural error in training. The training process stops whenever the maximum epoch number is reached or the training error goal is achieved.
The figure shows that the ANFIS model is almost perfectly trained on the selected training data set. The crosses indicate the values generated by the ANFIS model. The circles then indicate the actual stock index values   adjusted according to normalised procedures. It can be seen that most of the training values are close to or equal to the actual values.
For the purposes of testing the ANFIS model, a smaller number of values have been chosen. Specifically, the model is tested on 30 days or test data. Figures 11 to 14 show the results of model testing. Again, the values generated by the ANFIS model are represented by a cross, while the actual values are represented by a circle.
To test the predictive capability of the model we developed, the model is first "trained" on one set of data and then "tested" on previously invisible data that we collected independently. Finally, the results are compared in terms of their accuracy. For this purpose, the RMSE is used, which compares the original data y t and the data obtained from the output of the model t y  . The mathematical notation of the RMSE pointer is as follows: The root mean average error of the training and test data for each stock index is shown in Table 4. The table shows that the smallest training data error is reported by the PX index with a very low 0.22% error. On the other hand, the biggest training mistake is shown by the more liquid WIG, or SAX with a value of 1.86% and 1.85% respectively. Within the ANFIS model testing, the most accurate prediction is made for the Hungarian BUX index with an error value of 0.79%. The largest errors in the model testing are less liquid stock indices, namely the SAX with 2.38% and the PX with 2.33%.
Based on the analysis of training and testing errors, it can be stated that the ANFIS model can be better trained for less liquid stock indexes, but when testing the model shows a higher error than for more liquid and   efficient stock indexes. Even so, the relative errors show very low values. Therefore, based on the research, it can be stated that the ANFIS model is an effective tool for the prediction of stock indexes of Central European countries.

Conclusion
The paper deals with application of soft computing tools for stock market prediction. Specifically, due to the non-linear and chaotic nature of stock markets, a combination of fuzzy logic and artificial neural networks is chosen. Four stock markets of the Central European countries have been selected for the research. Specifically, two less liquid Czech Stock Exchange and Slovakia Stock Exchange and two more liquid and efficient Poland Stock Exchange and Hungary Stock Exchange have been examined. Testing and training of adaptive neuro-fuzzy inference system is performed by main stock indexes of the selected PX, SAX, BUX, and WIG. The data are tested over a five-year period, with data on a daily basis chosen for prediction. The input variables to the model are the delay of the daily data by one to three periods. Based on low training and testing errors, the ANFIS model can be considered as an effective tool for predicting not only liquid but also less efficient EU stock markets. However, the disadvantages of the ANFIS model, often referred to as the black--box, should also be recognised and the rules derived from an artificial neural network are not easily understood. In addition, the model can be further refined to improve its performance, for example by validating and reducing the rules created by financial experts and analysts, or by selecting different input variables for the model.