A New Particle Swarm Optimization Based Stock Market Prediction Technique

Over the last years, the average person's interest in the stock market has grown dramatically. This demand has doubled with the advancement of technology that has opened in the International stock market, so that nowadays anybody can own stocks, and use many types of software to perform the aspired profit with minimum risk. Consequently, the analysis and prediction of future values and trends of the financial markets have got more attention, and due to large applications in different business transactions, stock market prediction has become a critical topic of research. In this paper, our earlier presented particle swarm optimization with center of mass technique (PSOCoM) is applied to the task of training an adaptive linear combiner to form a new stock market prediction model. This prediction model is used with some common indicators to maximize the return and minimize the risk for the stock market. The experimental results show that the proposed technique is superior than the other PSO based models according to the prediction accuracy. Keywords—Computational intelligence; Particle Swarm Optimization; Stock Market; Prediction


INTRODUCTION
Stock market is, without a doubt, one of the greatest tools ever invented for building wealth.Stocks are main element, if not the cornerstone, of any investment portfolio.This demand coupled with advances in trading technology has opened up the markets so that nowadays nearly anybody can own stocks, and use many types of software to achieve the aspired profit with minimum risk.Consequently, a lot of attention has been devoted to the analysis and prediction of future values and trends of the financial stock markets, and due to large applications in different business transactions, stock market prediction has become a hot topic of research.Particle Swarm Optimization (PSO) has become popular choice for solving complex and intricate problems, which are otherwise difficult to solve by traditional methods.The usage of the Particle Swarm Optimization technique in coping with stock market prediction problems is the most important applications of PSO to predict the stocks that have maximum profit with minimum risk.In our earlier paper [1], a new Particle Swarm with Center of Mass (PSOCoM) Optimization algorithm is presented which gives a new efficient search technique.It gets benefit from the physical principle "Center of Mass" to move the particles to the new best predicted position.The new proposed technique improves the performance of the current PSO technique.In this paper, the presented particle swarm optimization with center of mass technique (PSOCoM) is applied to the task of training an adaptive linear combiner to form a new stock market prediction model.This prediction model is used with some common indicators to increase the profit and decrease the risk in stock market.
The survey of the relevant literature showed that there have been many studies for stock market prediction, Many research papers have appeared in the literature using evolutionary computing tools such as genetic algorithm (GA) [2], particle swarm optimization (PSO) [3], and bacterial foraging optimization (BFO) [4] in developing forecasting models.In [5], Hassan et al. described a novel time series forecasting tool, their fusion model combines a Hidden Markov Model (HMM), Artificial Neural Networks (ANN) and Genetic Algorithms (GA) to forecast financial market behavior.
In another work, Aboueldahab, et al. [6] introduced a new Enhanced Particle Swarm Optimization (EPSO) to train the Sigmoid Diagonal Recurrent Neural Networks (SDRNN) weights and applied this technique in the forecasting of both NASDAQ100 and S&P500 stock market indices.Majhi, et al. [4] used the standard particle swarm optimization (PSO) algorithm to develop an efficient forecasting model for prediction of S&P500 and DJIA stock indices.The connecting weights of the adaptive linear combiner based model are adjusted by the PSO so that its mean square error (MSE) is minimized.Also in [4], Majhi in 2008 developed two new forecasting models based on bacterial foraging optimization (BFO) and adaptive bacterial foraging optimization (ABFO) were presented to predict S&P500 and DJIA stock indices using technical indicators derived from the past stock indices.The structure of these models is basically an adaptive linear combiner, whose weights are trained using the ABFO and BFO algorithms.
A new adaptive-filter method for predicting assets on the stock markets is proposed in [7].This method is applied through the prediction over the actual valuation of the PETR3 shares (Petrobras ON) traded in the Brazilian Stock Market.The authors evaluated the first-rate choices of the window length and the number of filter coefficient.Observing the correlation between the predictor signals did this and the actual course performed by the market in terms of both the window prevision length and filter coefficient values.It is shown that such adaptive predictors furnish, on the average, very substantial profit on the invested amount.
The rest of the paper is organized as follows: in Section II the proposed technique is presented, Section III gives the evaluation of the proposed algorithm is presented, and Section IV concludes this paper with a summary of main points.

II. THE PROPOSED STOCK MARKET PREDICTION TECHNIQUE
In this section, the proposed technique is described.The It is important to refer that the previous scenario considers one day ahead closing price with its seven indicators values to train the prediction model, so when five days ahead closing price with their seven indicators values are used for training, the dimension of the particles will be D = 35.According, the number of connecting weights is equal to 35.However, in the prediction step, the optimized weight values, obtained by PSOCoM technique, are used to give the predicted price for the same forecasting stock price through an adaptive linear combiner.
Where: M is the number of test patterns.

B. Parameter Settings
The same set of parameters is applied to the compared prediction models, namely, ALCPSO, ALCLDWPSO, ALCCenterPSO, ALCMeanPSO and the proposed model, inertia weight w is linearly decreased from 0.9 to 0.4, and isfixed at 0.9 in PSO and Mean PSO.The acceleration coefficients are set to = 2 = 2.the maximum velocity is set to Vmax= 0.5 and Xmax= 1.The swarm size is set to 30.The maximum number of iterations was set to 100.Initialization is range of particle positions was -1≤ xi ≤ 1.All mean square errors (MSE) and mean absolute percentage errors (MAPE) are computed over 30 runs.The seven common technical indicators used for this evaluation are EMA10, EMA20, EMA30, SMA10, RSI9, RI14 and PROC27.In short term prediction experiment, the training period was set to 100, 200 and 500 days to predict test period of 100 days.In long term prediction experiment, the training period was set to 1000 and 1500 days to predict test period of 750 days.

C. Results and Discussion
There are two types of prediction to evaluate the proposed prediction model, short-and long-term prediction.Various experiments are carried out by varying the selection of technical indicators as a new feature with closing price to the inputs of the models.As a result, the best set of used indicators, which produced more accurate prediction are: EMA30, RSI14 and PROC27.These sets of indicators are applied to all calculations in this experiment.To clarify the learning characteristics of the compared models in short and long term, the mean square error (MSE) is considered as a measure during the training process.In short term prediction, Figure 2 to Figure 4 show the learning characteristics of the compared models obtained for one day advance with three technical indicators EMA30, RSI14 and PROC27, to predict DJIA, NASDAQ-100 and S&P500 stock indices, respectively.Figure 5 to Figure 7 show the learning characteristics of the compared models for long term.It is noted that the proposed PSOCoM converged faster than the other versions of PSO during the training process and reached the best minimum value of MSE indicating the convergence of the weights.This shows that the proposed PSOCoMis superior than the other PSO versions in learning characteristics, and in abstracting the important feature during training to perform more accurate prediction.Table II shows the best mean absolute percentage error (MAPE) obtained by the compared forecasting models for short and long term prediction.The comparative results of prediction the DJIA, NASDAQ-100 and S&P500 stock indices were obtained for one day and seven days ahead prediction over 30 runs.Observations of Table I indicate that the MAPE of the proposed predication model is the lowest between the compared PSO based models for all the stock market indices forecasting.This shows that the proposed forecasting model superior to the other PSO based models according to the prediction accuracy.It is noted that the MAPE obtained for short term prediction is less than that obtained for long term prediction, for example, the MAPE of short term prediction for DJIA index is equal to 0.0325%, while the MAPE of long term predication for DJIA index is equal to 0.8601%.Thus, the ratio between the short term and the long term MAPE predication equals to 0.1.This shows that all the PSO based forecasting models in addition to the proposed forecasting model give accurate prediction for short term prediction, while the prediction accuracy decreases for long term prediction.Back to the historical data for any index in stock markets, as known to all investors in financial stock markets, the last period of any stock can give important information about the next coming move of that stock, For short term investment the best selected period for abstract important information that guides to good prediction is three months to one year.Any information abstracted out of this period may disperse the investor and wrong prediction may be take place.On the other side, the best period for long-term investment is from one to three years.However, the previous notes verifies the obtained results as shown in Table II, where the MAPE increases as the training period increases for both of short-and long-term prediction.According to the complexity of the compared forecasting models, Table II shows that one day and seven days ahead used in all the calculations, where one day ahead indicates that there are four inputs to the adaptive linear combiner (one day ahead close price and three selected indicators).Consequently, the dimension of the particle is equal to four (the connecting weights of the adaptive linear combiner are equal to four), while for seven days ahead there are 28 inputs to the adaptive linear combiner (seven days closing prices and three selected www.ijacsa.thesai.orgindicators for that seven days), so the dimension of the particle becomes 28 (the connecting weights of the adaptive linear combiner are equal to twenty eight).
As a result, when the particle dimension increases (more complexity) the MAPE of the compared forecasting PSObased models increase (prediction accuracy decreases), while the proposed forecasting model gives almost the same MAPE for the two degree of complexity (one day and seven days ahead).This means that the optimal or near optimal solution (optimal values of connection weights in the adaptive linear combiner) is reached by the proposed PSOCoM technique.This shows that the prediction accuracy of the proposed forecasting model is almost the same while the complexity increases.

IV. CONCLUSION AND FUTURE WORK
A novel stock market prediction technique has been proposed.Also, a new stock market prediction model based on the proposed PSOCoM technique has been provided.This prediction model uses PSOCoM technique to adjust the weights of an adaptive linear combiner.The results of the experiments showed that the proposed forecasting model is superior than the other PSO based models according to the prediction accuracy.
The PSO based forecasting models in addition to the proposed forecasting model give accurate prediction for short term prediction, while the prediction accuracy decreases for long term prediction.The MAPE obtained by prediction models increases as the training period increases for both of short term prediction and long term prediction.As a result, the proposed forecasting model is a new promising forecasting model for stock market prediction.In the future, based on the proposed prediction technique, it can design a new selection technique to select the best stocks with highest profit and minimum risk.Furthermore, a new automated system can be developed based on the proposed work to become an intelligent agent that makes trades in stock markets to get maximum profit with minimum risk, gives the decision of buy and sell for the best selected stocks, and gives the final profit at the end of the required period.www.ijacsa.thesai.org structure of the proposed stock market prediction technique is assumed to be an adaptive linear combiner with parallel inputs as shown in Figure1.It is an adaptive finite impulse response (FIR) filter with number of inputs equal to the number of features in the input patterns.These features are abstracted from the stock market series such as closing prices and technical indicator values.The connecting weights of the adaptive linear combiner are considered as the particles, and initial their values are set to random numbers in the range [-1, +1].The swarm of particles is chosen to represent the initial solutions of the model.Each particle is adjusted during the training step by the way of minimizing the mean square error (MSE) as an objective function for PSOCoM technique.To give a clear sight about the methodology of proposed prediction model, let N represent the number of patterns (e.g. 100 days training set),and D is the size of an input pattern to an adaptive linear combiner (e.g.D = 8 means one day ahead obtained from the past stock prices plus seven technical indicator values related to this day), which equal the number of adjusted weights and also the dimension of the particles, so that every eight values (one day ahead price plus seven indicator values) are passed through an adaptive linear combiner, and multiplied with weights of an adaptive linear combiner and the partial sums are added together to give (k) as an output for the combiner.Then, this output is compared with the corresponding desired stock price d(k) to produce the error (k).A shift one day forward produces new error until reaching the end day in training set (100 days) is reached.After that, each produced error is squared and added to the others using the accumulator shown in Figure1.The summation is divided by number of patterns to give the mean square error for the particle as shown in equation1 which is the objective function of the PSOCOM technique, so that the aim is to minimize this mean square error for best training.∑ (1)

Fig. 1 .
Fig. 1.The proposed stock market prediction model If there is M number of test patterns, the mean absolute percentage error (MAPE) is used to measure the performance of prediction model during the forecasting stock prices as follows: EMA + (P-Previous EMA)*A where A = 2/(N+1) , A is smoothing factor, N is time period, P is current price.EMA10 = preEMA10 + (P-preEMA10)*(2/11) EMA20 = preEMA20 + (P-preEMA20)*(2/21) EMA30 = preEMA30 + (P-preEMA30)*(2/31) www.ijacsa.thesai.orgIII.EVALUATION OF THE PROPOSED STOCK MARKET PREDICTION TECHNIQUE In this section, the performance of the proposed technique is evaluated.The historical data of used indices and the values of parameters settings are described.Finally, the results and their discussion are presented.A. Historical Data The historical data of three common indices, namely, National Association of Securities Dealers Automated Quotations 100 (NASDAQ-100), Dow Jones Industrial Average (DJIA) and Standard's & Poor's 500 (S&P 500), are used in this experiment for the evaluation of the proposed prediction model.These historical data consist of daily close prices and technical indicators derived from those indices.Total number of samples for the stock indices is 2500 trading days, from 2 January 2005 to 31 December 2014.Each sample consists of the opening price, highest price, lowest price, closing price and the total volume of the stocks traded for the day.

Fig. 2 .Fig. 3 .
Fig. 2. Learning characteristics of compared models to predict DJIA for one day advance (short term prediction)

Table I
[15]ribes the indicators' equations, which are used in this paper.All previous indicators' equations were abstracted from "Encyclopedia of Technical Market Indicators" book published by Colby[15].

TABLE II .
COMPARATIVE RESULTS OF MEAN ABSOLUTE PERCENTAGE ERROR (MAPE) AVERAGED DURING PREDICTION PROCESS OVER 30 RUNS