Predicting Daily Closing Prices of Selected Shares of Dhaka Stock Exchange (DSE) Using Support Vector Machines

: Support Vector Machines (SVM) has been a naval research field in scientific research for forecasting. This study deals with the application of SVM in financial time series predicting. This paper suggests a model of stock market prediction based on SVMs with appropriate parameter values. A data set of daily closing prices of five selected companies such as Alhaj Textiles Limited, Apex Tannery Limited, Jamuna Bank Limited, Padma Oil Company, and Square Pharmaceuticals Limited of the Dhaka Stock Exchange (DSE) from 01 January 2017 to 13 August 2019 was selected and uses these data to train the model and checks the predictive power of the model. The obtained results show that all the companies closing stock prices are non-stationary. Also the number of support vectors and mean square error is decreasing pattern with the increase of kernel parameter. It is also found that original data and predicted data are very much identical. The result shows that in all the cases SVM model has some predictive power it can be used to forecast financial time series. Several methods, such as SVM, ARIMA, single exponential smoothing, and double exponential smoothing, were performed to predict Bangladesh's stock market. Amazingly, the outcome shows the most efficient method to be Support Vector Machine because of its lowest forecasting errors.


Introduction
Financial time series forecasting is one of the most challenging applications of modern time series forecasting [1,4]. Stock price time series are data-intensive, noisy, dynamic, unstructured, and highly uncertain [20]. There have been many studies on forecasting time-series data. In recent years, the neural network has been successfully applied to financial time series modeling from Stock Price Index [9,12] to the option price [11]. Over the past decade, neural networks have been successfully used for modeling financial time series [1,19]. Recently, Support Vector Machines (SVM), a novel neural network algorithm developed by Vapnik and his colleagues is a focus research field in the world [14,16]. SVM method, which was first suggested by Vapnik has recently been used in a range of applications such as in data mining, classification, regression, and time series forecasting [10,7,13]. The SVM has become a hot topic of intensive study due to its successful application in classification tasks [17,3] and regression tasks [8,18], especially on time series prediction [2]. SVM is a training algorithm for learning classification and regression rules from data [3]. This research is to explore the use of SVM for stock price prediction by performing a comprehensive experimental study for predicting stock prices. This paper navels on the application of SVMs in regression tasks to predict the financial time series in the D.S.E. This study develops the SVM model for the different regularization constant (C) and different kernel parameters of radial basis function. Determine the validity of the model, different performance metrics were calculated.

Research Data
This study considered the daily closing price index of the Dhaka Stock Exchange conveniently from five different sectors for the selected companies such as Alhaj Textiles Limited, Apex Tannery Limited, Jamuna Bank Limited, Padma Oil Company, and Square Pharmaceuticals Limited within 01-01-2017 to 13-08-2019 from the DSE website based on their historical prices. Among these data, the training data cover the period from 01 January 2017 up to the end of 30 December 2018, while the data starting from 01 January 2019 up to 13 August 2019 has used as the test data. All the programs used to generate the results in this study have been written in R-package version 3.0.2. and the figures are produced in M.S. Excel.

Prediction Theory of SVM
Suppose the training nonlinear time series sample is k is the number of training sample data). The basic idea of SVM for time series prediction is a nonlinear mapping ϕ that transfers time series to the high dimensional feature space F . It then constructs the optimized linear regression function in the ample feature space, and the expression of the linear regression function as follows: In the expression above, w and ( ) x ϕ are both mdimension vector, and b is the offset value. SVM adopts the structural risk minimization principle to determine the importance of w and b . Namely In the expression (2) 2 w is the complexity of control and c is the weight thathas used to control the punishment degree that exceeds the error sample.
is the error control function, which is usually measured by the ε insensitive loss function, and the insensitive loss function is defined as follows: According to the structural risk minimization principle considering the complexity of the regression model obtained from the training set, regression based on the SVM essentially is a solution of an optimized question, and the optimized question is in the following.
are the kernel function, and the most commonly used optimized kernel function is the Gauss function and the concrete formula Based on the nature of quadratic programming, only several coefficients ' , i i a a assume as nonzero, and the data points associated with them could be referred to as support vectors.
Kernel Function For SVM, the following four underlying kernels are used γ r , and d are kernel parameters.

Results and Discussions
The use of SVMs of the selected companies' stock price prediction has studied in this paper. This study considers the daily closing price index of the Dhaka stock index from five different companies, such as Alhaj Textiles Limited, Apex Tannery Limited, Jamuna Bank Limited, Padma Oil Company, and Square Pharmaceuticals Limited between 01-01-2017 to 13-08-2019. Among the total of 629 data, 481 data are used for training data, and the rest 148 data are used for test data. The experiments will emphasize on verifying the performance and effectiveness of the SVMs. In our operations, the kernel parameter, and are selected based on the validation set. In the next paragraph, M.S.E., RMSE, NRMSE, and the number of support vectors concerning the three free parameters have investigated. Only the results of the kernel parameter have illustrated; the same has applied to the other two settings. In this investigation, the Radial basis function is used as the kernel function of the SVMs because Radial basis kernels tend to giveexcellent performance under general smoothness assumptions [6].
Consequently, they are especially useful if no additional knowledge of the data is available. This study compares the prediction performance concerning various kernel parameters and constants. According to Tay and Cao [15], an appropriate range was between 1 and 100. Besides, they proposed that a properscale for C was between 10 and 100. The LibSVM algorithm hasused in this study. This algorithm needs to determine some parameters they are regularization constant, setting of the kernel functions, and the margins of error. After performing cross-validation in the first training data, themetrics and are chosen to be and respectively, because these values produced the best possible results according to the validation set. An appropriate amount of the kernel parameter ( ) would be between 10 and 100 [15]. The prediction performance is evaluated using the statistical matrices, Mean Squared Error (M.S.E.), a measure of the deviation between actual and predicted values. The smaller amounts of M.S.E., RMSE, NRMSE, the closer is the expected time series values to that of the actual costs [5]. The study has been calculated different performance metrics for varying parameters of the kernel ( ) for the selected companies that illustrate in the below tables.  γ , respectively, in which c and ε has fixed at 10 and .001. The result of these tables shows that in all the cases, the Mean Square Error, Number of Support Vector, Normalized Root Mean Square Error is decreasing with the increasing of kernel parameter γ , So most of the data points are converging to the support vectors. Therefore, the support vector model fits the actual data well. After the training with SVM, the predicted price and the actual price for the test data has exhibited in the following figures.      The above five figures illustrate the Real data and predicted data. The blue line is the actual value, and the red line is the predicted value of our method. From the figures, it can be observed that the predicted value curve's tendencies are identical to that of the actual value curve in all the cases. The predicted curve fits the real curve in most of the period. Therefore, SVMs predict the actual data very well. The experimental results show that this method is more effective and efficient in predicting closing stock prices. The study has also calculated different forecasting errors of Support Vector Machines with Classical time series methods.

Conclusions
The use of Support Vector Machines (SVM) in financial forecasting has been studied in this paper. This work establishes a model of stock market prediction based on SVM. The experimental result showed that the SVM model has some predictive power; it has been used to predict stock prices. The study also reveals that the predicted value curve is identical to the actual value curve. So SVM predicts the actual value very well. It has also been found that in all cases, SVMs are more appropriate to predict stock prices. SVMs predict better, as SVMs provide a smaller M.S.E., NRMSE, and RMSE compares to other classical time series methods. Therefore SVMs shift a hopeful alternative to time series prediction in Bangladesh.
To sum up, as the stock market is an important sector, this study can help determine whether to buy a stock or sell it, and this crucial purpose can be served with the help of stock market predictions. This study has been done for five selected companies, and it has extended with more stock companies on DSE. The other prospect of taking this research further is by comparing the results with other machine learning techniques.

Data Availability Statement
The data that support the findings of this study are openly available on the Dhaka Stock Exchange (D.S.E.) website www.dsebd.org.