# An Online Kernel Adaptive Filtering-Based Approach for Mid-Price Prediction

Authors: Shambhavi Mishra; Tanveer Ahmed; Vipul Mishra; Sami Bourouis; Mohammad Aman Ullah
Journal: Scientific Programming
 (2022)

---

## Abstract

The idea of multivariate and online stock price prediction via the kernel adaptive filtering (KAF) paradigm is proposed in this article. The prediction of stock prices is traditionally done with regression and classification, thereby requiring a large set of batch-oriented and independent training samples. This is problematic considering the nonstationary nature of a financial time series. In this research, we propose an online kernel adaptive filtering-based approach for stock price prediction to overcome this challenge. To examine a stock's performance and demonstrate the work's superiority, we use ten different KAF family of algorithms. In this paper, we take on this challenge and propose an approach for predicting stock prices. To analyze a stock's performance and demonstrate the work's superiority, we use ten distinct KAF algorithms. Besides, the results are analyzed on nine-time windows such as one day, sixty minutes, thirty minutes, twenty five minutes, twenty minutes, fifteen minutes, ten minutes, five minutes, and one minute. We are the first to experiment with several time windows for all fifty stocks on the Indian National Stock Exchange, to the best of our knowledge. It should be noted here that the experiments are performed on stocks making up the main index: Nifty-50. In terms of performance and compared to existing methods, we have a 66% probability of correctly predicting a stock's next upward or downward movement. This number clearly shows the edge that the proposed method has in actual deployment. Furthermore, the experimental findings show that KAF is not only a better option for predicting stock prices but that it may also be used as an alternative in high-frequency trading due to its low latency.


---

## Body

## 1. Introduction

Time-series prediction is prevalent in economics and investment research. Stock price prediction is one of the most popular applications of time-series prediction. Its success stems from its ability to reduce asset management costs, market impacts, and volatility risks [1]. It is a commonly held notion that stock markets are complex, volatile, and chaotic [2]. The markets, in our perspective, are made up of a variety of factors that influence stock movement. Predicting stock’s value at any given time in the future is, therefore, an important problem of academia and industry. Previous studies [3] have shown that the prediction of stock prices, particularly with the nonstationary and the nonlinear nature of the underlying asset, is challenging. In this regard, several models have been proposed, but the problem is nowhere near its end [4], and a substantial improvement is required. In addition, studies have also extended the problem by predicting option prices, volatility [5], and so on. This significant body of work demonstrates that stock price prediction remains a significant issue requiring solutions to a wide range of problems.As discussed in the previous paragraph, stock price prediction is a significant challenge. In this regard, a plethora of techniques have been used for predicting stock prices, such as neural network (NN), support vector machine (SVM), genetic algorithm, fuzzy logic, and Bayesian model [6]. However, getting an optimal solution is still a long way to go. During our literature review, we discovered that current research has overlooked kernel adaptive filtering (KAF) and has not thoroughly investigated this paradigm for financial time-series forecasting, especially stock prediction. Although there are a few introductory studies [7], a large-scale comprehensive evaluation lacks literature. With this shortcoming in mind, we would like to emphasize that KAF can be an effective stock prediction tool. The following observations serve as the foundation for our argument: first, KAF-based algorithms have a faster convergence rate; that is, the algorithm requires fewer iterations. Second, KAF has demonstrated excellent performance in nonstationary time-series prediction [8]. Third, KAF algorithms exhibit universal function approximation properties useful in highly dynamic environments [9]. Lastly, KAF has been used extensively in chaotic time-series prediction [10, 11]. Hence, it is also worth exploring the idea in financial time-series prediction. Therefore, in this article, we use the concept of KAF to examine and comprehend the real-time movement of stock prices. In addition to KAF being one of the largest unexplored paradigms in stock prediction, the literature review revealed one more issue. It contains one of the problems related to batch learning. We believe that sequential learning is the best tool rather than batch learning for financial time-series forecasting. This is mainly because a financial time series is nonstationary. We further argue that expecting a model trained on offline samples to perform excellently in a real situation is a slippery slope. The rationale here is supported by the work presented in the literature, which claims that online learning is the best way to understand and interpret nonstationary data behavior [12]. Consequently, studies have shown that online learning can be an effective method [13]. It is based on the concept of sequential measurement (training is performed sample-by-sample and in real time). Various scenarios can easily be added, and the algorithm adjusts the weight vector to provide accurate predictions. As a result, in order to solve the issue stated in the article, we enhance the KAF idea with online learning.With respect to the challenges and the ideas discussed in this section, we present an online KAF algorithms to predict the price of stock. The use of KAF techniques to stock price prediction is still limited [7, 14]. However, the concept is based upon this study is precedent and builds upon it to extend the application of KAF to a broader range of environments and contexts. With data taken from Nifty-50, the Indian Stock Index, we first build our dataset consisting of prices collected at a time window of one day, sixty minutes, thirty minutes, twenty five minutes, twenty minutes, fifteen minutes, ten minutes, five minutes, and one minute. These windows are chosen as they are some of the most common windows looked at by day traders. It should be noted here that the prices are collected for a total of fifty companies (they make up the main index: Nifty-50). Subsequently, we apply the ideas on each of the time windows and predict the next potential number for the “mid-price” of the stock. With comprehensive numerical investigation, we have found that the proposed trading algorithm has an extra 16% edge in the field, thereby making it an effective method capable of generating good returns in the long run. The following are the paper’s key contributions:(1)
A novel KAF-based online method for forecasting a stock’s mid-price is introduced. We look at two situations in which the mid-price is measured as (high + low)/2 and (open + close)/2, respectively. The main motivation for looking into mid-price was that mid-price time series is less noisy than close-price time series.(2)
With a comprehensive investigation performed on nine different time windows. We discover the best window for predicting stock prices. In the literature, several authors have focused on predicting daily prices [15, 16]. We, however, show that focusing efforts on other time windows could also be optimal.(3)
In this article, ten different KAF algorithms are used, and a detailed analysis is presented to validate the work. To the best of our knowledge, an investigation of this magnitude eludes literature.The following section has been divided into sections. The methods proposed by various researchers in the subject of stock prediction are discussed in Section2. Proposed methodology is described in Section 3. The experiments performed with different KAF algorithm, and their results are included in Section 4. Finally, in Section 5, the conclusions and future scopes are described.


## 2. Related Work

The work of other authors in the field of stock prediction is discussed in this section. Predicting stock has remained one of the nontrivial issues of the literature [17]. Previous studies have shown that the prediction of stock prices is difficult due to the inherent nonstationary behavior in the data [18]. Several studies [5] have shown that stock prediction is challenging and noisy. Various linear techniques such as correlations, discriminating analysis, autoregressive models, and moving averages have also been studied in the past [19]. Machine learning (ML) has been a popular field in time-series prediction in recent years. ML-based techniques are explored heavily as they can recognize complex patterns in stock prices [20]. Due to the nonlinear and time-varying nature of time-series, there has recently been a surge in demand for online prediction algorithms [21]. Online algorithms use the sequential calculation to achieve reliable and faster outcomes [13]. In this regard, several techniques have been developed, such as online support vector regression (SVR), NN [8], and KAF algorithms [10]. NN methods take a lot of processing power and have a slow convergence rate [22]. SVR provides superior applicability; however, it is not appropriate for huge datasets. Furthermore, the multifilter neural network (MFNN) is investigated, and it is discovered that MFNN outperforms SVR, random forests, and other neural network-based approaches. The use of convolutional neural networks (CNN) has also been explored to predict the next-day prices [23]. CNN outperformed for multimodality images in the biomedical domain [24, 25]. Furthermore, for stock price prediction, long short-term memory (LSTM) is applied [26]. The authors used an LSTM network with a single layer and 200 nodes in [27]. Furthermore, the network employs a single-layer LSTM with 140 nodes [28]. In contrast to using a deep architecture with four LSTM layers and 96 nodes in the hidden layers, each LSTM layer was further followed by a dropout layer [29].Adaptive filtering has been proven to be a preferable choice for streaming data having nonstreaming behavior [11, 30, 31]. For sequential stock prediction, KAF can be used by exploiting market interdependence. Fast convergence, low computational complexity, and nonparametric behavior make KAF a preferable choice [10, 32]. One research [33] focuses on adaptive asynchronous differential evolution with trigonometric mutation modified mutation operation, and adaptive parameters modified the convergence speed and diversity. In [34], the authors proposed meta-cognitive recurrent kernel online learning for multistep predictions of stocks. Although these studies show the potential that KAF has, KAF has not been investigated thoroughly in the context of stock price prediction. Though there are few studies in literature focusing on the area, large-scale investigation eludes literature. Nevertheless, we must point that the work presented in [14] proposes a two-phase method for stock prediction. First, sequential learning using KAF was applied to learn the underlying model for each stock separately. In the second phase, to improve prediction, real time models are learned from different stock. In [7], the authors proposed the idea of multikernel adaptive filters for online options trading. The method was applied to Taiwan composite stock index. Garcia-Vega et al. [35] presented a multi-kernel learning approach to overcome the two primary concerns with KAF: kernel size and step size. Despite the fact that these papers concentrate on using the KAF paradigm to forecast stock prices, none of them validates the paradigm’s effectiveness on a large-scale dataset. Moreover, the impact of multiple time windows is not considered. In our opinion, testing the method on multiple time windows that are often looked at by traders is of prime importance.


## 3. Methodology

### 3.1. Brief Discussion on KAF

We work with online learning-based KAF techniques, as discussed in Section1. The purpose of KAF is to learn with well-known input-output mapping f:S⟶R, and it contains sequence of data such as s1,d1,s2,d2,…,si,di, where, S⊆RL is the input space, si, i=1,…,n, is the system input at sample time, and di is known as desired response. In reproducing kernel Hilbert space (RKHS) F, KAF transforms the data into a set of points. Inner products can then be used to solve the problem. There is no need to do expensive computations in high-dimensional space, owing to the famous “kernel trick.” In KAFs, generally, the computation involves the use of a kernel. The following equation is an example of a kernel:(1)κ<s,s′>=exps−s′2σ2,where σ represents the kernel width.


### 3.2. Kernel Adaptive Filtering Algorithms

In this subsection, we briefly describe the ten different KAF methods.


#### 3.2.1. Least Mean Square (LMS)

The LMS algorithm, according to [36] employs a finite impulse response (FIR) filter, also known as a traversal filter, whose output is based on a linear combination of the input presented in the following equation:(2)yi=ϖi−1Tsi,where ϖi−1 represents the weight vector at iteration i−1. The following equation contains the main idea of the LMS algorithm:(3)ϖ0=0,ei=ti−ϖi−1si,ϖi=ϖi−1+ηeisi,where η and ei stands for step size and prior error. The weight-update equation findings were represented in the following equation:(4)ϖi=η∑i=1Neisi,The following equation represents the inner product:(5)t=ϖis=η∑i=1nei<si,s>,ei=ti−η∑i=1n−1ei<si,s>.


#### 3.2.2. Kernel Least Mean Square (KLMS)

To derive KLMS [36], the input si is converted into F as ϕsi. Using LMS, we can now rewrite the input and output mapping as follows:(6)ϖ0=0,ei=di−ϖi−1Tϕi,ϖi=ϖi−1+ηeiϕi,where ei is represented as the prediction error, η is the size of every step, and ϕsi is defined as the transformed filter input at a certain point in time or iteration i. Equation (7) compute the result, where we can use the famous kernel tricks. Consequently, the model now becomes(7)f0=0,ei=di−fi−1si,fi=fi−1+ηeiκ<si,.>.In KLMS, a new unit of the kernel is assigned to all new samples points withηei as the coefficient value. Following the radial basis function (RBF) described in this section, the system is represented as follows:(8)fi=∑j=1iojiκ<sj,.>.The coefficientso(i) and the centers Ci=sjj=1i are saved inside the storage during the training process.


#### 3.2.3. Kernel Affine Projection Algorithm (KAPA)

KAPA [37] is used where we want to improve the performance owing to the gradient noise. In KAPA, we estimate using the weight vector ϖ and minimise the cost function with the sequences d1,d2 and ϕ1,ϕ2 as shown below(9)minϖempd−ϖTϕs2.We replace the concept of covariance and cross variance matrix-vector by local approximation directly from the data using stochastic gradient descent summarized in(10)ϖi=ϖi−1+ηψidi−ψiTϖi−1,where ψi=ϕi−K+1,…,ϕi and K is the observation and regressor.


#### 3.2.4. Leaky Kernel Affine Projection Algorithm (LKAPA)

LKAPA [37] is the extension of KAPA as discussed in Section 3.2.3.Based on the selected kernels, the feature space can be infinitely dimensional, where the weight updation task is difficult. In the common consideration, the solution is the modification in equation (10) as follows.The weight vector in Equation (11) is calculated using the following criteria:(11)ϖi=∑j=1iojiϕi,∀i≥0.Equation (12) is used to reduce the following objective function from the perspective of empirical risk minimization:(12)minϖempd−ϖTϕs2+Λϖ2.Then, we get the updated weight, and it is shown in(13)ϖi=1−Ληϖi−1+ηψidi−ψiTϖi−1,where ψi=ϕi−K+1,…,ϕi.Finally, coefficientoκi is updated as(14)oκi=k=i,ηdi−∑j=1i−1oji−1ki,jfori−K+1≤k≤i−11−Ληoki−1+ηdk−∑j=1i−1oji−1κk,j.1≤k<i−K+11−Ληoki−1.


#### 3.2.5. Normalized Online Regularized Risk Minimization Algorithm (NORMA)

Similarly, the LKAPA [37] extension comes in NORMA, and also it is related to KAPA discussed in Section 3.2.3. It also includes the regularization and nonfunctional approaches.


#### 3.2.6. Quantized Kernel Least Mean Square Algorithm (QKLMS)

Quantization techniques are used in various applications such as digitization, data compression, speech, and image coding. QKLMS is a famous algorithm proposed in [11], which deals with the issue of data redundancy. The computational complexity of QKLMS and KLMS is nearly identical. The main difference between the two algorithms is that QKLMS uses redundant data to update the coefficient of closest centre in real time. The following equation represents the main idea using the quantization operator: (15)ϖ0=0,ei=ti−ϖi−1Tϕi,ϖi=ϖi−1+ηeiQϕi,where Q. signifies the quantization in feature space F. The following equation summarises the learning rule for QKLMS: (16)f0=0,ei=ti−fi−1si,fi=fi−1+ηeiκQsi.


#### 3.2.7. Fixed Budget Quantized Kernel Least Mean Square Algorithm (FBQKLMS)

The FBQKLMS [38] deals with the increasing popularity of online kernel approaches. The suggested algorithm uses a significance measure-based pruning criterion based on the weighted contribution of existing data centres.


#### 3.2.8. Kernel Adaptive Filtering with Maximum Correntropy Criterion (KMCC)

The fundamental goal of the method is to maximise the crossentropy between the desireddi and actual output yi [39]. Using the MCC technique [39] and SGD, the algorithm can be written as follows:(17)ϖ0=0,ϖi+1=ϖi+η∂κσti,ϖiTϕsi∂ϖi;=ϖi+ηexp−ei22σ2eiϕi,…=η∑i=1nexp−ei22σ2eiϕi,yi=η∑i=1nexp−ei22σ2eiκ<si,sn>,ei=di−yi,where η is the step size and σ is the kernel width. The entire amount of error and prediction calculation can be summarized in equation (17).


#### 3.2.9. Multikernel Normalized Least Mean Square (MKNLMS)

According to [30], the KNLMS algorithm is used to create dictionaries based on the coherence requirement. Here, we explore at KNLMS through the perspective of MKNLMS-CS (multi-kernel normalised least mean square algorithm with coherence-based sparsification). Consider the empty dictionary at the initial stage represented as J0cs:=∅, by which the H0 is shown as an empty matrix as M∗. Consider the Hilbertian unit for simplification of κs,s=1,∀s∈s, which is satisfied by the Gaussian kernel. n is added into Jncs in the case when the defined condition holds in the proposed methodology presented in equation (18)(18)κmax:=maxm∈ℳmaxj∈Jncsκmsn,sj,≤ϕ,n∈N,where η∈0,2 and Λ>0 denotes the step size and regularization parameter, respectively. δ>0 is the threshold.ConsideringIf equation (18) is satisfied, Jn+1cs:=Jncs∪n. If equation (18) is not satisfied, jn+1cs:=jncs∪n:(19)Hn+1:=H¯n+ηtn−<K¯n,H¯n>K¯n2+ΛK¯n,Hn+1:=Hn+ηtn−<Hn,Kn>Kn2+ΛKn,where H¯n:=Hn0 and K¯n:=Knk¯n with k¯n:=κ1sn,sn,κ2sn,sn,κ3sn,sn,…κMsn,snT where 0 ∈RM is the zero vector. The value of M for KNLMS is 1.


#### 3.2.10. Probabilistic Least-Mean Square Filter (PROB-LMS)

PROB-LMS [31] gives adaptable step-size to the LMS algorithm in Section 3.2.1. and also applied in the stationary and nonstationary environment. The LMS filter can be approximated effectively using a probabilistic approach. It includes a step-size LMS algorithm that may be modified as well as a measure of estimation uncertainty. It also maintains the standard LMS's linear complexity.


### 3.3. Problem Formulation

Our main objective, is to predict the stock's mid-price as stated in Section1. The motive of stock price prediction is to calculate stock’s future values depending on historical values. For this, we measured the percentage change in mid-price. As a result, we used the concept of order n auto-regression to predict future stock price changes. The sample regression equation is shown in Table 1. Multivariate financial time-series estimation often employs this formulation [40, 41] to predict future values of a time series. The formulation shown in Table 1 is done by considering daywise mid-prices. It should be noted here that the same procedure was used for all time windows. As a result, the problem was rephrased as follows: autoregression-based next percentage prediction. The exact mid-price of the stock may therefore be easily calculated using the percentage change. Figure 1 depicts the proposed approach's overall methodology. The Nifty-50 dataset was used in the experiments. We consider two different aspects for the mid-price prediction: (i) (high + low)/2 and (ii) (open + close)/2. As a result of this calculation, we created the dataset and pre-processed it using nine prediction windows (one-minute, five-minutes, ten-minutes, fifteen-minutes, twenty-minutes, twenty-five minutes, thirty-minutes, sixty-minutes, and one day). Further, the percentage change was calculated for each time windows, and min-max normalization was applied. The selection of embedding dimension M is a difficult task. We choose different M∈ {2, 3, 4, 5, 6, 7} and set the maximum dictionary size for required algorithms to 500 with Gaussian kernel for each time window. In Table 1, we have shown an example considering the time window of 1 day (Stock-TITAN). The error estimation was performed with the help of ten different KAF algorithms for each time window. For example, the performance of each algorithm is analyzed to find which embedding dimension produces the best result. After getting the best embedding dimension for each algorithm, the embedding dimension that produces the best result and the corresponding algorithm is selected.Table 1
A one-day time frame (Stock-TITAN).
DayHigh priceLow price(high + low)/2Change in price1 day15731555.951564.475−0.765 42 days156715381552.50.430 03 days1576.851541.51559.1752.079 64 days1621.351561.851591.6−2.456 65 days157015351552.5−0.908 26 days155.31521.51538.4NAIf we chooseM = 3, then Input = [{−0.765 4, 0.430 0, 2.079 6}.], Output = [{−2.456 6}].Figure 1
Proposed mid-price prediction framework.


## 3.1. Brief Discussion on KAF

We work with online learning-based KAF techniques, as discussed in Section1. The purpose of KAF is to learn with well-known input-output mapping f:S⟶R, and it contains sequence of data such as s1,d1,s2,d2,…,si,di, where, S⊆RL is the input space, si, i=1,…,n, is the system input at sample time, and di is known as desired response. In reproducing kernel Hilbert space (RKHS) F, KAF transforms the data into a set of points. Inner products can then be used to solve the problem. There is no need to do expensive computations in high-dimensional space, owing to the famous “kernel trick.” In KAFs, generally, the computation involves the use of a kernel. The following equation is an example of a kernel:(1)κ<s,s′>=exps−s′2σ2,where σ represents the kernel width.


## 3.2. Kernel Adaptive Filtering Algorithms

In this subsection, we briefly describe the ten different KAF methods.


### 3.2.1. Least Mean Square (LMS)

The LMS algorithm, according to [36] employs a finite impulse response (FIR) filter, also known as a traversal filter, whose output is based on a linear combination of the input presented in the following equation:(2)yi=ϖi−1Tsi,where ϖi−1 represents the weight vector at iteration i−1. The following equation contains the main idea of the LMS algorithm:(3)ϖ0=0,ei=ti−ϖi−1si,ϖi=ϖi−1+ηeisi,where η and ei stands for step size and prior error. The weight-update equation findings were represented in the following equation:(4)ϖi=η∑i=1Neisi,The following equation represents the inner product:(5)t=ϖis=η∑i=1nei<si,s>,ei=ti−η∑i=1n−1ei<si,s>.


### 3.2.2. Kernel Least Mean Square (KLMS)

To derive KLMS [36], the input si is converted into F as ϕsi. Using LMS, we can now rewrite the input and output mapping as follows:(6)ϖ0=0,ei=di−ϖi−1Tϕi,ϖi=ϖi−1+ηeiϕi,where ei is represented as the prediction error, η is the size of every step, and ϕsi is defined as the transformed filter input at a certain point in time or iteration i. Equation (7) compute the result, where we can use the famous kernel tricks. Consequently, the model now becomes(7)f0=0,ei=di−fi−1si,fi=fi−1+ηeiκ<si,.>.In KLMS, a new unit of the kernel is assigned to all new samples points withηei as the coefficient value. Following the radial basis function (RBF) described in this section, the system is represented as follows:(8)fi=∑j=1iojiκ<sj,.>.The coefficientso(i) and the centers Ci=sjj=1i are saved inside the storage during the training process.


### 3.2.3. Kernel Affine Projection Algorithm (KAPA)

KAPA [37] is used where we want to improve the performance owing to the gradient noise. In KAPA, we estimate using the weight vector ϖ and minimise the cost function with the sequences d1,d2 and ϕ1,ϕ2 as shown below(9)minϖempd−ϖTϕs2.We replace the concept of covariance and cross variance matrix-vector by local approximation directly from the data using stochastic gradient descent summarized in(10)ϖi=ϖi−1+ηψidi−ψiTϖi−1,where ψi=ϕi−K+1,…,ϕi and K is the observation and regressor.


### 3.2.4. Leaky Kernel Affine Projection Algorithm (LKAPA)

LKAPA [37] is the extension of KAPA as discussed in Section 3.2.3.Based on the selected kernels, the feature space can be infinitely dimensional, where the weight updation task is difficult. In the common consideration, the solution is the modification in equation (10) as follows.The weight vector in Equation (11) is calculated using the following criteria:(11)ϖi=∑j=1iojiϕi,∀i≥0.Equation (12) is used to reduce the following objective function from the perspective of empirical risk minimization:(12)minϖempd−ϖTϕs2+Λϖ2.Then, we get the updated weight, and it is shown in(13)ϖi=1−Ληϖi−1+ηψidi−ψiTϖi−1,where ψi=ϕi−K+1,…,ϕi.Finally, coefficientoκi is updated as(14)oκi=k=i,ηdi−∑j=1i−1oji−1ki,jfori−K+1≤k≤i−11−Ληoki−1+ηdk−∑j=1i−1oji−1κk,j.1≤k<i−K+11−Ληoki−1.


### 3.2.5. Normalized Online Regularized Risk Minimization Algorithm (NORMA)

Similarly, the LKAPA [37] extension comes in NORMA, and also it is related to KAPA discussed in Section 3.2.3. It also includes the regularization and nonfunctional approaches.


### 3.2.6. Quantized Kernel Least Mean Square Algorithm (QKLMS)

Quantization techniques are used in various applications such as digitization, data compression, speech, and image coding. QKLMS is a famous algorithm proposed in [11], which deals with the issue of data redundancy. The computational complexity of QKLMS and KLMS is nearly identical. The main difference between the two algorithms is that QKLMS uses redundant data to update the coefficient of closest centre in real time. The following equation represents the main idea using the quantization operator: (15)ϖ0=0,ei=ti−ϖi−1Tϕi,ϖi=ϖi−1+ηeiQϕi,where Q. signifies the quantization in feature space F. The following equation summarises the learning rule for QKLMS: (16)f0=0,ei=ti−fi−1si,fi=fi−1+ηeiκQsi.


### 3.2.7. Fixed Budget Quantized Kernel Least Mean Square Algorithm (FBQKLMS)

The FBQKLMS [38] deals with the increasing popularity of online kernel approaches. The suggested algorithm uses a significance measure-based pruning criterion based on the weighted contribution of existing data centres.


### 3.2.8. Kernel Adaptive Filtering with Maximum Correntropy Criterion (KMCC)

The fundamental goal of the method is to maximise the crossentropy between the desireddi and actual output yi [39]. Using the MCC technique [39] and SGD, the algorithm can be written as follows:(17)ϖ0=0,ϖi+1=ϖi+η∂κσti,ϖiTϕsi∂ϖi;=ϖi+ηexp−ei22σ2eiϕi,…=η∑i=1nexp−ei22σ2eiϕi,yi=η∑i=1nexp−ei22σ2eiκ<si,sn>,ei=di−yi,where η is the step size and σ is the kernel width. The entire amount of error and prediction calculation can be summarized in equation (17).


### 3.2.9. Multikernel Normalized Least Mean Square (MKNLMS)

According to [30], the KNLMS algorithm is used to create dictionaries based on the coherence requirement. Here, we explore at KNLMS through the perspective of MKNLMS-CS (multi-kernel normalised least mean square algorithm with coherence-based sparsification). Consider the empty dictionary at the initial stage represented as J0cs:=∅, by which the H0 is shown as an empty matrix as M∗. Consider the Hilbertian unit for simplification of κs,s=1,∀s∈s, which is satisfied by the Gaussian kernel. n is added into Jncs in the case when the defined condition holds in the proposed methodology presented in equation (18)(18)κmax:=maxm∈ℳmaxj∈Jncsκmsn,sj,≤ϕ,n∈N,where η∈0,2 and Λ>0 denotes the step size and regularization parameter, respectively. δ>0 is the threshold.ConsideringIf equation (18) is satisfied, Jn+1cs:=Jncs∪n. If equation (18) is not satisfied, jn+1cs:=jncs∪n:(19)Hn+1:=H¯n+ηtn−<K¯n,H¯n>K¯n2+ΛK¯n,Hn+1:=Hn+ηtn−<Hn,Kn>Kn2+ΛKn,where H¯n:=Hn0 and K¯n:=Knk¯n with k¯n:=κ1sn,sn,κ2sn,sn,κ3sn,sn,…κMsn,snT where 0 ∈RM is the zero vector. The value of M for KNLMS is 1.


### 3.2.10. Probabilistic Least-Mean Square Filter (PROB-LMS)

PROB-LMS [31] gives adaptable step-size to the LMS algorithm in Section 3.2.1. and also applied in the stationary and nonstationary environment. The LMS filter can be approximated effectively using a probabilistic approach. It includes a step-size LMS algorithm that may be modified as well as a measure of estimation uncertainty. It also maintains the standard LMS's linear complexity.


## 3.2.1. Least Mean Square (LMS)

The LMS algorithm, according to [36] employs a finite impulse response (FIR) filter, also known as a traversal filter, whose output is based on a linear combination of the input presented in the following equation:(2)yi=ϖi−1Tsi,where ϖi−1 represents the weight vector at iteration i−1. The following equation contains the main idea of the LMS algorithm:(3)ϖ0=0,ei=ti−ϖi−1si,ϖi=ϖi−1+ηeisi,where η and ei stands for step size and prior error. The weight-update equation findings were represented in the following equation:(4)ϖi=η∑i=1Neisi,The following equation represents the inner product:(5)t=ϖis=η∑i=1nei<si,s>,ei=ti−η∑i=1n−1ei<si,s>.


## 3.2.2. Kernel Least Mean Square (KLMS)

To derive KLMS [36], the input si is converted into F as ϕsi. Using LMS, we can now rewrite the input and output mapping as follows:(6)ϖ0=0,ei=di−ϖi−1Tϕi,ϖi=ϖi−1+ηeiϕi,where ei is represented as the prediction error, η is the size of every step, and ϕsi is defined as the transformed filter input at a certain point in time or iteration i. Equation (7) compute the result, where we can use the famous kernel tricks. Consequently, the model now becomes(7)f0=0,ei=di−fi−1si,fi=fi−1+ηeiκ<si,.>.In KLMS, a new unit of the kernel is assigned to all new samples points withηei as the coefficient value. Following the radial basis function (RBF) described in this section, the system is represented as follows:(8)fi=∑j=1iojiκ<sj,.>.The coefficientso(i) and the centers Ci=sjj=1i are saved inside the storage during the training process.


## 3.2.3. Kernel Affine Projection Algorithm (KAPA)

KAPA [37] is used where we want to improve the performance owing to the gradient noise. In KAPA, we estimate using the weight vector ϖ and minimise the cost function with the sequences d1,d2 and ϕ1,ϕ2 as shown below(9)minϖempd−ϖTϕs2.We replace the concept of covariance and cross variance matrix-vector by local approximation directly from the data using stochastic gradient descent summarized in(10)ϖi=ϖi−1+ηψidi−ψiTϖi−1,where ψi=ϕi−K+1,…,ϕi and K is the observation and regressor.


## 3.2.4. Leaky Kernel Affine Projection Algorithm (LKAPA)

LKAPA [37] is the extension of KAPA as discussed in Section 3.2.3.Based on the selected kernels, the feature space can be infinitely dimensional, where the weight updation task is difficult. In the common consideration, the solution is the modification in equation (10) as follows.The weight vector in Equation (11) is calculated using the following criteria:(11)ϖi=∑j=1iojiϕi,∀i≥0.Equation (12) is used to reduce the following objective function from the perspective of empirical risk minimization:(12)minϖempd−ϖTϕs2+Λϖ2.Then, we get the updated weight, and it is shown in(13)ϖi=1−Ληϖi−1+ηψidi−ψiTϖi−1,where ψi=ϕi−K+1,…,ϕi.Finally, coefficientoκi is updated as(14)oκi=k=i,ηdi−∑j=1i−1oji−1ki,jfori−K+1≤k≤i−11−Ληoki−1+ηdk−∑j=1i−1oji−1κk,j.1≤k<i−K+11−Ληoki−1.


## 3.2.5. Normalized Online Regularized Risk Minimization Algorithm (NORMA)

Similarly, the LKAPA [37] extension comes in NORMA, and also it is related to KAPA discussed in Section 3.2.3. It also includes the regularization and nonfunctional approaches.


## 3.2.6. Quantized Kernel Least Mean Square Algorithm (QKLMS)

Quantization techniques are used in various applications such as digitization, data compression, speech, and image coding. QKLMS is a famous algorithm proposed in [11], which deals with the issue of data redundancy. The computational complexity of QKLMS and KLMS is nearly identical. The main difference between the two algorithms is that QKLMS uses redundant data to update the coefficient of closest centre in real time. The following equation represents the main idea using the quantization operator: (15)ϖ0=0,ei=ti−ϖi−1Tϕi,ϖi=ϖi−1+ηeiQϕi,where Q. signifies the quantization in feature space F. The following equation summarises the learning rule for QKLMS: (16)f0=0,ei=ti−fi−1si,fi=fi−1+ηeiκQsi.


## 3.2.7. Fixed Budget Quantized Kernel Least Mean Square Algorithm (FBQKLMS)

The FBQKLMS [38] deals with the increasing popularity of online kernel approaches. The suggested algorithm uses a significance measure-based pruning criterion based on the weighted contribution of existing data centres.


## 3.2.8. Kernel Adaptive Filtering with Maximum Correntropy Criterion (KMCC)

The fundamental goal of the method is to maximise the crossentropy between the desireddi and actual output yi [39]. Using the MCC technique [39] and SGD, the algorithm can be written as follows:(17)ϖ0=0,ϖi+1=ϖi+η∂κσti,ϖiTϕsi∂ϖi;=ϖi+ηexp−ei22σ2eiϕi,…=η∑i=1nexp−ei22σ2eiϕi,yi=η∑i=1nexp−ei22σ2eiκ<si,sn>,ei=di−yi,where η is the step size and σ is the kernel width. The entire amount of error and prediction calculation can be summarized in equation (17).


## 3.2.9. Multikernel Normalized Least Mean Square (MKNLMS)

According to [30], the KNLMS algorithm is used to create dictionaries based on the coherence requirement. Here, we explore at KNLMS through the perspective of MKNLMS-CS (multi-kernel normalised least mean square algorithm with coherence-based sparsification). Consider the empty dictionary at the initial stage represented as J0cs:=∅, by which the H0 is shown as an empty matrix as M∗. Consider the Hilbertian unit for simplification of κs,s=1,∀s∈s, which is satisfied by the Gaussian kernel. n is added into Jncs in the case when the defined condition holds in the proposed methodology presented in equation (18)(18)κmax:=maxm∈ℳmaxj∈Jncsκmsn,sj,≤ϕ,n∈N,where η∈0,2 and Λ>0 denotes the step size and regularization parameter, respectively. δ>0 is the threshold.ConsideringIf equation (18) is satisfied, Jn+1cs:=Jncs∪n. If equation (18) is not satisfied, jn+1cs:=jncs∪n:(19)Hn+1:=H¯n+ηtn−<K¯n,H¯n>K¯n2+ΛK¯n,Hn+1:=Hn+ηtn−<Hn,Kn>Kn2+ΛKn,where H¯n:=Hn0 and K¯n:=Knk¯n with k¯n:=κ1sn,sn,κ2sn,sn,κ3sn,sn,…κMsn,snT where 0 ∈RM is the zero vector. The value of M for KNLMS is 1.


## 3.2.10. Probabilistic Least-Mean Square Filter (PROB-LMS)

PROB-LMS [31] gives adaptable step-size to the LMS algorithm in Section 3.2.1. and also applied in the stationary and nonstationary environment. The LMS filter can be approximated effectively using a probabilistic approach. It includes a step-size LMS algorithm that may be modified as well as a measure of estimation uncertainty. It also maintains the standard LMS's linear complexity.


## 3.3. Problem Formulation

Our main objective, is to predict the stock's mid-price as stated in Section1. The motive of stock price prediction is to calculate stock’s future values depending on historical values. For this, we measured the percentage change in mid-price. As a result, we used the concept of order n auto-regression to predict future stock price changes. The sample regression equation is shown in Table 1. Multivariate financial time-series estimation often employs this formulation [40, 41] to predict future values of a time series. The formulation shown in Table 1 is done by considering daywise mid-prices. It should be noted here that the same procedure was used for all time windows. As a result, the problem was rephrased as follows: autoregression-based next percentage prediction. The exact mid-price of the stock may therefore be easily calculated using the percentage change. Figure 1 depicts the proposed approach's overall methodology. The Nifty-50 dataset was used in the experiments. We consider two different aspects for the mid-price prediction: (i) (high + low)/2 and (ii) (open + close)/2. As a result of this calculation, we created the dataset and pre-processed it using nine prediction windows (one-minute, five-minutes, ten-minutes, fifteen-minutes, twenty-minutes, twenty-five minutes, thirty-minutes, sixty-minutes, and one day). Further, the percentage change was calculated for each time windows, and min-max normalization was applied. The selection of embedding dimension M is a difficult task. We choose different M∈ {2, 3, 4, 5, 6, 7} and set the maximum dictionary size for required algorithms to 500 with Gaussian kernel for each time window. In Table 1, we have shown an example considering the time window of 1 day (Stock-TITAN). The error estimation was performed with the help of ten different KAF algorithms for each time window. For example, the performance of each algorithm is analyzed to find which embedding dimension produces the best result. After getting the best embedding dimension for each algorithm, the embedding dimension that produces the best result and the corresponding algorithm is selected.Table 1
A one-day time frame (Stock-TITAN).
DayHigh priceLow price(high + low)/2Change in price1 day15731555.951564.475−0.765 42 days156715381552.50.430 03 days1576.851541.51559.1752.079 64 days1621.351561.851591.6−2.456 65 days157015351552.5−0.908 26 days155.31521.51538.4NAIf we chooseM = 3, then Input = [{−0.765 4, 0.430 0, 2.079 6}.], Output = [{−2.456 6}].Figure 1
Proposed mid-price prediction framework.


## 4. Experiments and Results

### 4.1. Dataset Description

This section explores into the specifics of the dataset that was used to test the applicability of the proposed method. For this study, we used data from the National Stock Exchange of India. The main index of NSE, Nifty-50, has 50 stocks. Based on the average and total daily turnover for equity shares, Nifty-50 is India’s largest stock exchange. We collected data between January 01, 2021, and May 31, 2021, from 9:15 a.m. to 3:30 p.m. In addition, experimentation data are available athttps://shorturl.at/lnvF2. The original data included open, high, low, and close (OHLC) prices and were available for one minute. The original data consisted of OHLC prices and were available for one minute. The dataset is generated and preprocessed in accordance with the nine prediction windows (one minute, five minutes, ten minutes, fifteen minutes, twenty minutes, twenty five minutes, thirty minutes, sixty minutes, and one day). Data samples range is different according to their time window. As pointed out in Section 1, we are trying to predict the mid-price with two different scenarios: (high + low)/2 and (open + close)/2. For this, firstly we calculated the percentage change of mid-price. All data values were normalized between zero to one range. Ten different KAF algorithms were used to the final preprocess data and each stock and analyse the comparative performance.


### 4.2. Evaluation Criterion

To measure and analyse the efficacy of various KAF algorithms, standard assessment criteria are used. In Table2, yi and di represent the actual and predicted output. n is the time step, and(20)Di=0,otherwise,1,yi−yi−1di−di−1≥0,.Table 2
Evaluation metrics.
MSEMAEDS∑i=1nyi−di21/n∑i=1nyi−di1/n∑i=1nDiCalculating the evaluation metrics with Nifty-50.(1)
The parameter listed in Table3 were tuned manually. The parameter description for ten different algorithms are presented in Table 3. These values were found after multiple rounds of experimentation.(2)
For the error values, we applied the methods to all stocks and tried to quantify the predictive performance via the metrics discussed in this section. In total, we get50×3 (one for each stock) error values for MSE, MAE, and DS, respectively.(3)
Then, for each of the 50 stocks, error estimation was performed using nine different prediction windows for ten different KAF algorithms.(4)
Finally, we used the average of all fifty-error metrics for a single time window and a single stock to reach the final value, which is presented in Tables4 and 5. On all 50 stocks, the provided number represents the models' overall predictive capacity.Table 3
Parameter description of KAF techniques for NSE-50 dataset for mid-price.
ParameterKAPAKLMSKMCCKNLMSFBQKLMSLKAPALMSNORMAPROB-LMSQKLMSσ5.07.04.07.056—3—4η1.51.71.71.70.20.03———0.2ϵ1E-4——1E-40.4——1.5—0.5β————0.85—————Λ—————1E-2—1E-20.4—σ2n————————2—σ2d————————3—mu00.2——2——0.2———(P)20————20————τ———————5000——tcoff———————4——σ = kernel width, σ2n = variance of observation noise, σ2d = variance of filter weight diffusion, η = step-size, ϵ = regularization parameter, Λ = Tikhonov regularization, tcoff = learning rate coefficient, τ = memory size (terms retained in truncation), mu0 = coherence criterion threshold, P = memory length, nu = approximate linear dependency (ALD) threshold, and β = forgetting factor for influence.Table 4
Result in terms of MSE, MAE, and DS for mid-price (high + low)/2.
Time windowMSEBest algorithms out of ten discussed (according to MSE)MAEBest algorithms out of ten discussed (according to MAE)DSBest algorithms out of ten discussed (according to DS)1 day0.030 6KAPA1.412 9KAPA0.537 8NORMA60 minutes0.009 1KAPA0.509 6KAPA0.559 2NORMA30 minutes0.005 3KAPA0.359 5KAPA0.555 8PROB-LMS25 minutes0.004 7KAPA0.331 4KAPA0.557 8NORMA20 minutes0.003 8KAPA0.290 9KAPA0.555 0NORMA15 minutes0.003 0KAPA0.253 4KAPA0.555 6NORMA10 minutes0.002 1KAPA0.201 9KAPA0.547 2NORMA5 minutes0.001 2KAPA0.144 7KAPA0.534 2PROB-LMS1 minute0.000 27KAPA0.059 0KAPA0.549 6NORMATable 5
Result in terms of MSE, MAE, and DS for mid-price (open + close)/2.
Time windowMSEBest algorithms out of ten discussed (according to MSE)MAEBest algorithms out of ten discussed (according to MAE)DSBest algorithms out of ten discussed (according to DS)1 day0.032 4KAPA1.298 9KAPA0.597 0NORMA60 minutes0.009 0KAPA0.454 1KAPA0.636 7NORMA30 minutes0.004 8KAPA0.316 8KAPA0.654 7NORMA25 minutes0.004 1KAPA0.290 3KAPA0.659 2NORMA20 minutes0.003 3KAPA0.254 3KAPA0.658 0NORMA15 minutes0.002 6KAPA0.219 8KAPA0.665 2KNLMS10 minutes0.001 7KAPA0.174 7KAPA0.666 6KNLMS5 minutes0.000 9KAPA0.122 4KAPA0.662 8KNLMS1 minute0.000 25KAPA0.055 2KAPA0.601 8KNLMS


### 4.3. Prediction, Convergence, and Residual Analysis

In this subsection, we examined prediction, converge and residual analysis with the help of KAF algorithms. Regarding this, we have shown the prediction graphs with the KAPA algorithm (discussed in Section 3.2.3) for one stock (TITAN). Figure2 shows the results for (high + low)/2, while Figure 3 shows the results for (open + close)/2. The predictive curve suits well against the original curve, as can be seen from the prediction graphs. It is worth noting that we have only given results for one prediction window (thirty-minutes) with one stock (TITAN). However, we must note that other stocks in the dataset produced similar result. The prediction graphs clearly show that the predictions are not exact, although they are close. To be precise, the numbers for MSE and MAE are presented in Tables 4 and 5. We must point out that getting accurate value in financial time series forecasting is tough. The goal has always been to get close enough values. Therefore, the result that we achieved shows the good predictive capability of the work. Figures 4 and 5 show the convergence graph for mid-price for (high+low)/2, (open+close)/2, respectively. We have provided the results using the KAPA algorithm with only one prediction window (thirty minutes) and one stock (TITAN), similar to the prior scenario. The algorithm converges quickly, as evidenced by the graphs, at the 1000th data point. We can see in KAF algorithms capacity to adapt and converge quickly. One more important point to note from the convergence graphs is that although there is some fluctuation in the graphs, it is nevertheless acceptable. This is because there will be noise in the new data and minor changes are inevitable. In addition to the results discussed so far, we have complemented the analysis by presenting the distribution of error residuals in Figures 6 and 7. It can be seen from the figures that residuals follow a normal distribution. Moreover, the outliers are also less. Furthermore, the residual's variance is low, demonstrating the KAF algorithm's superior prediction capability and potential in predicting the next immediate, mid-priced occurrence. Directional symmetry is used to determine the continuity of actual and expected prices in terms of stock movement. It is a measure for determining a model's ability to predict a stock's direction. We examined the ten different algorithms mentioned in Section 3 to better understand the actions of a stock’s movement. The experiment revealed that using KNLMS, we have a 66% percent chance of accurately predicting the next up or down movement. This is shown in Table 5. The best result is obtained at the window of ten minutes, and the worst result is obtained at the one-minute window. From the table, it is also visible that there is a big difference in the number obtained for the one minute window and that for the rest of the windows. This is expected as there is much noise in a minute, which indeed affects prediction. It should be noted here that literature often ignores looking at these different time windows. Work mostly focuses on predicting daily prices [42, 43]. We discovered the perfect balance by playing with various time windows. Furthermore, when trading, it is recommended to strike a balance between error minimization and directional symmetry.Figure 2
Prediction for one stock (TITAN) using KAPA (high + low)/2.Figure 3
Prediction for one stock (TITAN) using KAPA (open + close)/2.Figure 4
Error convergence for one stock (TITAN) using KAPA (high + low)/2.Figure 5
Error convergence for one stock (TITAN) using KAPA (open + close)/2.Figure 6
Error residuals for one stock (TITAN) using KAPA (high + low)/2.Figure 7
Error residuals for one stock (TITAN) using KAPA (open + close)/2.


### 4.4. Comparative Evaluation of KAF Algorithms

Since we have used ten algorithms in our experimentation, it becomes essential to compare their performance. In this context, we present the topic in two separate situations. First, we analyze the results considering mid-price as (high + low)/2 to find the best algorithm. In the next scenario, we tried mid-price using (open + close)/2. Tables4 and 5 show the outcome of this experiment. In terms of MSE and MAE, the tables show that KAPA outperforms other algorithms. When it comes to directional symmetry, we can see a contradiction. In directional symmetry, we see a conflict. Here, NORMA and KNLMS give the best performance.


### 4.5. Comparison with Methods of a Similar Kind

We have also compared the result with other existing techniques such as [28, 29] and [44]. These are some of the most recent deep learning (DL)-based algorithms for predicting stock prices. It should be noted here that these methods were trained and tested using 80:20 splits for 25 epochs. The time taken to train and make prediction was recorded. Specifically, these methods [28, 29] and [44] were reimplemented based on the architecture details and hyper-parameters setting found in the respective papers. The Nifty-50 dataset was used to train all of the methods. To ensure consistency across different methods for experimentation, we use sixty-minute time periods, for fifty stocks. All of the methods' results were then compared to the proposed method. Table 6 contains the results. The table's data clearly demonstrate the proposed method's superiority over a number of other waysTable 6
The proposed research is compared to different state-of-the-art stock prediction approaches.
MethodMSEExecution time (s)LSTM [28]0.683 1256.16LSTM [29]0.681 7945.09LSTM [44]0.682 41770.40KAPA (proposed method)0.009 12.132


### 4.6. Effect of Different Kernels

In Table7, we can see the effect of different kernel methods. For this test, we used a thirty-minute time window (Stock-TITAN) with the algorithm KAPA and analyzed the best performance of RBF kernel in terms of MSE. That is why, we have chosen RBF kernel (gauss) for each algorithm.Table 7
Effect of different kernel methods on time window of thirty minutes (Stock-TITAN) using KAPA for (high + low)/2.
(High + low)/2(Open + close)/2Kernel functionMSEMAEDSMSEMAEDSRBF kernel (Gauss)0.008 1200.298 570.534 210.008 270.260 470.531 88Anisotropic RBF kernel (Gauss-anis)0.019 190.406 170.515 550.025 350.348 680.579 31Laplace kernel (Laplace)0.008 1280.298 720.533 430.008 280.260 610.531 10


### 4.7. Experimentation with Dictionary Size

We also conducted experiments with various dictionary sizes. The result for this test is shown in Table8. For this test, we used a thirty-minute time window with the algorithm KMCC. It is visible from Table 8 that increasing the dictionary size leads to an improvement in the system's performance. It should be noted here that when the size is 1000, the performance has fallen. The reason for this behavior could be the erratic behavior of the stock, the presence of noise, or too much irrelevant data. The exact reason is unknown. However, it is worth noting that with a dictionary size of 500, for forecasting a single stock, execution time is 0.82 seconds. This low number clearly shows the advantage one can achieve in high-frequency trading.Table 8
The influence of dictionary size.
Dictionary sizeMSEMAEDSExecution time (s)5000.014 80.3680.545 80.820 210000.032 30.530 20.614 30.853 350000.011 370.308 00.644 61.314The algorithm chose KMCC (30 minutes).


### 4.8. Important Note: Error Minimization and Profitability

We obtain an MSE of 10–4 as the lowest error. We can observe from Tables 4 and 5 that KAPA gives best results in terms of MSE and MAE. It is important to note that, in the one-minute time window, we reached a minimum error value. From Tables 4 and 5, we can also see that going down the column (for MSE and MAE only), the results are improving with the one-minute time window giving the best figures. However, because the time window is one minute, the volatility is low enough that decreasing error will not result in too much benefit. Moreover, there is too much noise while trading at one-minute window. To look at it another way, one-minute volatility is lower, resulting in very close predictions. However, in a low-volatility environment, the chances of taking a position and making a highly profitable trade are also low.


## 4.1. Dataset Description

This section explores into the specifics of the dataset that was used to test the applicability of the proposed method. For this study, we used data from the National Stock Exchange of India. The main index of NSE, Nifty-50, has 50 stocks. Based on the average and total daily turnover for equity shares, Nifty-50 is India’s largest stock exchange. We collected data between January 01, 2021, and May 31, 2021, from 9:15 a.m. to 3:30 p.m. In addition, experimentation data are available athttps://shorturl.at/lnvF2. The original data included open, high, low, and close (OHLC) prices and were available for one minute. The original data consisted of OHLC prices and were available for one minute. The dataset is generated and preprocessed in accordance with the nine prediction windows (one minute, five minutes, ten minutes, fifteen minutes, twenty minutes, twenty five minutes, thirty minutes, sixty minutes, and one day). Data samples range is different according to their time window. As pointed out in Section 1, we are trying to predict the mid-price with two different scenarios: (high + low)/2 and (open + close)/2. For this, firstly we calculated the percentage change of mid-price. All data values were normalized between zero to one range. Ten different KAF algorithms were used to the final preprocess data and each stock and analyse the comparative performance.


## 4.2. Evaluation Criterion

To measure and analyse the efficacy of various KAF algorithms, standard assessment criteria are used. In Table2, yi and di represent the actual and predicted output. n is the time step, and(20)Di=0,otherwise,1,yi−yi−1di−di−1≥0,.Table 2
Evaluation metrics.
MSEMAEDS∑i=1nyi−di21/n∑i=1nyi−di1/n∑i=1nDiCalculating the evaluation metrics with Nifty-50.(1)
The parameter listed in Table3 were tuned manually. The parameter description for ten different algorithms are presented in Table 3. These values were found after multiple rounds of experimentation.(2)
For the error values, we applied the methods to all stocks and tried to quantify the predictive performance via the metrics discussed in this section. In total, we get50×3 (one for each stock) error values for MSE, MAE, and DS, respectively.(3)
Then, for each of the 50 stocks, error estimation was performed using nine different prediction windows for ten different KAF algorithms.(4)
Finally, we used the average of all fifty-error metrics for a single time window and a single stock to reach the final value, which is presented in Tables4 and 5. On all 50 stocks, the provided number represents the models' overall predictive capacity.Table 3
Parameter description of KAF techniques for NSE-50 dataset for mid-price.
ParameterKAPAKLMSKMCCKNLMSFBQKLMSLKAPALMSNORMAPROB-LMSQKLMSσ5.07.04.07.056—3—4η1.51.71.71.70.20.03———0.2ϵ1E-4——1E-40.4——1.5—0.5β————0.85—————Λ—————1E-2—1E-20.4—σ2n————————2—σ2d————————3—mu00.2——2——0.2———(P)20————20————τ———————5000——tcoff———————4——σ = kernel width, σ2n = variance of observation noise, σ2d = variance of filter weight diffusion, η = step-size, ϵ = regularization parameter, Λ = Tikhonov regularization, tcoff = learning rate coefficient, τ = memory size (terms retained in truncation), mu0 = coherence criterion threshold, P = memory length, nu = approximate linear dependency (ALD) threshold, and β = forgetting factor for influence.Table 4
Result in terms of MSE, MAE, and DS for mid-price (high + low)/2.
Time windowMSEBest algorithms out of ten discussed (according to MSE)MAEBest algorithms out of ten discussed (according to MAE)DSBest algorithms out of ten discussed (according to DS)1 day0.030 6KAPA1.412 9KAPA0.537 8NORMA60 minutes0.009 1KAPA0.509 6KAPA0.559 2NORMA30 minutes0.005 3KAPA0.359 5KAPA0.555 8PROB-LMS25 minutes0.004 7KAPA0.331 4KAPA0.557 8NORMA20 minutes0.003 8KAPA0.290 9KAPA0.555 0NORMA15 minutes0.003 0KAPA0.253 4KAPA0.555 6NORMA10 minutes0.002 1KAPA0.201 9KAPA0.547 2NORMA5 minutes0.001 2KAPA0.144 7KAPA0.534 2PROB-LMS1 minute0.000 27KAPA0.059 0KAPA0.549 6NORMATable 5
Result in terms of MSE, MAE, and DS for mid-price (open + close)/2.
Time windowMSEBest algorithms out of ten discussed (according to MSE)MAEBest algorithms out of ten discussed (according to MAE)DSBest algorithms out of ten discussed (according to DS)1 day0.032 4KAPA1.298 9KAPA0.597 0NORMA60 minutes0.009 0KAPA0.454 1KAPA0.636 7NORMA30 minutes0.004 8KAPA0.316 8KAPA0.654 7NORMA25 minutes0.004 1KAPA0.290 3KAPA0.659 2NORMA20 minutes0.003 3KAPA0.254 3KAPA0.658 0NORMA15 minutes0.002 6KAPA0.219 8KAPA0.665 2KNLMS10 minutes0.001 7KAPA0.174 7KAPA0.666 6KNLMS5 minutes0.000 9KAPA0.122 4KAPA0.662 8KNLMS1 minute0.000 25KAPA0.055 2KAPA0.601 8KNLMS


## 4.3. Prediction, Convergence, and Residual Analysis

In this subsection, we examined prediction, converge and residual analysis with the help of KAF algorithms. Regarding this, we have shown the prediction graphs with the KAPA algorithm (discussed in Section 3.2.3) for one stock (TITAN). Figure2 shows the results for (high + low)/2, while Figure 3 shows the results for (open + close)/2. The predictive curve suits well against the original curve, as can be seen from the prediction graphs. It is worth noting that we have only given results for one prediction window (thirty-minutes) with one stock (TITAN). However, we must note that other stocks in the dataset produced similar result. The prediction graphs clearly show that the predictions are not exact, although they are close. To be precise, the numbers for MSE and MAE are presented in Tables 4 and 5. We must point out that getting accurate value in financial time series forecasting is tough. The goal has always been to get close enough values. Therefore, the result that we achieved shows the good predictive capability of the work. Figures 4 and 5 show the convergence graph for mid-price for (high+low)/2, (open+close)/2, respectively. We have provided the results using the KAPA algorithm with only one prediction window (thirty minutes) and one stock (TITAN), similar to the prior scenario. The algorithm converges quickly, as evidenced by the graphs, at the 1000th data point. We can see in KAF algorithms capacity to adapt and converge quickly. One more important point to note from the convergence graphs is that although there is some fluctuation in the graphs, it is nevertheless acceptable. This is because there will be noise in the new data and minor changes are inevitable. In addition to the results discussed so far, we have complemented the analysis by presenting the distribution of error residuals in Figures 6 and 7. It can be seen from the figures that residuals follow a normal distribution. Moreover, the outliers are also less. Furthermore, the residual's variance is low, demonstrating the KAF algorithm's superior prediction capability and potential in predicting the next immediate, mid-priced occurrence. Directional symmetry is used to determine the continuity of actual and expected prices in terms of stock movement. It is a measure for determining a model's ability to predict a stock's direction. We examined the ten different algorithms mentioned in Section 3 to better understand the actions of a stock’s movement. The experiment revealed that using KNLMS, we have a 66% percent chance of accurately predicting the next up or down movement. This is shown in Table 5. The best result is obtained at the window of ten minutes, and the worst result is obtained at the one-minute window. From the table, it is also visible that there is a big difference in the number obtained for the one minute window and that for the rest of the windows. This is expected as there is much noise in a minute, which indeed affects prediction. It should be noted here that literature often ignores looking at these different time windows. Work mostly focuses on predicting daily prices [42, 43]. We discovered the perfect balance by playing with various time windows. Furthermore, when trading, it is recommended to strike a balance between error minimization and directional symmetry.Figure 2
Prediction for one stock (TITAN) using KAPA (high + low)/2.Figure 3
Prediction for one stock (TITAN) using KAPA (open + close)/2.Figure 4
Error convergence for one stock (TITAN) using KAPA (high + low)/2.Figure 5
Error convergence for one stock (TITAN) using KAPA (open + close)/2.Figure 6
Error residuals for one stock (TITAN) using KAPA (high + low)/2.Figure 7
Error residuals for one stock (TITAN) using KAPA (open + close)/2.


## 4.4. Comparative Evaluation of KAF Algorithms

Since we have used ten algorithms in our experimentation, it becomes essential to compare their performance. In this context, we present the topic in two separate situations. First, we analyze the results considering mid-price as (high + low)/2 to find the best algorithm. In the next scenario, we tried mid-price using (open + close)/2. Tables4 and 5 show the outcome of this experiment. In terms of MSE and MAE, the tables show that KAPA outperforms other algorithms. When it comes to directional symmetry, we can see a contradiction. In directional symmetry, we see a conflict. Here, NORMA and KNLMS give the best performance.


## 4.5. Comparison with Methods of a Similar Kind

We have also compared the result with other existing techniques such as [28, 29] and [44]. These are some of the most recent deep learning (DL)-based algorithms for predicting stock prices. It should be noted here that these methods were trained and tested using 80:20 splits for 25 epochs. The time taken to train and make prediction was recorded. Specifically, these methods [28, 29] and [44] were reimplemented based on the architecture details and hyper-parameters setting found in the respective papers. The Nifty-50 dataset was used to train all of the methods. To ensure consistency across different methods for experimentation, we use sixty-minute time periods, for fifty stocks. All of the methods' results were then compared to the proposed method. Table 6 contains the results. The table's data clearly demonstrate the proposed method's superiority over a number of other waysTable 6
The proposed research is compared to different state-of-the-art stock prediction approaches.
MethodMSEExecution time (s)LSTM [28]0.683 1256.16LSTM [29]0.681 7945.09LSTM [44]0.682 41770.40KAPA (proposed method)0.009 12.132


## 4.6. Effect of Different Kernels

In Table7, we can see the effect of different kernel methods. For this test, we used a thirty-minute time window (Stock-TITAN) with the algorithm KAPA and analyzed the best performance of RBF kernel in terms of MSE. That is why, we have chosen RBF kernel (gauss) for each algorithm.Table 7
Effect of different kernel methods on time window of thirty minutes (Stock-TITAN) using KAPA for (high + low)/2.
(High + low)/2(Open + close)/2Kernel functionMSEMAEDSMSEMAEDSRBF kernel (Gauss)0.008 1200.298 570.534 210.008 270.260 470.531 88Anisotropic RBF kernel (Gauss-anis)0.019 190.406 170.515 550.025 350.348 680.579 31Laplace kernel (Laplace)0.008 1280.298 720.533 430.008 280.260 610.531 10


## 4.7. Experimentation with Dictionary Size

We also conducted experiments with various dictionary sizes. The result for this test is shown in Table8. For this test, we used a thirty-minute time window with the algorithm KMCC. It is visible from Table 8 that increasing the dictionary size leads to an improvement in the system's performance. It should be noted here that when the size is 1000, the performance has fallen. The reason for this behavior could be the erratic behavior of the stock, the presence of noise, or too much irrelevant data. The exact reason is unknown. However, it is worth noting that with a dictionary size of 500, for forecasting a single stock, execution time is 0.82 seconds. This low number clearly shows the advantage one can achieve in high-frequency trading.Table 8
The influence of dictionary size.
Dictionary sizeMSEMAEDSExecution time (s)5000.014 80.3680.545 80.820 210000.032 30.530 20.614 30.853 350000.011 370.308 00.644 61.314The algorithm chose KMCC (30 minutes).


## 4.8. Important Note: Error Minimization and Profitability

We obtain an MSE of 10–4 as the lowest error. We can observe from Tables 4 and 5 that KAPA gives best results in terms of MSE and MAE. It is important to note that, in the one-minute time window, we reached a minimum error value. From Tables 4 and 5, we can also see that going down the column (for MSE and MAE only), the results are improving with the one-minute time window giving the best figures. However, because the time window is one minute, the volatility is low enough that decreasing error will not result in too much benefit. Moreover, there is too much noise while trading at one-minute window. To look at it another way, one-minute volatility is lower, resulting in very close predictions. However, in a low-volatility environment, the chances of taking a position and making a highly profitable trade are also low.


## 5. Conclusion and Future Work

This paper focuses on predicting a stock's mid-price. Predicting a financial nonstationary time series is an open fundamental and a nontrivial problem of literature. To address this, we proposed a framework based on online learning-driven KAF algorithms. In the proposed work, ten different KAF algorithms were evaluated and analyzed on Indian National Stock Exchange (Nifty-50). In contrast to the existing methods, experiments are performed on nine different time windows. This was done keeping in mind the method’s applicability in intraday and swing trading. Previous studies often underestimated the importance of intraday time windows. We, therefore, tried to bridge this gap through the work presented here. The experimental results show the superiority and predictive capabilities of the work. The KAF class of algorithms was also discovered to be not only efficiently working in execution time but also providing best results of error minimization, demonstrating their importance in high-frequency trading. The goal of the research was to propose a KAF-based method for the prediction of stock’s mid-price. The empirical results on Nifty-50 dataset show that the proposed method achieved superior performance over existing stock prediction methods. On voting schema KAPA shown better prediction performance with all-time windows, NORMA & KNLMS gave the best performance in terms of directional symmetry. It is worth noting that every KAF-based algorithm is hyperparameter-sensitive. As a result, in the future, we will experiment with various hyper-parameter optimization approaches in order to enhance the framework’s predictive capabilities.



---

*Source: 3798734-2022-02-16.xml*