Philippines Stock Exchange Prediction Using Hybrid Neural Network

The stock market is dynamic and highly chaotic due to its complicated nature. The prediction of future stock prices has gained the interest of investors and researchers. Numerous conventional and hybrid approaches were put forth. The projections performed poorly and strangely did not get any better. This study aimed to predict Philippine Stock Exchange closing prices using a proposed hybrid method. This proposed study aimed to improve the Artificial Neural Network (ANN) performance using the Kepler Optimization Algorithm, a metaheuristic algorithm, in conjunction with the Artificial Neural Network (ANN-KOA). ANN is a widely accepted technique in predicting. Still, the Kepler Optimization Algorithm can provide random initial inputs for the method through effective feature selection. It can identify superior subsets of input variables to integrate into ANN, enabling more accurate prediction. In this study, the ups and downs were grouped, and 12 technical indicators with varying lengths of days 3, 5, 10, 15, and 20 were used to decompose the original historical data, which are regular and smoother than the original data. The historical data was normalized into [-1, 1], so the predicted result would be 0 (decrease) or 1 (increase) otherwise. Finally, to obtain the train and test data, it was fused into five groups and tested using the ANN and ANN-KOA. The experiment's outcome of 0 (a declining stock price) indicates two alternative courses of action based on the two scenarios: holding if investors have already purchased it or purchasing if they haven't made a decision. In this proposed study, ANN-KOA resulted in higher accuracy than ANN. However, regarding the number of elapsed times, KOA-ANN provided a slower time than ANN. On the other hand, in terms of variations of lengths of the days, 3-5-10-KOA-ANN outperformed the variations of lengths of days: 3-5-10-ANN, 3-5-10-15-KOA-ANN, 3-5-10-15-20-KOA, and 3-5-10-15-20-KOA-ANN. In conclusion, this study suggested that it be utilized for other problems, such as predicting academic performance, diseases, floods, etc.


INTRODUCTION
The main goal of investing is to make a profit.Investing in the stock market is one pathway to having a passive income.The primary goal of stock market investment is to make money.Still, nearly 50% of people comfort themselves with the thought that they will eventually buy stocks, even though they are not doing so now because they are uncertain about the future.Some are hesitant to invest due to its chaotic characteristics.Anybody suspicious about generating money through stock investing does so due to a lack of market expertise and the large percentage of investments that result in losses rather than gains.Technological advancements like global digitization have brought about a technologically advanced period in stock market prediction, reinforcing the conventional trading approach.Stock traders consider stock market prediction to be one of their main concerns.The dynamic nature of stock market data can be attributed to the contradictory magnitude of essential elements.Stock market prediction is a challenging task.As a result, the task of comprehending and predicting the stock market draws in scholars, investors, analysts, and fans [1].Many researchers and analysts have developed tools and techniques designed to predict fluctuations in stock prices and assist investors in making informed investing choices [2].
Researchers and academics from businesses to academic sectors have focused on studying and forecasting the financial market.The abstract notion of a financial market refers to the exchange of financial products and services between buyers and sellers, such as derivatives, bonds, stocks, and foreign currencies.Their influence on business, education, employment, technology, and the economy is noteworthy."It is argued that the performance of the PSEI reflects the financial health of Philippine business as a whole," states Balaba.One could argue that the stock market's performance indicates the economy's direction.
In particular, investors, researchers, and enthusiasts examine the stock market index to evaluate the behavior of the country's economy, as it serves as a collective measure of an investor's value.Regarding inflation, Filipino investors believe that investing in the Philippine stock market will keep them ahead of inflation and provide them with financial security.
The stock market is often a sentiment indicator affecting gross domestic product [3].Consequently, investors, researchers, and enthusiasts are keen to study its movement.Some research or studies have found that its movement takes a random path.Some studies examine different factors such as interest rate, inflation (deflation), and unemployment and believe that these factors affect the movement and trend of the stock, using various technical, fundamental, and sentimental analyses.
Due to its complicated nature, the stock market is dynamic and highly chaotic, making it hard to predict and monitor its movement.Philip, Taofiki, and Bedimi explained that it is non-stationary, inherently noisy, and deterministically chaotic.The noisy characteristics refer to the unavailability of complete information from the financial market's past behaviors to capture the dependency between future and past prices fully.
Numerous researchers used different methods, such as traditional methods, including time series and Regression, and analyzed fundamental and technical aspects [4].Other researchers have combined machine learning with various methods, such as artificial neural networks and random forests.However, no papers examine the Philippine Stock Exchange using machine learning or mixed methods.
Hybrid artificial neural networks and other algorithms were used to improve the accuracy of the predicted values.Guresen et al. [5] conducted a study demonstrating the strength of the DAN2 neural network architecture.While the algorithm can reduce training error, hybrid models that combine GARCH and EGARCH do not ensure a reduction in testing error.The hybrid model based on DAN2 achieves the lowest error, indicating improved noise tolerance for DAN2.
Another study was conducted by Rather et al. [6], who formed a robust hybrid model using the merged ANN, linear (RNN), and nonlinear model (HPMM).Gucken et al. [6] conducted a comparable study.Based on this study, the most pertinent technical indicators are chosen using hybrid Artificial Neural Network (ANN) models, which combine the strengths of Harmony Search (HS) and Genetic Algorithm (GA) to capture the relationship between the technical indicators and the stock market for the period under investigation.The HS-based ANN model is the best for stock market forecasting.
A similar study addressed the problems regarding the movement of stock and stock index of the Indian stock market [7].Poor results of the traditional way or algorithm resulted in the creation of a hybrid algorithm such as a combination of machine learning and fundamental analysis [8], ANN, fundamental and technical analysis [9], soft computing technique and Particle Swarm Optimization [10].Three methods were classified for predicting the stock market: fundamental analysis and technical analysis, which includes AR, MA, ARIMA, and machine learning [11].The effectiveness of ARIMA in forecasting the stock market was studied, and it was found that it had 0.85 accuracy.However, focusing on specific sectors, such as the banking and automobile sectors, produced a lower accuracy than other accuracy [12].
Hybrid artificial neural networks and other algorithms were used to improve the accuracy of the predicted values.A study by Guresen et al. [13] demonstrated the strength of the DAN2 neural network architecture.While the algorithm can reduce training error, hybrid models that combine GARCH and EGARCH do not ensure a reduction in testing error.The hybrid model based on DAN2 achieves the lowest error, indicating improved noise tolerance for DAN2.
Most PSEi research has been conducted in the Philippines to examine the nation's economic expansion rather than day trading.One study focused on predicting PSEi but used ARIMA as a technique and individual companies.This paper focuses on predicting the PSE trading days, forecasting the following using the proposed new method, and comparing it to the Artificial neural network.
This study aimed to forecast the Philippine Stock Exchange (PSE) using the Artificial Neural Network (ANN) and a proposed method, KOA-ANN.Specifically, the study focused on comparing ANN and KOA-ANN to determine the accuracy of the two algorithms and to predict the next trading day using these algorithms.The research aimed to answer several key questions: how accurate the proposed KOA-ANN method could be in predicting the following trading days, whether the forecasts generated by the model could aid in making trading decisions, and which combinations of architecture for the variations of the trading days yield better results when combined.These research challenges were designed to address the main goals and objectives of the study, providing a thorough framework for examining the accuracy and efficacy of the KOA-ANN approach in PSE forecasting.

METHOD 2.1 Data Preprocessing
This paper utilized the secondary data extracted from Yahoo Finance.The historical data was from April 1, 2010, to December 29, 2023.This study employed an Artificial Neural Network to determine the predicted values and proposed a hybrid algorithm, KOA-ANN.This study determined the data's ups and downs and used 12 (twelve) selected technical indicators.During this span, the closing price went up to 1747 and down to 1567, as shown in Table 1.The data was run into five cross-validations.Cross-validation is a resampling method to evaluate the predictive model's ability to prevent overfitting [14].There were five runs overall, with one group of data used as a test data set and the other four as training data sets.This ensured that each group was utilized as a test data set precisely once.This was to decompose the original data and make it smoother.
The equation for each input variable was derived using the 13 commonly used technical indicators for stock price and index forecast [14], [15], [16].The relevant indicator equations are displayed in Table 3.Each technical indicator yielded four input variables, each computed using one of the following four historical period lengths: 3, 5, 10, 15 and 20 days.This resulted in a total of 13 × 5 = 60 input variables for span lengths: 3,5,10,15, 20 ; 13 × 4 = 52 inputs for span lengths 3,5,10,15; and 13 × 3 = 39 inputs for span lengths 3,5,10.The highest average was the 2nd run (26.43)during the cross-validation, whereas the lowest was the 5th run (19.5).On the other hand, to normalize the data, every input variable was given the same weight by being normalized to [−1, 1].There were only two possible values for the single output variable: 0 indicates a downward trend in the expected PSE for the following day, and 1 indicates an upward trend.Technical indicators are a popular statistical technique used to identify trends in stock.Here, the trend can be an uptrend or a downtrend [17].

Artificial Neural Network
An Artificial Neural network (ANN) mimics the structures and functions of a biological network.It follows the architecture shown in Figure 1.The flow of information, as depicted in Figure 1, starts when a signal reaches a synapse through dendrites and axons.The signals passing through a synapse can adjust its effectiveness to learn from the activities it participates in [18].

Proposed New Method Hybrid KOA and ANN
Kepler Optimization Algorithm (KOA) is a physics-based metaheuristic algorithm inspired by Kepler's laws of motion to predict the position and velocity of the planets [19].In this algorithm, each earth acts as a candidate with its initial position, and the best solution is called the Sun.In contrast, an Artificial Neural network mimics the structures and functions of a biological network.
The Kepler Optimization Algorithm is known for searching for the best candidate performed [20].It can be seen that KOA's performance is significantly superior to all the rival algorithms [21]  In this study, to measure the accuracy, utilizing the formula which can be calculated as follows: Where TP is true positive, TN is true negative, FP is false positive, and FN is false negative.
During the pre-processing, with 12 technical indicators and trained 8000 epochs, the data was simulated in MATLAB online software for the ANN and ANN-KOA.

Predicted next trading days
This experiment's predicted value for the first four days was 1 (up trend).On this trading day, the decision that needed to be taken was as follows: do nothing if already sold and sell if no actions were taken.However, in the next 139 trading days, the predicted value was 0 (downtrend).The trading decision that needed to be taken was as follows: Hold if already bought and Buy if no actions were taken (Table 5).

Artificial Neural Network
ANN is a machine learning model that abstracts the human brain's neural network from the information processing standpoint and assembles various networks based on multiple connections [22].ANN-KOA (0.6162) outperformed the traditional ANN.This is a similar result from Farahani,2021, comparing ANN to another metaheuristic algorithm.
Combining the usual algorithm with ANN could result in a lesser error.On the other hand, this study tested different time variations to build an efficient prediction model.In this experiment, the shorter term 3-5-10 trading days for ANN provided 0.6131, which is a better result than 3-5-10-15 and 3-5-10-15-20, as shown in Table 4  Similarly, 3-5-10 provided a better result for ANN-KOA than 3-5-10-15 and 3-5-10-15-20, as shown in Table 5.The result revealed that accuracy was changing based on the year.The year 2011 outperformed the other years with an accuracy of 0.8676, and the accuracy dropped to 0.8636 for 2011.
Comparing ANN and ANN-KOA, ANN-KOA was more efficient than ANN alone.Usmani [23] supported this result.A combined algorithm could improve the accuracy of the predictions.The actual movement compared to predicted values was scattered and efficient for the shorter term.This implied that it was more accurate than the other two variations of days.This asserted that the longer the variations provided, the lower the accuracy.

DISCUSSION
The recent investigation focused on forecasting the Philippine Stock Exchange trading days with a hybrid methodology integrating the Artificial Neural Neural Network.The 3552 trading days were extracted from Yahoo! Finance for experimental works.The up times and downtimes were determined and separated.After separating the data, it became 3314 trading days since the null data were removed, including data from holidays such as Christmas and New Year.The data was gone through cross-validation to avoid over-fitting.The data was divided into five groups during cross-validation: 4 for training data and 1 for testing data.The data was simulated using Matlab online software.Conversely, to standardize the data, each input variable was assigned equal importance by being normalized to a range of [-1, 1].The sole output variable had only two potential values: 0 represented a downward trend in the projected PSE for the next day, while 1 indicated an upward trend.After the cross-validation, the data was trained using Artificial Neural Network and finally tested for the proposed methods.The accuracy was tested using the formula adopted by Inchantot et al.The main observation of this study is that the short-term horizon provided a better result.The study's results highlight a significant improvement in accuracy when combining machine learning techniques with shorter variations, making this experiment a compelling option for various applications.This result highlights the efficacy of combining KOA and ANN to increase prediction accuracy by minimizing noise and intricacy.
One of the key findings is that short-term variations' accuracy is higher than longterm variations.In this investigation, the ANN performed superiorly on a short-term horizon.However, in this experiment, the proposed combined method, ANN and Kepler Optimization, outperformed the ANN -alone in a short-term horizon and the other two variations.The utilization of KOA to optimize the input variables and starting weights in the ANN is believed to have contributed to this enhancement by guaranteeing that the model provided a more efficient set of parameters.This significant result asserted that the shorter variations reduce the noise and complexity of the data, which, in turn, facilitates better learning and prediction by the artificial neural network and the combined proposed model.This simplification allowed the algorithms to operate more effectively, honing in on crucial patterns without being overwhelmed by extraneous data.This reduction in complexity allowed the algorithms to focus on the most relevant features, thereby improving their performance.This study demonstrated that this method leads to more precise and reliable outcomes, surpassing the performance of artificial neural networks alone.
On the other hand, the study also highlighted the efficiency gained from the combined methods.Hybrid artificial neural networks and other algorithms were used to improve the accuracy of the predicted values.Guresen et al. [5] agreed with this study, which demonstrated the strength of the DAN2 neural network architecture, a hybrid method.The leading accuracy of the Hybrid ANN-KOA model compared to the ANNalone model can be caused by some possibilities.Based on the existing evidence, the KOA's capability to offer outstanding beginning criteria enables ANN to local minima during training, resulting in improved overall performance.This is one of the characteristics of KOA.Incorporating KOA may improve the model's capacity to manage stock market data's non-linearity and chaotic characteristics, typically included in conventional models.In theory, the mixture of meta-heuristic optimization with neural networks is consistent with previous research that indicates hybrid models can achieve better results than single methods by utilizing the advantages of many techniques.
The comparison of these results with earlier studies emphasizes the originality and efficacy of the hybrid ANN-KOA technique.Previous studies, such as Guresen et al. [13] and Rather et al. [24], have shown that hybrid models can enhance prediction accuracy.Nevertheless, this research frequently concentrated on other markets or employed alternate methods.The present study's utilization of KOA, a comparatively innovative optimization technique in the context of the Philippine stock market, offers fresh perspectives and a distinctive contribution to the area.
The study's findings indicate numerous possible uses and avenues for future investigation.The improved precision of the hybrid ANN-KOA model can be used for a range of additional prediction tasks, including forecasting academic achievement, disease outbreaks, and natural disasters such as floods.Moreover, this approach can provide traders and financial analysts valuable insights, influencing their investment strategies and decision-making processes.Subsequent research endeavors may investigate the utilization of this model in various stock markets or expand the analysis to incorporate more technical indicators and longer prediction timeframes to assess the strength and applicability of the results.In summary, the hybrid ANN-KOA model notably improves stock market prediction methods and provides a helpful tool for researchers and practitioners.

CONCLUSION
In this paper, the proposed algorithm was a new combined algorithm: Kepler Optimization Algorithm and Artificial Neural Network.This study's result confirmed that hybrid algorithms could predict market behavior.The ANN-KOA predicted 61.62% accuracy in short-term variations of days.Instead of utilizing KOA alone, the study showed that combining KOA and ANN improves predictive accuracy.This implies hybrid strategies combining machine learning and metaheuristic algorithms could improve financial market prediction abilities.In conclusion, This study suggested using a shorter-term variation of days to improve accuracy.Kepler Optimization improved the accuracy performance.However, this study recommended utilizing other metaheuristic algorithms, such as Genetic Algorithms, Simulated Annealing, etc.This method could be employed in other prediction problems, such as predicting diseases, floods, etc.

Table 1 .
Down Times and Uptimes

Table 3 .
Technical Indicators Note: n is n-day period times ago; Ct is closing price; Lt is a low price at time; Ht is high at time t ; DIFF =EMA(12)t -EMA(26)t ; EMA is exponential moving average; EMA(k)t =EMA(k)t-1 +∝(Ct -EMA(k)t-1); ∝ is smoothing factor =2/(1+k); k= 10 in k-day exponential moving average; LLTt and HHt are the lowest low and highest high in the last t days, respectively; Mt= (Ht+ Lt + Ct)/3;SMt =∑  −+1 UPt is upward index change at time t, DWt is downward indexat time t; + DInis plus directional indicator and -DIn is minus directional indicator.

Table 4 .
Summarizes the architecture of Artificial Neural Networks.

Table 5 .
Predicted Value for the next trading day

Table 6 .
Accuracy of Artificial Neural Network

Table 7 .
Accuracy Performance of ANN-KOA