JJMIE Jorda Joural of Mechaical ad Idustrial Egieerig Volume 5, Number 5, Oct. 2011 ISSN 1995-6665 Pages 439-446 Modelig Stock Market Exchage Prices Usig Artificial Neural Network: A Study of Amma Stock Exchage S. M. Alhaj Ali*,a, A. A. Abu Hammad b, M. S. Samhouri a, ad A. Al-Ghadoor a a Idustrial Egieerig Departmet, Faculty of Egieerig, Hashemite Uiversity, Zarqa 13115, Jorda b Civil egieerig Departmet, College of Egieerig, Applied Sciece Uiversity, Amma 11931, Jorda Abstract Stock market represets a essetial part of the ecoomy i the Middle East, it is sigificat for shareholders ad ivestors to estimate the stock price ad select the best tradig opportuity accurately i advace. This paper utilizes artificial eural etwork i the modelig of stock market exchage prices. The etwork was traied usig supervised learig. Simulatio was coducted for seve case study compaies from Amma Stock Exchage represetig both the service ad maufacturig sectors. The case study compaies were selected from differet categories varies accordig to the degree of stock market stability. The model was evaluated by stock market brokers through the use of a questioaire that was distributed i Amma Stock Exchage, the majority of the participats foud the results acceptable. The use of ANN provides fast covergece; high precisio, ad strog forecastig ability for real stock prices which it tur will brig high retur ad reduce potetial loss to stock brokers. 2011 Jorda Joural of Mechaical ad Idustrial Egieerig. All rights reserved Keywords: Artificial Neural Network; Supervised Learig; Simulatio; Stock Market; Amma Stock Exchage; Predictio 1. Itroductio Stock market is the market ivolved with the issuace ad trade of shares either through exchages or over-thecouter which is also kow as equity market, it provides compaies with access to capital ad ivestors with a segmet of owership i the compay ad the prospective of gais based o the compay's future performace [1-2]. Stock market represets a essetial part of the ecoomy i the Middle East; however, stock markets i the Middle East are usually small ad deeply regulated. Lack of reliable iformatio, isider tradig, accoutig practices, ad govermets iterferece are amog the problems that are ecoutered by ivestors. Some Middle East markets have limit foreigers to ivest i the stock market except i some bourses, as those of Egypt, Lebao, ad Israel [3]. Apparetly, it is sigificat for shareholders ad ivestors to estimate the stock price ad select the best tradig opportuity accurately i advace. This will brig high retur ad reduce potetial loss to ivestors. Traditioal methods for stock price forecastig are based o the statistical methods, ituitio, or o experts judgmet. Time series aalysis, Autoregressive Movig Average (ARMA) models, Autoregressive Coditioal Heteroskedasticity (ARCH) models, ad Autoregressive Itegrated Movig Average (ARIMA) models [4] are usually used for forecastig the stock market prices, however, their performace depeds o the stability of the prices (i. e. if the prices time-series exhibits memory), as more political, ecoomical ad psychological impact factors get ito the picture, the problem becomes o liear, ad eed a more heuristic or oliear methods like ANN, Fuzzy logic ad Geetic Algorithms [5-6]. Jordaia stock market faces cotiuous fluctuatig values due to political ad ecoomical factors; it also witesses a oticeable sharp growth i the last few years. Thus, it is imperative for the Jordaia stock brokers to employ ew aalysis tools. The motivatio of this research was to itroduce the cocept of ANN ito the Jordaia busiess sector ad utilize it i forecastig the Jordaia stock market prices. A lot of research had bee coducted for usig ANN i stock market prices forecastig, Hassou [7] defies ANN as parallel computatioal models comprised of desely itercoected adaptive processig uits, they are viable computatioal models for a wide rage of problems icludig patter classificatio, speech sythesis ad recogitio, adaptive iterfaces, fuctio approximatio, image compressio, associative memory, clusterig, forecastig ad predictio, combiatorial optimizatio, oliear system modelig, ad cotrol. ANN ca outperform other methods of forecastig due to its remarkable ability to derive meaig from complicated or imprecise data, it had bee used successfully to extract complex patters ad treds [8]. Literature shows that ANN ca be used i predictio, classificatio, data associatio, data coceptualizatio, ad data filterig [9]. Steier ad Wittkemper [10] had developed a portfolio optimizatio model embedded i the oliear dyamic capital market model based o ANN. A ecoomic approach to the aalysis of highly itegrated fiacial markets ad ecoometric methods had bee developed by * Correspodig author. e-mail: souma@hu.edu.jo
440 2011 Jorda Joural of Mechaical ad Idustrial Egieerig. All rights reserved - Volume 5, Number 5 (ISSN 1995-6665) Poddig ad Rehkugler [11]. Doaldso ad Kamstra [12] proposed a methodology for forecastig future stock prices ad retur volatilities for fudametally valuig assets such as stocks ad stock optios. 2. Amma Stock Exchage Amma Stock Exchage (ASE) is a private o-profit istitutio with admiistrative ad fiacial autoomy that was established i March 1999 ad authorized to fuctio as a exchage for the tradig of securities by a board of directors. It icludes i its membership 70 Jordaia brokerage firms. The ASE is a active member of the Uio of Arab Stock Exchages, Federatio of Euro-Asia Stock Exchages, World Federatio of Exchages, ad a affiliate member of the Iteratioal Orgaizatio for Securities Commissios [13]. 3. ANN Mathematical Model The euro ca be modeled mathematically as show i Fig. 1, where: x ( t),..., x( t) The cell iputs are 1 The cell output is y(t) v 1,...,v The dedrite or iput weights are v The firig threshold or bias weight is 0 The cell fuctio or activatio fuctio is f output per euro [14]: y f ( l j 1 y l (t). This etwork ca be modeled as vljx j vl 0); l 1,2,..., L. However, most of the ANN cosists of more tha oe layer, where the secod layer iput is the first layer output ad so o. The cases preseted i this paper eeded two ad three layers, the output for the etwork cosists of three layers ca be writte based o Eq. (4) as follows: 3 y l f ( vkl f2( vio f1( v jpx p v j0) vi0) vk 0) (5) Where: l 1 2 o 1 1 3 p 1 f1, f2, f3 : are the activatio fuctios for layer 1, layer 2, ad layer 3 respectively. 1, 2, 3 : are the umber of iput sigals for layer 1, layer 2, ad layer 3 respectively. L : is the umber of outputs for layer. v2 1, v32, vl3 : are the iput weights for layer 1, layer 2, ad layer 3 respectively. v20, v30, vl0 : are the bias weights for layer 1, layer 2, ad layer 3 respectively. l 1,2,..., L. The etwork used for stock market prices forecastig model build from two or three layers, 13 iputs ad oly oe output; the variables of Eq. (5) were set as follows: (4) y : The price i JD s for the 14th workig day of the moth. x1 x 13 : The stock market prices for the first 13th days of the moth. The other variables were set accordig to the case study. Figure 1: Neuro mathematical model. The output ca be expressed as [14]: y ( t ) f ( v j x ( j t ) v ). 0 (1) j 1 Eq. (1) ca be streamlied by defiig the augmeted 1 colum vector of the cell iputs x( t) ad the iput 1 weights v( t) as [14]: x t) 1 x x... ( 1 2 T x v ( t), v v v... v T 0 1 2 (2) The Eq. (1) ca be writte i matrix otatio as [14]: T y f ( v x). (2) Oe layer ANN is commoly used which has L cells, all x (t) fed by the same iput sigals j, ad producig oe 4. Traiig a ANN Oce a etwork has bee structured for a particular applicatio, that etwork is ready to be traied. To start this process the iitial weights are chose radomly. The, the traiig, or learig, begis. There are three approaches to traiig or learig: Supervised learig, usupervised learig, ad reiforcemet learig. The vast bulk of etworks utilize supervised learig. Usupervised ad reiforcemet learig are used to perform some iitial characterizatio o iputs. However, i the full blow sese of beig truly self learig, it is still just a shiig promise that is ot fully uderstood ad i eed for further research. 4.1. Supervised Learig: Supervised learig, or learig with a teacher, or associative learig is where the etwork is supplied with a traiig data set that icludes a set of iputs ad its correspodig output or target, ANN adjusts their weights usig oe observatio at a time. Learig is achieved by
2011 Jorda Joural of Mechaical ad Idustrial Egieerig. All rights reserved - Volume 5, Number 5 (ISSN 1995-6665) 441 miimizig a criterio fuctio which is the average square error betwee the etwork outputs ad the target. 4.2. Reiforcemet Learig: to forecast the prices for the ext year startig from February till Jauary, Fig. 5 reveals the forecasted prices agaist the actual prices, as show i the figure the forecasted price is very close to the actual oe. The learig process i reiforcemet learig is desiged to maximize the expected value of a criterio fuctio by usig trial ad error. That is if the actio improves the state of affairs the the tedecy to produce this actio is reiforced while if it deteriorate the state of affairs, the the tedecy to produce it is weakeed [7]. The traiig data does ot icludes a target; istead, it icludes a performace judge or a utility fuctio that reports how good the curret etwork output [15]. 4.3. Usupervised learig: I this case the etwork is adapted without givig it ay kid of directive feed back, i other words there are o target iformatio i the traiig data or a performace judge, rather the learig objective is to fid out the features iheret i the traiig data [16-18]. Stock market forecastig is doe by approximatig the fuctio or the relatioship betwee iputs ad output, thus supervised learig is more appropriate for our applicatio compared to the other two, furthermore, supervised learig is more mature ad accurate tha the other two learig approaches. Figure 2: Stock market prices for Arab Egieerig Idustry Compay. 5. Simulatio Results To test the efficiecy ad effectiveess of the model a Software program was developed usig MATLAB for this purpose. The weights ad biases of the etwork were automatically iitialized to small radom umbers by the software. Seve Jordaia compaies from differet sectors were used as case studies. For each compay, a full year was used for traiig the etwork; each moth was used as a differet patter. The data startig from February ad edig with Jauary were used for the traiig; the validatio was doe by usig the ext year prices startig from February ad edig with Jauary. Differet traiig fuctios, activatio fuctios, umber of layer, ad umber of euros were tried till the error coverged to the set value which is 10-6. The performace fuctio used was the mea square error (MSE). MSE is the average squared error betwee the etwork outputs ad the target. 5.1. Case 1: Arab Egieerig Idustry The traiig was doe usig oe step secat backpropagatio, a two layers etwork was used with Hyperbolic taget sigmoid activatio fuctio for the first layer ad hard limit activatio fuctio for the secod layers, the first layers cosists with 14 euros ad 1 euro for the secod layer. The stock market prices for this compay durig the year i Jordaia Diars (JD) are show i Fig. 2, after eterig these data ito the simulatio software, the error resultig durig the traiig is show i Fig. 3. As show i the figure the etwork was able to trai the data with 9.7245*10-7 i oly 11 epochs. To put thigs ito perspective, the output of the etwork is plotted agaist the target as show i Fig. 4, after the etwork passed the validatio stage, the etwork was used Figure 3: Traiig error for Arab Egieerig Idustry Compay. Figure 4: Traiig output agaist the target for Arab Egieerig Idustry Compay.
442 2011 Jorda Joural of Mechaical ad Idustrial Egieerig. All rights reserved - Volume 5, Number 5 (ISSN 1995-6665) Figure 7: Traiig error for the Nutriadar Compay. Figure 5: Forecasted prices agaist the actual prices for the Arab Egieerig Idustry Compay. 5.2. Case 2: Nutriadar: Jordaia Drug Compay: The same traiig fuctio was used, however, this time three layers cotai (14,10,1) euros respectively was eeded to coverge to a small traiig error, the first ad secod layers used positive liear trasfer activatio fuctio, while the third layer used a hard limit trasfer activatio fuctio. The stock market prices for this compay are show i Fig. 6, as revealed from the figure this compay exhibit a oticeable variatio of the prices amog days i each moth, which make the forecastig job more difficult, after eterig these data ito the simulatio software, the error resultig durig traiig is show i Fig. 7. As show i the figure the etwork was able to trai the data i 1000 epochs that took oly 30 secods. The output of the etwork is plotted agaist the target as show i Fig. 8, the figure prove that the etwork output matches the actual prices, after the etwork passed the validatio stage, the etwork was used to forecast the prices for the ext year, Fig. 9 reveals the forecasted prices agaist the actual prices. This time the forecasted price was slightly differet tha the actual prices, however, the gap did ot exceed.08 JD (1 JD=$1.40). Figure 8: Traiig output agaist the target for the Nutriadar Compay. Figure 9: Forecasted prices agaist the actual prices for the Nutriadar Compay. Figure 6: Stock market prices for the Nutriadar Compay.
2011 Jorda Joural of Mechaical ad Idustrial Egieerig. All rights reserved - Volume 5, Number 5 (ISSN 1995-6665) 443 Figure 9: Forecasted prices agaist the actual prices for the Nutriadar Compay. Figure 11: Traiig error for Jerusalem Isurace Compay. 5.3. Case 3: Jerusalem Isurace Compay: The traiig was doe usig oe step secat backpropagatio, two layers cotai (14,1) euros respectively was eeded to coverge to a small traiig error, the first layer used positive liear trasfer activatio fuctio, while the third layer used a hard limit trasfer activatio fuctio. The stock market prices for this compay are show i Fig. 10, as revealed from figure, the stock prices vary durig the moths, its also varies from moth to aother, after eterig these data ito the simulatio software, the error resultig durig the traiig is show i Fig. 11. As show i the figure the etwork took 174 epochs ad 20 secod to reach a performace level of 10-8. The output of the etwork is plotted agaist the target as show i Fig. 12, the etwork output is very close to the actual prices, after the etwork passed the validatio stage, the etwork was used to forecast the prices for the ext year, Fig. 13 reveals the forecasted prices agaist the actual prices. This time the forecasted prices are close to the actual prices. Figure 12: Traiig output agaist the target for Jerusalem Isurace Compay. Figure 10: Stock market prices for Jerusalem Isurace Compay. Figure 13: Forecasted prices agaist the actual prices for Jerusalem Isurace Compay.
444 2011 Jorda Joural of Mechaical ad Idustrial Egieerig. All rights reserved - Volume 5, Number 5 (ISSN 1995-6665) 5.4. Case 4: Uited Glass Idustries: The traiig was doe usig oe step secat backpropagatio, two layers cotai (14, 1) euros respectively was eeded to coverge to a small traiig error, a two layers etwork was used with Hyperbolic taget sigmoid activatio fuctio for the first layer ad hard limit activatio fuctio for the secod layers. The stock market prices for this compay durig the year is show i Fig. 14, which shows that the stock prices are very stable, its varies from moth to aother but i very small amout (maximum chage was 0.050 JD), eterig these data ito the simulatio software resulted i a error of 10-7 i oly 10 epochs as show i Fig. 15. The output of the etwork is plotted agaist the target as show i Fig. 16, the etwork output matches exactly the actual prices, after the etwork passed the validatio stage, the etwork was used to forecast the prices for the ext year, Fig. 17 reveals the forecasted prices agaist the actual prices. The forecasted prices are very close to the actual prices except for the last moth (Jauary) where the actual price has a small drop. Figure 16: Traiig output agaist the target for Uited Glass Idustries Compay. Figure 14: Stock market prices for Uited Glass Idustries Compay. Figure 17: Forecasted prices agaist the actual prices for Uited Glass Idustries Compay. The rest of the seve case studies were very close to the oes preseted before where the etwork was able to trai very quickly the data ad produce a very good forecast, except for oe case that will be preseted ext. 5.5. Case 7: Jorda Petroleum Refiery: Figure 15: Traiig error for Uited Glass Idustries Compay. A three layers ANN was used i this case of (14,7,1) euros o the three layers, the traiig was doe usig oe step secat backpropagatio, the first ad secod layers used positive liear activatio fuctio, while the third layer used hard limit activatio fuctio. The stock market prices for this compay durig the year are very volatile ad vary substatially from moth to moth or eve durig the same moth as show i Fig. 18. The performace level could reach 10-3 withi 90 secod through 1000 epochs. After 1000 epochs, the traiig mea square error was 10-3 which is far from the specified error of 10-6 as show i Fig. 19. The output of the etwork is plotted agaist the target as show i Fig. 20, this time the etwork output slightly differs from the target, although it exhibits the same patter, fially, usig the etwork to forecast the prices of the ext year resulted i very good forecast for the first four moths (February-Jue) as show i Fig. 21, after Jue the actual prices jumps from 15 JD s to 4 JD s, the forecasted prices jumps too at the same time but with differet amplitude (from 14 to 1 JD) the it follow the
2011 Jorda Joural of Mechaical ad Idustrial Egieerig. All rights reserved - Volume 5, Number 5 (ISSN 1995-6665) 445 same patter of the actual price but with a gap that is less tha 2 JD s. Further ivestigatio ito this case reveals that the compay broke the shares i order to icrease the supplied quatity of them which caused the prices to drop to 3 JD s. Figure 21: Forecasted prices agaist the actual prices for Jorda Petroleum Refiery Compay. Figure 18: Stock market prices for Jorda Petroleum Refiery Compay. 6. Discussio The results obtaied from the software were very accurate for six out of seve cases, which prove that this is a valid techique for stock market price forecastig. I the last case the results shows that although the etwork did ot give a good forecast due to the sigificat drop i the actual Stock market prices but it followed the same patter of the actual price, which meas that eve whe the actual stock prices chage dramatically for ay assigable cause, the etwork was able to catch up ad the forecast chage at the same moth ad eve with the same patter as the actual data. This proves that this method ca give a very good idicatio about market treds. 7. Model Evaluatio by Stock market brokers Figure 19: Traiig error for Jorda Petroleum Refiery Compay. Figure 20: Traiig output agaist the target for Jorda Petroleum Refiery Compay. The model was evaluated by stock market brokers through the use of a questioaire that was distributed i Amma Stock Market, the questioaire was desiged so that it ca be filled i o more tha two miutes, it first presets the forecastig results obtaied from the etwork ad the asked the participat to aswer seve multiple choice questios, focus o the techiques curretly used by the broker, ad whether he wat to use the etwork i the future, oly seve questioaires were retured. I respose to a questio askig Would you deped o the ANN techique for forecastig Amma Stock Market prices?, five out of the seve participats who aswered the questioaires stated that they would deped o ANN techique, while two of them stated that they would partially deped o ANN techique. I respose to aother questio Do you believe that this techique will be applicable to all categories of compaies (volatile, stable)?, six participats decided that the ANN techique will be applicable to all compaies categories, while oe participats believed that it is ot applicable to all categories of compaies.
446 2011 Jorda Joural of Mechaical ad Idustrial Egieerig. All rights reserved - Volume 5, Number 5 (ISSN 1995-6665) 8. Coclusios This paper utilizes artificial eural etwork i the modelig of stock market exchage prices. The model was developed usig a feed forward eural etwork with two to three layers; the etwork was traied usig oe step secat backpropagatio, the activatio fuctios used were hyperbolic taget sigmoid, positive liear ad hard limit trasfer fuctio. Simulatio software developed by MATLAB was used to evaluate the etwork performace for seve Jordaia compaies selected from service ad maufacturig sectors. The compaies have differet degree of stock prices stability. The etwork was traied o a whole year data; the etwork was able to produce the output withi a MSE of 0.0023*10-8 from the target. The etwork performace was evaluated usig the stock market prices of the followig year, the etwork output Refereces [1] Hagstrom R G, Miller B. The Essetial Buffett: Timeless Priciples for the New Ecoomy. 1 st ed. Joh Wiley & Sos Icorporated; 2002. [2] Ivestopedia ULC. Ivestopedia Dictioary. Ivestopedia a Forbes digital compay; 2009; http://www.ivestopedia.com/terms/s/stockmarket.asp. [3] Mattar Ph. Ecyclopedia of the Moder Middle East ad North Africa. 2 d ed. USA: Macmilla Library Referece; 2004. [4] Mills T C. Time Series Techiques for Ecoomists. Cambridge Uiversity Press, 1997. [5] Greee W H. Ecoometric Aalysis. 5th ed. Pretice Hall; 2003. [6] IvestorWords. IvestorGuide.com, Ic. 2005; http://www.ivestorwords.com. [7] Hassou M H. Fudametals of Artificial Neural Networks. USA: Massachusetts Istitute of Techology Press; 1995. [8] C. Stergiou, D. Sigaos, Neural etworks. Surprise Joural, Vol. 14, 1996. [9] Aderso D, McNeil G. Artificial Neural Networks Techology. NY: Rome NY, Rome Laboratory; 1992. [10] M. Steier ad H. G. Wittkemper, Theory ad Methodology: Portfolio optimizatio with a eural etwork implemetatio of the coheret market hypothesis. was very close to the actual data, except for oe case, for which the compay broke it s shares i the middle of the year, however, eve i that case the etwork output drops dramatically to values close but ot exactly the same as the oes of the actual data. The results of the etwork were further evaluated by stock brokers from Amma stock market; the majority of the resposes stated that they may deped o ANN techique ad that they believe that the techique is applicable to all categories of compaies. The model is sigificat i view of the fact that stock market represets a essetial part of the ecoomy i the Middle East. Usig the developed ANN model ca help shareholders ad ivestors to estimate the stock price ad select the tradig chace that will maximizes their profits more accurately i advace compared to the curretly used methods. Europea Joural of Operatioal Research, Vol. 100, 1997, pp. 27-40. [11] T. Poddig ad H. Rehkugler, A world model of itegrated fiacial markets usig artificial eural etwork. Neurocomputig, Vol. 10, 1996, pp. 251-273. [12] Doaldso R G, Kamstra M. Forecastig Fudametal Stock Price Distributios. Caada: Uiversity of British Columbia; 2000. [13] Amma Stock Exchage, About ASE, http://www.ammastockexchage.et/, 2008. [14] Lewis F L, Jagaatha S, Yesildirek A. Neural Network Cotrol of Robot Maipulators ad Noliear Systems. Padstow, UK: Taylor ad Fracis Ltd, T. J. Iteratioal Ltd; 1999. [15] Sethi K, Jai A K. Artificial Neural Networks ad statistical Patter Recogitio: Old ad New Coectios. Amsterdam, Netherlads: Elsevier Sciece Publishers B. V.; 1991. [16] Hassou M H. Associative Neural Memories: Theory ad Implemetatio. New York, USA: Oxford Uiversity Press, Ic.; 1993. [17] Kohe T. Self-Orgaizatio ad Associative Memory. 2d ed. Berli Heidelberg, Germay: Spriger-Verlag; 1988. [18] Micheli-Tzaakou E. Supervised ad Usupervised Patter Recogitio: Feature Extractio ad Computatioal Itelligece. USA: CRC Press LLC; 2000.