10 October 2018

Prediction of Stock Price in Investor Portfolios with Stock Price Time Series Analysis using ANN Wibiksana Hendra S2 Informatics Engineering Telkom University Bandung, Indonesia hendra2621@gmail.com Houw Liong Thee Postgraduate Telkom University Bandung, Indonesia thehl007@gmail.com Fatchul Huda Arief Mathematics Engineering UIN Sunan Gunung Djati Bandung, Indonesia afhuda@uinsgd.ac.id

Prediction of Stock Price in Investor Portfolios with Stock Price Time Series Analysis using ANN Wibiksana Hendra S2 Informatics Engineering Telkom University Bandung, Indonesia hendra2621@gmail.com Houw Liong Thee Postgraduate Telkom University Bandung, Indonesia thehl007@gmail.com Fatchul Huda Arief Mathematics Engineering UIN Sunan Gunung Djati Bandung, Indonesia afhuda@uinsgd.ac.id Abstract—Indonesia Stock Exchange (IDX) is a place to trade the stock market in Indonesia. In general, this is represented by the value of Jakarta Composite Index (JCI). JCI itself is the combined value of all stocks listed on the Stock Exchange. It does not matter whether the stock traded on that day is in a state of rising, down, flat (no change in value), not being traded and even suspension (prohibited from conducting transactions for a certain period of time). The stock data source used is the closing stock price of BNI, BCA and Mandiri stocks for 5 years from 2011-2015 from the Indonesia Stock Exchange (via yahoo finance site). Each of these stock data are be trained and tested, to observe how much the accuracy by using this method. The stock price that has been predicted by ANN are merged into a portfolio, this portfolio will shows the increasing or decreasing. At the end of process, the change rate of loss predicted stock price into beneficial predicted stock price are calculated. The daily data accuracy of BNI, BCA and Mandiri are 97.7474%, 98.2266%, and 97.8942%. Weekly accuracy data a bit smallest than daily accuracy. The weekly data accuracy of BNI, BCA and Mandiri are 95.4247%, 97.0631%, and 96.5706%. Monthly accuracy data a bit smallest than weekly accuracy. The monthly data accuracy of BNI, BCA and Mandiri are 91.6259%, 95.9425%, and 94.1434%. If the investor focuses all of his funds only to buy one stock, then he will have a portfolio profit of 3 times more than before. If the profit of BNI stocks is 19.19%, then in terms of the investor portfolio will have a profit of 19.19% x 3 = 57.57%. Compare with the profit level of the 3 banks which if we add up, the value will be as follows: 19.19+17.68+15.73 = 52.6%. So there are additional benefits from a portfolio of 57.57% - 52.6% = 4.97%. Keywords— stock, Backpropagation, prediction, portfolio Background Jakarta Composite Index (JCI) is a value used to measure the combined performance of all stocks listed on the Indonesia Stock Exchange. JCI can be used to assess the general market situation or measure if the stock price has increased or decreased. JCI rose show excitement, whereas JCI down indicate a market sluggishness [1]. When there is an increase in JCI, of course stock investors excited because it could achieve a profit as much as the price difference between the current sales price and the purchase price of the stock before. The other way, when JCI has decreased, of course, mostly small / large investors are experiencing a panic with the action of release the stock. Stocks are proof of equity in a company. By buying a company's stock, you are investing capital or funds that will be used by the management to finance the company's operational activities. There are two types of corporate shares: preferred stock and common stock. Portfolio is if you diversify your investments in more than one stock or with a combination of bonds, forex, property or other assets in order to reduce risk, you have created a portfolio. The stock data source used is the closing stock price of BNI, BCA and Mandiri shares for 5 years from 2011-2015 from the Indonesia Stock Exchange [2] [3] [4]. For the theory, Backpropagation algorithm is applied. Backpropagation is the one method for pattern recognition beside Perceptron, Adeline and Madeline. Backpropagation use data input, hidden neuron and data output for estimate forecast value ahead based on given source data. Backpropagation is better than other 3 pattern recognition methods for time series case. Predicting stock price become challenging for this decade [5]. So many previous researcher to find the best model for predicted stock price like Jay Desai, Arti Trivedi and Nisarg A Joshi (2013) [6]. This research uses closing price data as training and testing data set, unfortunately from his experiment only reached training accuracy result still 59.84% and average testing accuracy 82%. The data used by Jay Desai, Arti Trivedi and Nisarg A Joshi are the homogeneous data in the form of price out (close) S & P CNX Nifty 50 Index. Trading data used by it is from January 1, 2010 to December 31, 2011. Jay Desai use neural network with one input layer, one hidden layer and one linear output layer. 10 input variables are used with 10 neurons in the hidden layer. All networks tested in the study are trained for 3,000 epochs. So based on this result, I want improve that accuracy better than him. I will make propose new neural network architecture with one input layer, one hidden layer and one output layer, where input layer contains 20 input data, 10 hidden neurons in hidden layer and 1 output data in output layer. The objective is to purposes of this research are to predict stock prices portfolio with prediction accuracy greater than 82%. The hypothesis is this prediction can be achieved by ANN method and hope its accuracy value can be greater than 80% for BNI, BCA and Mandiri stock and stock price portfolio greater than 80%. RESEARCH DESIGN This study contains some parts, starting from collecting raw data, backpropagation process include training and testing, prediction plot combination training and testing, making plot from testing data from each stock (BNI, BCA and Mandiri), calculate delta value from each stock (BNI, BCA and Mandiri), plot portfolio, and calculate benefit BNI, BCA, Mandiri, and portfolio based on the above banks. An overall architecture of the stages is shown in Figure 1. Figure 1 Research Design Legends: 1. Close Price Stock Data for training and testing 2. Backpropagation 3. Prediction plot Training+Testing 4. Making plot from testing data from each stock (BNI, BCA, Mandiri) 5. Best accuracy from daily, weekly and monthly data 6. Calculate delta value from each stock (BNI, BCA, Mandiri) (tn – tn-1) 7. Buy and sell for each stock (BNI, BCA, Mandiri) 8. Combine 3 delta value (BNI, BCA and Mandiri) into 1 plot 9. Decision which stock have high benefit to investor with delta value each stock 10. Delta value for buy stock (- - +) at the lowest price from 3 banks 11. Delta value for selling stock (+ + -) at the highest price from 3 banks 12. Print table benefit portfolio 13. Calculate benefit 14. Plot portfolio 15. Result analysis Raw data Experiment began with collecting data from one resources. Where the dataset is obtained from yahoo finance website [see implementation process no.3 in chapter 4 Experiment Result] during 5 years from January 1, 2011 until December 31, 2015. List of stock dataset are close price data of BNI, BCA and Mandiri stocks. Backpropagation process Backpropagation divide to 2 phase: training process and testing process. The training and testing data will be separate in 3 scenario: 60%:40%, 70%:30% and 80%:20%. Training process In training phase, there are several phase: Close Price Stock Data Experiment began with collecting data from one resources. Where the dataset is obtained from yahoo finance website [2] [3] [4] during 5 years from January 1, 2011 until December 31, 2015. List of stock dataset are close price data of BNI, BCA and Mandiri stocks. For this case, the dataset used is for training data. For detail, you can see in next step below. Training Process In here, each close price stock data (BNI, BCA and Mandiri) be trained for forecast 1 month and 3 months based on daily data, weekly data and monthly data with proportion 60%:40%, 70%:30% and 80%:20%. It means from 100 data, 60 became training data and the other will become testing data (60%:40%). It will be the same with proportion for 70%:30% and 80%:20%. Weight and Bias In here, each input variable from training process will calculate and update weight and bias until will be get MSE value. Tolerance error minimum or max epoch reached In here, tolerance error be setting to less than 0.001 and max epoch be setting maximum 10,000 epochs. In fact, the stop condition achieved during an experiment is always the maximum epoch number achieved than the error rate that must be achieved less than 0.001. An overall architecture of training process is shown in Figure 2. Testing Process In testing phase, there are several phase: Close Price Stock Data Experiment began with collecting data from one resources. Where the dataset is obtained from yahoo finance website for BNI [2], BCA [3] and Mandiri [4] stock during 5 years from January 1, 2011 until December 31, 2015. List of stock dataset are close price data of BNI, BCA and Mandiri stocks. For this case, the dataset used is for testing data. For detail, you can see in next step below. Testing Process In here, each close price stock data (BNI, BCA and Mandiri) be tested for forecast 1 month and 3 months based on daily data, weekly data and monthly data with proportion 60%:40%, 70%:30% and 80%:20%. It means from 100 data, 40 became testing data and the other will become training data (60%:40%). It will be the same with proportion for 70%:30% and 80%:20%. Surely, testing process based on the training model result where contains weight and bias value before to executed. Prediction result The value between origin testing data and forecast data during testing process. An overall architecture of training process is shown in Figure 3. Prediction plot After second process (Backpropagation process) above is done, the prediction result from each training and testing will be combine into one plot for every experiment scenario. There are describe step by step by diagram below (see Figure 4). Weight and bias value from Training model result, can be used for testing process After testing process is done, it will give a prediction result Making plot from testing data from each stock (BNI, BCA and Mandiri) From prediction plot training and testing, only testing data plotted and calculate delta value from each stock (BNI, BCA and Mandiri). The delta value formula is: delta = tn – tn-1 where tn is the forecast value for today and tn-1 is the forecast value for yesterday. Figure 2 Backpropagation Training Process Figure 3 Backpropagation Testing Process Portfolio plot This section is the next step after prediction plot process (step 3 above) is done. Best result from daily, weekly and monthly accuracy Selecting from each daily, weekly and monthly plotting in step 3c, which is getting the best accuracy. The best accuracy from that 3 type data, it will be continue to next step. Combine 3 delta value into 1 plot In here, the delta value from previous step, will be combine 3 delta value both BNI, BCA and Mandiri into 1 plot Decision which stock have high benefit to investor In here, the system will decision which stock has high benefit to investor with comparison delta value from each stock. Which the stock to buy and sell. For more explanation about this, you can see in section 3.4.1 and 3.4.2 about buy analysis and sell analysis Print table benefit Print table benefit both BNI, BCA and Mandiri stock Plot portfolio Making plot portfolio from table benefit Figure 4 Prediction Plot Result Analysis Giving conclusion which stock has high benefit to investor during period An overall architecture of the stages is shown in Figure 5. Table 1 Scenario of Research for BNI, BCA and Mandiri No Data Type Training Total Data Testing Total Data 1 Daily 60% 736 40% 490 2 70% 858 30% 368 3 80% 981 20% 245 4 Weekly 60% 155 40% 103 5 70% 181 30% 77 6 80% 206 20% 52 7 Monthly 60% 36 40% 24 8 70% 42 30% 18 9 80% 48 20% 12 EXPERIMENT RESULT A detail about experiment result, you can see in Table 2 below.  Table 2 Experiment Result No. Bank Data type Training Total Data Accuracy Testing Total Data Accuracy 1 BNI Daily 60% 736 97.9652% 40% 490 97.956% 2 70% 858 97.9903% 30% 368 97.9066% 3 80% 981 98.0134% 20% 245 97.7474% 4 Weekly 60% 155 96.9404% 40% 103 96.1172% 5 70% 181 96.8367% 30% 77 96.017% 6 80% 206 96.8925% 20% 52 95.4247% 7 Monthly 60% 36 92.2304% 40% 24 93.0717% 8 70% 42 92.384% 30% 18 93.0797% 9 80% 48 92.8769% 20% 12 91.6259% 10 BCA Daily 60% 736 98.0013% 40% 490 98.4043% 11 70% 858 98.0028% 30% 368 98.3903% 12 80% 981 97.9829% 20% 245 98.2266% 13 Weekly 60% 155 97.3678% 40% 103 97.4292% 14 70% 181 97.447% 30% 77 97.3375% 15 80% 206 97.5270% 20% 52 97.0631% 16 Monthly 60% 36 93.7236% 40% 24 96.6982% 17 70% 42 94.3474% 30% 18 96.2256% 18 80% 48 94.6175% 20% 12 95.9425% 19 Mandiri Daily 60% 736 97.8848% 40% 490 98.2297% 20 70% 858 97.9111% 30% 368 98.2633% 21 80% 981 97.9246% 20% 245 97.8942% 22 Weekly 60% 155 96.4793% 40% 103 96.8952% 23 70% 181 96.5508% 30% 77 96.9584% 24 80% 206 96.7027% 20% 52 96.5706% 25 Monthly 60% 36 92.3449% 40% 24 95.0939% 26 70% 42 92.8416% 30% 18 95.1057% 27 80% 48 93.3736% 20% 12 94.1434% How to calculate portfolio Portfolio benefits are calculated from the difference between the latest investment value and the initial investment value divided by the initial investment value. The value of prediction accuracy with daily data is better than weekly and monthly, because the data trained on daily data is more than weekly and monthly data. For buying or selling, use formula: Current price * amount of shares For profit calculation, use formula: (Ending value-beginning value)/(beginning value)*100% Table 3 below only happen if an investor diversify his cost to each bank. BNI, BCA and Mandiri stock are only got benefit 19.19%, 17.68% and 15.73%. But what if investors only focus their funds on one stock that has the highest profit level? In other words, the funds that were supposed to be used to buy BCA and Mandiri stocks were all only used to buy BNI stocks. Table 3 Portfolio benefits: BNI BCA Mandiri Buy: IDR 6,100 as much as 1 lot or 100 shares (IDR 610,000) Selling: IDR 7,270.9092 (IDR 727,090.92). Profit: IDR 1,170.9092/share or IDR 117,090.92 (19.19%) Buy: IDR 13,125 as much as 1 lot or 100 shares (IDR 1,312,500) Selling: IDR 15,445.4704 (IDR 1,544,547.04) Profit: IDR 2,320.4704/share or IDR 232,047.04 (17.68%) Buy: IDR 5,387.5 as much as 1 lot or 100 shares (IDR 538,750) Selling: IDR 6,234.8643 (IDR 623,486.43) Profit: IDR 847.3643/share or IDR 84,736.43 (15.73%) If this is the case, then investors will have a portfolio profit of 3 times more than before. If the profit of BNI stocks is 19.19%, then in terms of the investor portfolio will have a profit of 19.19% x 3 = 57.57%. Compare with the profit level of the 3 banks which if we add up, the value will be as follows: 19.19+17.68+15.73 = 52.6%. So there are additional benefits from a portfolio of 57.57% - 52.6% = 4.97%. Figure 5 Prediction Plot conclusion All experiments have been completed, with a total 27 experiments where each stock like BNI, BCA and Mandiri each have 9 experiments with daily, weekly dan monthly data. From the experimental results for BNI, BCA and Mandiri stocks, both for daily, weekly and monthly data, it is known that the value of accuracy with daily data is better than the value of weekly and monthly data accuracy. The daily data accuracy of BNI, BCA and Mandiri are 97.7474%, 98.2266%, and 97.8942%. Weekly accuracy data a bit smallest than daily accuracy. The weekly data accuracy of BNI, BCA and Mandiri are 95.4247%, 97.0631%, and 96.5706%. Monthly accuracy data a bit smallest than weekly accuracy. The monthly data accuracy of BNI, BCA and Mandiri are 91.6259%, 95.9425%, and 94.1434%. If the investor focuses all of his funds only to buy one stock, then he will have a portfolio profit of 3 times more than before. If the profit of BNI stocks is 19.19%, then in terms of the investor portfolio will have a profit of 19.19% x 3 = 57.57%. Compare with the profit level of the 3 banks which if we add up, the value will be as follows: 19.19+17.68+15.73 = 52.6%. So there are additional benefits from a portfolio of 57.57% - 52.6% = 4.97%. recommendation During experiment, there are no anomaly data. Because there are no data about financial crisis as in year 1997 and 2008 so the recommended is include data in the year 1997 and 2008. So it is recommended to increase the time series including data in the year 1997 and 2008. References Hari Purnomo Susanto, “Pemodelan Fuzzy untuk Data Time Series menggunakan metode Tabel Look up dengan transformasi logaritma dan diferensi dan aplikasinya pada data indeks harga saham gabungan (IHSG)”, Jurnal Penelitian Pendidikan, Vol 5, Nomor 1, Juni 2013 https://finance.yahoo.com/quote/BBNI.JK/history?p=BBNI.JK https://finance.yahoo.com/quote/BBRI.JK/history?p=BBRI.JK https://finance.yahoo.com/quote/BMRI.JK/history?p=BMRI.JK Ganesh Bonde, Rasheed Khaled, “Stock price prediction using genetic algorithms and evolution strategies”, http://worldcomp-proceedings.com/proc/p2012/GEM4716.pdf, October 13, 2015 Jay Desai,Arti Trivedi, Nisarg A Joshi, “Forecasting of Stock Market Indices Using Artificial Neural Network”, Shri Chimanbhai Patel Institutes, Ahmedabad; 2013 Andy Porman Tambunan, “Menilai Harga Wajar Saham (Stock Valuation)”. 2010. Jakarta: Gramedia. Pang-Ning Tan, Michael Steinbach, Vipin Kumar-Introduction to Data Mining-Pearson (2005) Heaton Jeff, “Introduction to Neural Networks for C#”, 2nd Edition-Heaton Research, Inc. (2008) page 153 Fausett Laurene, “Fundamentals of Neural Networks – Architectures, Algorithms, and Applications”. 1994. Charlie Lie, “Kalau Ada Uang Belilah $aham”. 2010. Bandung: TriEks Media.Inc. page 91 Drs. Jong Jek Siang, M.Sc., “Jaringan Syaraf Tiruan & Pemrogramannya menggunakan MATLAB”. 2009. Jakarta: Andi. Bayu Ariestya Ramadhan, “Analisis Perbandingan Metode Arima Dan Metode Garch Untuk Memprediksi Harga Saham (Studi kasus pada perusahaan Telekomunikasi yang terdaftar di Bursa Efek Indonesia Periode Mei 2012 – April 2013”, Prodi S1 Manajemen Bisnis Telekomunikasi dan Informatika, Fakultas Ekonomi dan Bisnis, Universitas Telkom, Juni 2013 “Istilah Pasar Modal”, http://wasbunsiahaan.blogspot.com/2011/11/istilahkamus-pasar-modal.html

1 comment:

HouwLiong said...

Publised in
http://www.e-jmii.org/#