1 Introduction

A stock index price prediction is prevalent issue in both economic and financial research. It is hard to forecast it due to its uncertain noise. A measure of volatility of stock index returns is a great challenge for investors in order to reduce uncertainty and risk in the stock market. Volatility is often described and measured by the variance of stock index returns. Despite many available models and techniques for predicting volatility of stock index returns, forecasting it accurately is very difficult.

Various econometric models have already been implemented for forecasting volatility of stock index returns. A breakthrough in this regard was the development of the Autoregressive Conditional Heteroskedasticity (ARCH) model, wherein the variance of the random error in a particular period depends on the values of the random errors in previous periods (Engle, 1982). One of its generalization is the Generalized Autoregressive Conditional Heteroskedasticity (GARCH) model (Bollerslev, 1986). Further modifications were introduced to take into account the specifics of the modeled markets: GJR-GARCH (Glosten et al., 1993), exponential GARCH Model (EGARCH) (Nelson, 1991), and various other GARCH family models (Pagan & Schwert, 1990; Franses & Van Dijk, 1996; Brailsford & Faff, 1996; Corrado & Miller, 2005; Tsay, 2005).

Another group of techniques for forecasting volatility of stock index returns includes neural networks. Neural networks are information technology tools based on the structure of neurons in living organisms. One of their capabilities is a linear and non-linear function (also given as data series) approximation (more details in Cybenko (1989)). The main advantage of using neural networks is the ability to recreate complex, non-linear relationships between variables based on historical data without assuming that historical data comes from a single and definable stochastic process (Atsalakis & Valavanis, 2009). They are commonly used in almost all areas of knowledge: medicine, chemistry, pattern recognition, data mining, visualization and finance. This approach appears to be very useful for stock markets, where the changing nature of the market has a potentially ongoing impact on assumptions used in modeling.

Neural networks began to be successfully used for financial series forecasting in the 1990s (Azoff, 1994). Krollner, Vanstone and Finnie (Krollner et al., 2010) point out that neural networks are the most widely used method for forecasting financial series, among all machine learning methods. Thanks to nonparametric capturing of nonlinearity, the most popular neural networks - multilayer perception and feedforward network - have allowed to obtain forecasts with lower forecast errors than standard methods, such as the regression method, ARMA, ARIMA, ARCH or GARCH (Kohzadi et al., 1996; Pacelli, 2012). Over the past several years, the literature has begun to develop hybrid models that combine machine learning methods and econometric methods. Pioneering work includes combining the popular linear ARIMA method with neural networks (Zhang, 2003). Such a method performs especially well for complex problems with a combination of both linear and nonlinear structures. Predictions obtained by the hybrid method were more accurate than those obtained separately using the ARIMA method and neural networks. To forecast chaotic time series, hybrid method - Elman’s neural network was used and the nonlinear autoregressive model NARX (Nonlinear Autoregressive with Exogenous Input). The analysis showed that the NARX-Elman neural network worked well as a forecasting tool for both artificially created chaotic series and real chaotic series (Ardalani-Farsa & Zolfaghari, 2010).

In finance neural networks are used in the study of financial series (Krollner et al., 2010; Zhang et al., 2023), stock prices (Bodart & Candelon, 2009; Niu et al., 2023), stock market indices (Radomska, 2021; Alkhoshi & Belkasim, 2018; Kumar & Murugan, 2013; Moghaddam et al., 2016; Song & Choi, 2023; Bhandari et al., 2022; Al-Akashi, 2022), forecasting volatility of many financial variables (Donaldson & Kamstra, 1996a, b; Salchenberger et al., 1992; Kristjanpoller et al., 2014; Ramos-Pérez et al., 2019; Liu et al., 2017; Hamid & Iqbal, 2004; Sahiner et al., 2021). For example, volatility analysis of the S&P 500 index using the LTSM40 network was conducted (Xiong et al., 2016). A nonlinear autoregressive neural network (NARX) to forecast the value of the WIG20 series, which is recursive and dynamic, was used in Radomska (2021).

The family of types of neutral networks is extensive with different topologies and learning algorithms. The main challenge is to select an appropriate one for a given problem. Certainly, the design of the network itself plays a large role; there is no single scheme that can be described as optimal (Thawornwong & Enke, 2004). The results of the research largely depend on the preparation and usage of appropriately selected input data (Walczak, 2004). Many articles deal with methodologies for selecting appropriate variables and preprocessing data in conjunction with neural networks as a predictive element (e.g. Lu et al. (2009)).

Another challenge is to determine what political-economical parameters affect stock index returns. Moreover, today’s financial market is global, so it is evident that stock prices from one country have an influence on the another one.

Various statistical and econometric tools are used in studies of the impact of strong stock markets on other countries’ markets. To analyze the interdependence between financial markets, one can use a standard linear model, constructed using the classical least squares method, as well as correlation analysis between indices representing individual stock exchanges (Dalkir, 2009) or cointegration analysis (Bachman et al., 1996) and frequency analysis (Bodart & Candelon, 2009). The interdependence of financial markets is also studied using vector autoregression models (VaR models), discrete choice models, GARCH-type models or Markov chain-based modeling.

Research on the impact of global markets on the Polish capital market has been discussed in the literature. In exemplary studies using the causality test, a strong dependence of the Polish market on the US market was demonstrated, while no opposite dependence was obtained (Dudek, 2009). Analyses of the dependence of the Polish market on major world markets, carried out using factor models, in turn, proved the dependence of the Polish stock market on European markets (Augustyński, 2011), where 13 stock indices on the American, British and German markets were compered and determined their impact on the WIG and WIG20 indices. The analysis showed that the British FTSE 100 and FTSE 250 indices and the German DAX have the greatest influence on the Warsaw indices. In Gluzicka (2013), the dependence analysis was carried out using correlation coefficients and a single equation linear model estimated using the least squares method. The study showed that the Polish stock market is mainly influenced by European markets. This situation occurred both in periods with long-term increases in quotations, as well as in periods of gradual declines in the quotations of the WIG20 index.

The aim of this study is to determine which stock market indices of different countries have influence on WIG20 and to what extent. Econometric models (i.e. GARCH) require strong assumptions that may not hold always true in practice. For example assumption regarding the distribution of random values. Therefore, this paper suggests a machine-learning method to compute a prediction value of volatility of stock index returns.

The input for each network is the last 3 values of WIG20 index returns volatility and the last 3 values of one of the considered foreign index returns volatility. Poland is located in Central Europe, therefore, two European (DAX and FTSE 250), two Asian (Nikkei 225 and Hang Seng), and two American (S&P 500 and Nasdaq 100) indices have been selected as foreign ones. The accuracy of the determined forecasts (output) was compared using ex-post measures such as: the Mean Error (ME), the Mean Percentage Error (MPE), the Mean Absolute Error (MAE), the Mean Absolute Percentage Error (MAPE), the Root Mean Square Error (RMSE).

The innovation of this work is the usage of a new neural network with three different activation functions. This type of network has been introduced in the paper (Fraszka-Sobczyk & Zakrzewska, 2024) for volatility predictions. In contrast to it, in the current article, the neural network input has been expanded by variables describing foreign indices. To our knowledge, other studies on the impact of foreign markets on volatility of WIG20 has not utilized such a constructed network.

2 Methodology

2.1 Volatility of stock index returns

Let the log returns of stock prices at time t be defined as follows:

$$R_t=\ln \frac{S_t}{S_{t-1}},$$

where \(S_t\) is the stock price at time t and \(S_{t-1}\) is the stock price at time \(t-1\). Volatility \(\sigma _t\) is the square root of the conditional variance of the log return process given its previous values:

$$\sigma ^2_t=Var[R_t\vert {\mathcal {F}}_{t-1}],$$

where \({\mathcal {F}}_{t-1}\) is \(\sigma \)-algebra generated by \(R_0, R_1,\cdots , R_{t-1}\).

2.2 Neural network

An artificial neural network (ANN) is composed of artificial neurons (Fig. 1). Each neuron has a vector of weights \([w_1,\ldots ,w_n]\) and an activation function \(f:[0,1]\rightarrow [0,1]\). Neurons proceed information from input vector \([x_1,\ldots ,x_n]\) to the output value y. The most popular activation functions are among others:

  • sigmoid: \(f(x)=\frac{1}{1+e^{-x}}\),

  • ReLU: \(f(x)=\left\{ \begin{array}{cr}\max (0,x)&{},x\ge 0\\ 0&{},x<0\end{array}\right. \),

  • tangensoid: \(f(x)=\tanh (x)\).

Fig. 1
figure 1

The artificial neuron

In ANNs neurons send information between each other. An output from one neuron is an input for the another one. The input is sent to initial neurons (from the 1st layer) and the output is got from final neurons (from the last layer). ANNs are described in details in Cochocki and Unbehauen (1993); Kohonen (1988).

One of the type of ANNs is Multi Layer Perceptions network (MLP) in MLP neurons are grouped in layers (see Fig. 2) where \(N_i^j\) are artificial neurons. In this network, information is transferred from one layer to the next one.

Fig. 2
figure 2

The Multi Layer Perceptions network

The main advantage of using neutral network is that such a structure can learn by processing example data. One of learning methods is supervised learning. The main algorithm of this method is presented in Algorithm 1. Initially, weights are set randomly. Then the algorithm takes prepared learning data: the input and the expected output. The data is processed by the network and the output is compared with the expected output. After this, the weights in neurons are updated. The learning process is described in details in Russell and Norvig (2010).

Algorithm 1
figure a

Supervised learning

In this article a Multi Layer Perceptions network is customized to predict volatility of the stock index more precisely. A schema of the proposed network is shown in Fig. 3. In the first layer, the activation function is \(f(x)=x^2\). In the second and in the third is the tangesoid function, and in the last it is \(f(x)=\sqrt{x}\). The number n denotes the number of days considered backward (the most recent are \(x_n\) and \(z_n\)). Firstly, each value is multiplied by a special ratio. Thanks to this operation the most recent value is the most valuable. As the input the data from two different stock markets is provided (\(x_i\) and \(z_i\)). After this operation the date is processed. This network learns by the supervised learning with a learning rate 0.01.

Fig. 3
figure 3

The proposed network

2.3 Measures of the predictive ability

Many measures of the predictive ability can be chosen to test the neural network’s accuracy. In this article, as the measurements for the best forecasting performance of each neural network classical indicators, such as the Mean Error (ME), the Mean Percentage Error (MPE), the Mean Absolute Error (MAE), the Mean Absolute Percentage Error (MAPE), the Root Mean Square Error (RMSE) are taken. The equations of these indicators are following:

  • The Mean Error (ME): ME=\(\frac{1}{n}\sum _{i=1}^{n}(\sigma _i- {\hat{\sigma }}_i)\),

  • The Mean Percentage Error (MPE): MPE=\(\left( \frac{1}{n}\sum _{i=1}^{n}\frac{\sigma _i- {\hat{\sigma }}_i}{\sigma _i}\right) \cdot 100\%\),

  • The Mean Absolute Error (MAE): MAE=\(\frac{1}{n}\sum _{i=1}^{n}\vert \sigma _i- {\hat{\sigma }}_i\vert \),

  • The Mean Absolute Percentage Error (MAPE): MAPE= \(\left( \frac{1}{n}\sum _{i=1}^{n}\frac{\vert \sigma _i- {\hat{\sigma }}_i\vert }{\sigma _i}\right) \cdot 100\%\),

  • The Root Mean Square Error (RMSE): RMSE=\(\sqrt{\frac{1}{n}\sum _{i=1}^{n}(\sigma _i- {\hat{\sigma }}_i)^2}\),

where:

\(\circ \):

\(\sigma _i\) is WIG20 index returns volatility at the moment i (calculated from some period of time),

\(\circ \):

\({\hat{\sigma }}_i\) is WIG20 index returns volatility forecast at the moment i obtained from a neural network,

\(\circ \):

n is the number of forecasts,

\(\circ \):

\({\overline{\sigma }}_i \) is the mean of the original series of WIG20 index returns volatility,

\(\circ \):

\(\overline{{\hat{\sigma }}}_i\) is the mean of the predicted series of WIG20 index returns volatility.

The criterion is that the smaller the value of the errors mentioned above, the better the predicting ability of a neural network.

2.4 Data

For analysis, daily closing prices of indices (WIG20, DAX, FTSE 250, Nikkei 255, Hang Seng, S&P 500, Nasdaq 100) between 01.01.2016 and 31.12.2020 are considered, they are downloaded from www.stooq.pl. Return rates and volatility are calculated and they are used as an input in the neural networks. Volatility is got from the last 230 days.

3 Experiments and results

In this experiments neural networks for different years and different indices are run. The input for each network consisted of the last 3 values of WIG20 index returns volatility and the last 3 values of one of the considered foreign index returns volatility. After the supervised learning, the standard errors were calculated. The results are shown is Tables 123456.

Table 1 Results in 2016

In 2016, the differences between forecast errors in each neural network with a different foreign stock market index are not significant. All errors are rather low.

Table 2 Results in 2017

In 2017, the Mean Percentage Error (MPE) is the smallest for neural network with DAX and NASDAQ 100 index. The network with DAX index also gives the best result when the Mean Absolute Percentage Error (MAPE) is considered. The largest forecast bias is observed for networks with FTSE 250 and HANG SENG indices. However, all errors remain rather low.

Table 3 Results in 2018

In 2018, all indicators of the predictive ability are the worst in the neural with HANG SENG index. The MPE and the MAPE are a slightly higher, at around 6%. The best performing networks are those with FTSE 250 and DAX indices.

Table 4 Results in 2019

In 2019, the neural network with S&P 500 index gives the worst results. The Mean Absolute Percentage Error (MAPE) is significantly higher, at 9.13%. The Mean Percentage Error (MPE) is also higher in comparison with others, at 3.62%.

Table 5 Results in 2020

In 2020, forecast bias in each neural network with a different foreign stock market index is in the same level. Only the Mean Percentage Error (MPE) is slightly lower for the network with DAX index.

Table 6 Results in 2021

In 2021, the Mean Absolute Percentage Error (MAPE) is significantly higher for the networks with HANG SENG and NIKKEI 225 indices, at around 8%. The Mean Percentage Error (MPE) is also much higher for the network with NIKKEI 225 index. The network with DAX index gives the smallest MAPE error.

Fig. 4
figure 4

MAPE for all indices in years 2016–2021

According to Fig. 4 the MAPE for the networks with all indices remains stable until 2017. In 2018, this error with HANG SENG index approaches a higher value, only in this year, in the next two years it falls to the previous level. Reflecting the boom of S&P 500 index on the US stock market, the MAPE error with it increases in 2019. It is the highest growth among all predictions in the considered periods of time. The chart shows that in 2021, the reaction to the COVID-19 pandemic of Asian markets is different from European and US markets. This causes the MAPEs for the networks with Asian indices raise sharply.

4 Conclusions

It is difficult to indicate the best neural network. Hence, the frequency of each individual network appearing on the list of two networks with the smallest errors is taken into account. Consequently, the neural networks with DAX and NASDAQ 100 index are the best networks. Summing up similarly, the network with HANG SENG index generally gives the highest forecast errors.

This conclusion is not surprising because Germany and the United States have got the great impact on Polish economy and finance, while Asian stock indices do not have so much effect on stock market in Poland.

The study shows that the Polish stock market is mainly influenced by the European and US markets and thus confirmed the conclusions of other articles (Dudek, 2009; Augustyński, 2011; Gluzicka, 2013).

The presented research can be interested for the audience focused on financial market. For example, observations of other foreign market indices may influence investment decisions.

This approach can be applied to test dependencies between stock indices from others countries and from different series of time. Moreover, future research can explore the usage of alternative activation functions within the network and assess the precision of obtained forecasts. Additionally, it is worth applying other statistical methods for comparative analysis.