01578783 stock market forecasting using hidden markov model

31
Page 1 Page 1 Stock Market Forecasting Using Hidden Markov Model: Pasar Saham Peramalan Menggunakan Model Markov Tersembunyi: A New Approach Sebuah Pendekatan Baru Md. Rafiul Hassan and Baikunth Nath Rafiul Md Hassan dan Nath Baikunth Computer Science and Software Engineering Ilmu Komputer dan Rekayasa Perangkat Lunak The University of Melbourne, Carlton 3010, Australia. The University of Melbourne, Carlton 3010, Australia. {mrhassan , bnath}@cs.mu.oz.au {Mrhassan, bnath} @ cs.mu.oz.au Abstract Abstrak This paper presents Hidden Markov Models Tulisan ini menyajikan Hidden Markov Model (HMM) approach for forecasting stock price for (HMM) pendekatan peramalan harga saham interrelated markets. saling pasar. We apply HMM to Kita menerapkan HMM untuk forecast some of the airlines stock. ramalan beberapa saham maskapai penerbangan. HMMs have HMMs memiliki been extensively used for pattern recognition telah banyak digunakan untuk pengenalan pola and classification problems because of its dan klasifikasi masalah karena yang proven suitability for modelling dynamic terbukti kesesuaian untuk pemodelan dinamis systems. sistem. However, using HMM for predicting Namun, dengan menggunakan HMM untuk memprediksi future events is not straightforward. peristiwa masa depan tidak mudah. Here we Di sini kita use only one HMM that is trained on the past hanya menggunakan satu HMM yang dilatih di masa lalu dataset of the chosen airlines. Dataset dari perusahaan penerbangan yang dipilih. The trained HMM The HMM dilatih is used to search for the variable of interest digunakan untuk mencari variabel bunga behavioural data pattern from the past dataset. perilaku pola data dari dataset lalu. By interpolating the neighbouring values of Dengan interpolasi nilai tetangga these datasets forecasts are prepared. ramalan dataset disusun. The The results obtained using HMM are encouraging hasil yang diperoleh menggunakan HMM yang mendorong

Upload: fikarxyzone

Post on 25-Jun-2015

224 views

Category:

Documents


7 download

TRANSCRIPT

Page 1: 01578783 Stock Market Forecasting Using Hidden Markov Model

Page 1 Page 1Stock Market Forecasting Using Hidden Markov Model: Pasar Saham Peramalan Menggunakan Model Markov Tersembunyi: A New Approach Sebuah Pendekatan Baru Md. Rafiul Hassan and Baikunth Nath Rafiul Md Hassan dan Nath Baikunth Computer Science and Software Engineering Ilmu Komputer dan Rekayasa Perangkat Lunak The University of Melbourne, Carlton 3010, Australia. The University of Melbourne, Carlton 3010, Australia. {mrhassan , bnath}@cs.mu.oz.au {Mrhassan, bnath} @ cs.mu.oz.au Abstract Abstrak This paper presents Hidden Markov Models Tulisan ini menyajikan Hidden Markov Model (HMM) approach for forecasting stock price for (HMM) pendekatan peramalan harga saham interrelated markets. saling pasar. We apply HMM to Kita menerapkan HMM untuk forecast some of the airlines stock. ramalan beberapa saham maskapai penerbangan. HMMs have HMMs memiliki been extensively used for pattern recognition telah banyak digunakan untuk pengenalan pola and classification problems because of its dan klasifikasi masalah karena yang proven suitability for modelling dynamic terbukti kesesuaian untuk pemodelan dinamis systems. sistem. However, using HMM for predicting Namun, dengan menggunakan HMM untuk memprediksi future events is not straightforward. peristiwa masa depan tidak mudah. Here we Di sini kita use only one HMM that is trained on the past hanya menggunakan satu HMM yang dilatih di masa lalu dataset of the chosen airlines. Dataset dari perusahaan penerbangan yang dipilih. The trained HMM The HMM dilatih is used to search for the variable of interest digunakan untuk mencari variabel bunga behavioural data pattern from the past dataset. perilaku pola data dari dataset lalu. By interpolating the neighbouring values of Dengan interpolasi nilai tetangga these datasets forecasts are prepared. ramalan dataset disusun. The The results obtained using HMM are encouraging hasil yang diperoleh menggunakan HMM yang mendorong and HMM offers a new paradigm for stock dan HMM menawarkan paradigma baru untuk saham market forecasting, an area that has been of peramalan pasar, daerah yang telah dari much research interest lately. banyak penelitian bunga belakangan ini. Key Words: HMM, stock market forecasting, Kata Kunci: HMM, saham peramalan pasar, financial time series, feature selection waktu keuangan seri, pemilihan fitur 1. 1. Introduction Pengantar Forecasting stock price or financial markets has been Peramalan harga saham atau pasar keuangan telah one of the biggest challenges to the AI community. salah satu tantangan terbesar bagi komunitas AI. The The objective of forecasting research has been largely beyond Tujuan dari penelitian peramalan sebagian besar telah melampaui the capability of traditional AI research which has mainly kemampuan penelitian AI tradisional yang terutama

Page 2: 01578783 Stock Market Forecasting Using Hidden Markov Model

focused on developing intelligent systems that are difokuskan pada pengembangan sistem cerdas yang supposed to emulate human intelligence. seharusnya meniru kecerdasan manusia. By its nature the Dengan sifatnya yang stock market is mostly complex (non-linear) and volatile. pasar saham sebagian besar kompleks (non-linear) dan volatile. The rate of price fluctuations in such series depends on Tingkat fluktuasi harga dalam seri tersebut tergantung pada many factors, namely equity, interest rate, securities, banyak faktor, yaitu ekuitas, suku bunga, sekuritas, options, warrants, merger and ownership of large opsi, waran, merger dan kepemilikan besar financial corporations or companies etc. Human traders keuangan perusahaan atau perusahaan pedagang dll Manusia can not consistently win in such markets. bisa tidak konsisten menang di pasar tersebut. Therefore, Oleh karena itu, developing AI systems for this kind of forecasting mengembangkan sistem AI untuk jenis peramalan requires an iterative process of knowledge discovery and membutuhkan proses berulang-ulang penemuan pengetahuan dan system improvement through data mining, knowledge perbaikan sistem melalui data mining, pengetahuan engineering, theoretical and data-driven modelling, as teknik, teori dan-driven pemodelan data, sebagai well as trial and error experimentation. serta trial and error eksperimen. The stock markets in the recent past have become an pasar saham tersebut pada masa lalu telah menjadi integral part of the global economy. bagian integral dari ekonomi global. Any fluctuation in Setiap fluktuasi this market influences our personal and corporate pasar ini mempengaruhi pribadi dan perusahaan financial lives, and the economic health of a country. keuangan hidup, dan kesehatan ekonomi suatu negara. The The stock market has always been one of the most popular pasar saham selalu menjadi salah satu yang paling populer investments due to its high returns [1]. investasi karena keuntungan yang tinggi [1]. However, there is Namun, ada always some risk to investment in the Stock market due to selalu beberapa risiko investasi di pasar saham karena its unpredictable behaviour. yang tak terduga perilaku. So, an 'intelligent' prediction Jadi, sebuah 'cerdas' prediksi model for stock market forecasting would be highly model untuk peramalan pasar saham akan sangat desirable and would of wider interest. diinginkan dan akan kepentingan yang lebih luas. A large amount of research has been published in Sejumlah besar penelitian telah dipublikasikan di

Page 3: 01578783 Stock Market Forecasting Using Hidden Markov Model

recent times and is continuing to find an optimal (or waktu terakhir dan terus mencari optimal (atau nearly optimal) prediction model for the stock market. hampir optimal) prediksi model untuk pasar saham. Most of the forecasting research has employed the Sebagian besar penelitian peramalan telah memanfaatkan statistical time series analysis techniques like auto- teknik statistik analisis deret waktu seperti auto- regression moving average (ARMA) [2] as well as the regresi rata-rata bergerak (ARMA) [2] serta multiple regression models. regresi berganda model. In recent years, numerous Dalam beberapa tahun terakhir, banyak stock prediction systems based on AI techniques, sistem prediksi saham berdasarkan teknik AI, including artificial neural networks (ANN) [3, 4, 5], fuzzy termasuk jaringan saraf tiruan (JST) [3, 4, 5], fuzzy logic [6], hybridization of ANN and fuzzy system [7, 8, logika [6], hibridisasi dari JST dan sistem fuzzy [7, 8, 9], support vector machines [10] have been proposed. 9], dukungan mesin vektor [10] telah diusulkan. However, most of them have their own constraints. Namun, kebanyakan dari mereka memiliki kendala sendiri. For Untuk instance, ANN is very much problem oriented because of Misalnya, JST sangat masalah yang lebih berorientasi karena its chosen architecture. yang dipilih arsitektur. Some researchers have used fuzzy Beberapa peneliti telah menggunakan fuzzy systems to develop a model to forecast stock market sistem untuk mengembangkan model untuk memperkirakan pasar saham behaviour. perilaku. To build a fuzzy system one requires some Untuk membangun satu sistem fuzzy memerlukan beberapa background expert knowledge. latar belakang pengetahuan yang ahli. In this paper, we make use of the well established Dalam tulisan ini, kita memanfaatkan mapan Hidden Markov Model (HMM) technique to forecast Hidden Markov Model (HMM) teknik untuk meramalkan stock price for some of the airlines. harga saham untuk beberapa maskapai penerbangan. The HMMs have been Para HMMs telah extensively used in the area like speech recognition, DNA ekstensif digunakan di daerah tersebut seperti speech recognition, DNA Proceedings of the 2005 5th International Conference on Intelligent Systems Design and Applications (ISDA'05) Prosiding Konferensi Internasional ke-5 Tahun 2005 tentang Desain Sistem Cerdas dan Aplikasi (ISDA'05) 0-7695-2286-06/05 $20.00 © 2005 0-7695-2286-06/05 $ 20,00 © 2005 IEEE IEEE

Page 2 Page 2sequencing, electrical signal prediction and image sequencing, prediksi sinyal listrik dan gambar

Page 4: 01578783 Stock Market Forecasting Using Hidden Markov Model

processing, etc. In here, HMM is used in a new way to pengolahan, dll Di sini, HMM digunakan dalam cara baru untuk develop forecasts. mengembangkan prakiraan. First we locate pattern(s) from the past Pertama kita menemukan pola (s) dari masa lalu datasets that match with today's stock price behaviour, dataset yang sesuai dengan perilaku harga saham hari ini, then interpolate these two datasets with appropriate kemudian interpolasi kedua dataset dengan tepat neighbouring price elements and forecast tomorrow’s tetangga harga unsur-unsur dan ramalan besok stock price of the variable of interest. harga saham variabel bunga. Details of the Rincian proposed method are provided in Section 3. metode yang diusulkan diberikan dalam Bagian 3. The The remainder of the paper is organised as follows: Section 2 sisa kertas ini disusun sebagai berikut: Bagian 2 provides a brief overview on HMM; Section 4 lists memberikan gambaran singkat tentang HMM; Bagian 4 daftar experimental results obtained using HMM and compares Hasil percobaan yang diperoleh menggunakan HMM dan membandingkan with results obtained using ANN; and finally Section 5 dengan hasil yang diperoleh menggunakan JST, dan akhirnya Bagian 5 concludes the paper. menyimpulkan kertas. 2. 2. HMM as a Predictor HMM sebagai suatu Predictor A Hidden Markov Model (HMM) is a finite state A Hidden Markov Model (HMM) adalah sebuah negara yang terbatas machine which has some fixed number of states. mesin yang memiliki beberapa nomor tetap negara. It Ini provides a probabilistic framework for modelling a time menyediakan kerangka probabilistik untuk pemodelan waktu series of multivariate observations. serangkaian pengamatan multivariat. Hidden Markov Hidden Markov models were introduced in the beginning of the 1970's as model yang diperkenalkan pada awal tahun 1970 sebagai a tool in speech recognition. alat dalam pengenalan suara. This model based on Ini model yang didasarkan pada statistical methods has become increasingly popular in the metode statistik telah menjadi semakin populer di last several years due to its strong mathematical structure beberapa tahun terakhir karena struktur yang kuat matematis and theoretical basis for use in a wide range of dan teori dasar untuk digunakan dalam berbagai applications. aplikasi. In recent years researchers proposed HMM Dalam beberapa tahun terakhir para peneliti diusulkan HMM as a classifier or predictor for speech signal recognition sebagai pengklasifikasi atau prediksi untuk sinyal speech recognition [11, 12, 13], DNA sequence analysis [14], handwritten [11, 12, 13], analisis urutan DNA [14], tulisan tangan

Page 5: 01578783 Stock Market Forecasting Using Hidden Markov Model

characters recognition [15], natural language domains etc. karakter pengakuan [15], domain bahasa alam dll It is clear that HMM is a very powerful tool for various Jelas bahwa HMM merupakan alat yang sangat ampuh untuk berbagai applications. aplikasi. The advantage of HMM can be summarized Keuntungan dari HMM dapat diringkas as: sebagai: • • HMM has strong statistical foundation HMM memiliki landasan statistik yang kuat • • It is able to handle new data robustly Hal ini dapat menangani data baru bersemangat • • Computationally efficient to develop and evaluate Komputasi yang efisien untuk mengembangkan dan mengevaluasi (due to the existence of established training (Karena adanya pelatihan yang dilaksanakan algorithms). algoritma). • • It is able to predict similar patterns efficiently [16] Hal ini dapat memprediksi pola serupa efisien [16] Rabiner [17] tutorial explains the basics of HMM and Rabiner [17] tutorial menjelaskan dasar-dasar HMM dan how it can be used for signal prediction. bagaimana dapat digunakan untuk prediksi sinyal. The next session Sesi berikutnya describes the HMM in brief. HMM menjelaskan secara singkat. 2.1. 2.1. The Hidden Markov Model The Model Markov Tersembunyi Hidden Markov Model is characterized by the Model Markov tersembunyi dicirikan oleh following berikut 1) number of states in the model 1) sejumlah negara dalam model 2) number of observation symbols 2) jumlah simbol observasi 3) state transition probabilities 3) keadaan transisi probabilitas 4) observation emission probability distribution that 4) observasi emisi probabilitas distribusi yang characterizes each state mencirikan negara masing-masing 5) initial state distribution 5) distribusi keadaan awal For the rest of this paper the following notations will be Selama sisa kertas ini notasi berikut ini akan used regarding HMM digunakan tentang HMM N = number of states in the model N = sejumlah negara dalam model M = number of distinct observation symbols per state M = jumlah observasi simbol negara yang berbeda per (observation symbols correspond to the physical output (Simbol observasi sesuai dengan output fisik of the system being modelled) dari sistem yang dimodelkan) T = length of observation sequence T = panjang urutan observasi O = observation sequence, ie, O O = observasi urutan, yaitu, O 1 1

Page 6: 01578783 Stock Market Forecasting Using Hidden Markov Model

, O , O 2 2 , O , O 3 3 ,………O , ... ... ... O T T Q = state sequence q Q q negara urutan = 1 1 , q , Q 2 2 , ……., q , ... ... Q., T T in the Markov di Markov yang model model A = {a A = {a ij ij } transition matrix, where a } Matriks transisi, dimana ij ij represents the mewakili transition probability from state i to state j transisi probabilitas dari state i ke negara j B = {b B = {b j j (O (O t t )} observation emission matrix, where b )} Emisi observasi matriks, dimana b j j (O (O t t ) ) represent the probability of observing O merupakan probabilitas mengamati O t t at state j di negara j π = {π π = {π i i } the prior probability, where π } Probabilitas sebelumnya, dimana π i i represent the mewakili probability of being in state i at the beginning of the probabilitas berada di state i pada awal experiment, ie, at time t = 1 percobaan, yaitu, pada waktu t = 1 λ = (A, B, π) the overall HMM model. λ = (A, B, π) model HMM secara keseluruhan. As mentioned above the HMM is characterized by N, M, Seperti yang disebutkan di atas HMM ditandai dengan N, M, A, B and π. A, B, dan π. The a A ij ij , b , B i i

Page 7: 01578783 Stock Market Forecasting Using Hidden Markov Model

(O (O t t ), and π ), Dan π i i have the properties memiliki sifat ∑ Σ ∑ Σ ∑ Σ = = = = = = i i i i t t t t i i j j ij ij O O b b a sebuah 1 1 ,1 , 1 ) ) ( ( ,1 , 1 π π and dan 0 0 ,) ,) ( ( , , ≥ ≥ i i t t i i ij ij O O b b a sebuah π π for all i, j, t. untuk semua i, j, t. To work with HMM, the following three fundamental Untuk bekerja dengan HMM, berikut tiga fundamental questions should be resolved pertanyaan-pertanyaan harus diselesaikan

Page 8: 01578783 Stock Market Forecasting Using Hidden Markov Model

1. 1. Given the model λ= (A, B, π) how do we compute Mengingat model λ = (A, B, π) bagaimana kita menghitung P(O| λ), the probability of occurrence of the P (O | λ), probabilitas terjadinya observation sequence O = O urutan observasi O = O 1 1 ,O , O 2 2 , ….. , ... .. , O , O T T . . 2. 2. Given the observation sequence O and a model λ, Mengingat urutan observasi O dan λ model, how do we choose a state sequence q bagaimana kita memilih urutan negara q 1 1 , q , Q 2 2 , ….. , ... .. , q , Q T T that best explains the observations. yang paling menjelaskan pengamatan. 3. 3. Given the observation sequence O and a space of Mengingat urutan observasi O dan sebuah ruang models found by varying the model parameters A, Model ditemukan oleh memvariasikan parameter model A, B and π, how do we find the model that best B dan π, bagaimana kita menemukan model yang terbaik explains the observed data. menjelaskan data yang diamati. There are established algorithms to solve the above Ada dibentuk algoritma untuk memecahkan di atas questions. pertanyaan. In our task we have used the forward-backward Dalam tugas kami, kami telah menggunakan maju-mundur algorithm to compute the P(O| λ), Viterbi algorithm to algoritma untuk menghitung P (O | λ), Viterbi algoritma untuk resolve problem 2, and Baum-Welch algorithm to train menyelesaikan masalah 2, dan algoritma Baum-Welch untuk melatih the HMM. HMM tersebut. The details of these algorithms are given in the Rincian algoritma ini diberikan dalam tutorial by Rabiner [17]. tutorial oleh Rabiner [17]. 3. 3. Using HMM for Stock market forecasting Menggunakan HMM untuk peramalan pasar Saham In this section we develop an HMM based tool for Pada bagian ini kami mengembangkan alat berbasis HMM untuk time series forecasting, for instance for the stock market peramalan time series, misalnya untuk pasar saham Proceedings of the 2005 5th International Conference on Intelligent Systems Design and Applications (ISDA'05) Prosiding Konferensi Internasional ke-5 Tahun 2005 tentang Desain Sistem Cerdas dan Aplikasi (ISDA'05)

Page 9: 01578783 Stock Market Forecasting Using Hidden Markov Model

0-7695-2286-06/05 $20.00 © 2005 0-7695-2286-06/05 $ 20,00 © 2005 IEEE IEEE

Page 3 Page 3forecasting. peramalan. While implementing the HMM, the choice of Sementara melaksanakan HMM, pilihan the model, choice of the number of states and observation model, pilihan jumlah negara bagian dan observasi symbol (continuous or discrete or multi-mixture) become simbol (kontinu atau diskrit atau multi-campuran) menjadi a tedious task. tugas yang membosankan. For instance we have used left-right HMM Sebagai contoh kita telah menggunakan HMM kiri kanan with 4 states. dengan 4 negara. In our problem, for simplicity, we consider 4 input Dalam masalah kami, untuk kemudahan, kami anggap 4 input features for a stock – that is the opening price, closing fitur untuk saham - yang adalah harga pembukaan, penutupan price, highest price, and the lowest price. harga tertinggi harga,, dan harga terendah. The next day’s Hari berikutnya closing price is taken as the target price associated with harga penutupan diambil sebagai harga target yang terkait dengan the four input features. empat masukan fitur. Our observations here being Pengamatan kami di sini adalah continuous rather than discrete, we choose empirically as terus menerus daripada diskrit, kami memilih empiris sebagai many as 3 mixtures for each state for the model density. sebanyak 3 campuran untuk masing-masing negara untuk kepadatan model. For the prior probability Untuk probabilitas sebelumnya i i π π , a random number was , Nomor acak chosen and normalized so that dipilih dan normalisasi sehingga ∑ Σ = = = = N N i i i i 1 1 1 1 π π . . The dataset Dataset being continuos, the probability of emitting symbols from yang berkesinambungan, probabilitas memancarkan simbol dari a state can not be calculated. suatu negara tidak dapat dihitung. For this reason a three- Untuk alasan ini tiga

Page 10: 01578783 Stock Market Forecasting Using Hidden Markov Model

dimensional Gaussian distribution was initially chosen as distribusi Gaussian dimensi pada awalnya dipilih sebagai the observation probability density function. probabilitas fungsi kepadatan pengamatan. Thus, we Jadi, kita have memiliki [ [ ] ] ∑ Σ ℵ ℵ = = jm jm jm jm jm jm j j U U O O c c O O b b , , , , ) ) ( ( µ μ N N j ≤ j ≤ ≤ ≤ 1 1 where mana = = O O vector of observations being modelled vektor pengamatan yang dimodelkan = = jm jm c c mixture coeff. coeff campuran. for the m-th mixture in state j , untuk campuran ke-m di negara j, where mana ∑ Σ = = = = M M m m jm jm c c 1 1 1 1

Page 11: 01578783 Stock Market Forecasting Using Hidden Markov Model

= = jm jm µ μ mean vector for the m-th mixture component in rerata vektor untuk campuran ke komponen-m state j negara j = = jm jm U U Covariance matrix for the m-th mixture Kovarian campuran matriks untuk m-th component in state j komponen di negara j = = ℵ ℵ Gaussian density. Densitas Gaussian. In the experiment, our objective was to predict the Dalam percobaan, tujuan kami adalah untuk memprediksi next day's closing price for a specific stock market share hari berikutnya harga penutupan untuk pangsa pasar saham tertentu using aforementioned HMM model. HMM menggunakan model tersebut. For training the Untuk pelatihan model, past one and a half years (approximately) daily model, satu lewat setengah tahun (sekitar) setiap hari data were used and recent last three month's data were Data yang digunakan dan terakhir tiga bulan terakhir adalah data used to test the efficiency of the model. digunakan untuk menguji efisiensi model. The input and Masukan dan output data features were as follows: fitur data output adalah sebagai berikut: Input: opening, high, low, and closing price Input: pembukaan, tinggi, rendah, dan harga penutupan Output: next day's closing price Output: harganya penutupan hari berikutnya The idea behind our new approach in using HMM is Ide dibalik pendekatan baru kami dalam menggunakan HMM that of using the training dataset for estimating the yang menggunakan dataset pelatihan untuk memperkirakan parameter set (A, B, parameter set (A, B, π π ) of the HMM. ) Dari HMM tersebut. For a specific stock Untuk saham tertentu at the market close we know day's price values of the four pada penutupan pasar hari itu kita tahu harga nilai dari empat variables (open, high, low, close), and using this variabel (terbuka, tinggi, rendah, tutup), dan menggunakan information our objective is to predict next day's closing informasi yang objektif kami adalah untuk memprediksi's hari penutupan berikutnya price. harga. A forecast of any of the four variables for the next Sebuah ramalan dari salah satu dari empat variabel untuk selanjutnya day indeed will be of tremendous value to the traders and hari memang akan menjadi nilai yang luar biasa untuk para pedagang dan

Page 12: 01578783 Stock Market Forecasting Using Hidden Markov Model

investors. investor. Using the trained HMM, likelihood value for Menggunakan, kemungkinan nilai HMM dilatih untuk current day's dataset is calculated. Teman-hari Dataset berjalan dihitung. For example, say the Misalnya, mengatakan likelihood value for the day is ' kemungkinan nilai untuk hari itu adalah ' ¶ ¶ , then from the past , Kemudian dari masa lalu dataset using the HMM we locate those instances that dataset menggunakan HMM kita menemukan contoh-contoh yang would produce the same ' akan menghasilkan hal yang sama ' ¶ ¶ or nearest to the ' atau terdekat dengan ' ¶ ¶ likelihood kemungkinan value. nilai. That is we locate the past day(s) where the stock Itulah kita cari hari lalu (s) di mana saham behaviour is similar to that of the current day. perilaku yang mirip dengan hari saat ini. Assuming Dengan asumsi that the next day's stock price should follow about the hari berikutnya harga saham itu harus mengikuti tentang same past data pattern, from the located past day(s) we sama pola data masa lalu, dari hari terakhir terletak (s) kita simply calculate the difference of that day's closing price hanya menghitung perbedaan itu harga penutupan hari itu and next to that day's closing price. dan di samping itu harga penutupan hari itu. Thus the next day’s Jadi hari berikutnya stock closing price forecast is established by adding the proyeksi harga penutupan saham dibentuk dengan menambahkan above difference to the current day's closing price. atas perbedaan untuk hari penutupan harganya saat ini. 4. 4. Experimentation: Training and Testing Percobaan: Pelatihan dan Pengujian In order to train the HMM, we divided the dataset Dalam rangka untuk melatih HMM, kami membagi dataset into two sets, one training set and one test (recall) set. dalam dua set, satu set pelatihan dan satu tes (ingat) ditetapkan. For Untuk example, we trained an HMM using the daily stock data Misalnya, kita dilatih sebuah HMM menggunakan data saham harian of Southwest Airlines for the period 18 December 2002 to Southwest Airlines untuk periode 18 Desember 2002 29 September 2004 to predict the closing price on 30 29 September 2004 untuk memprediksi harga penutupan pada 30 September 2004. September 2004. The trained HMM produced likelihood The HMM terlatih yang dihasilkan kemungkinan value of -9.4594 for the stock price on 29 September nilai -9,4594 untuk harga saham pada tanggal 29 September

Page 13: 01578783 Stock Market Forecasting Using Hidden Markov Model

2004. 2004. Using this trained HMM and the past data, we Menggunakan HMM terlatih dan data masa lalu, kita located a (closer) likelihood value -9.4544 on 01 July terletak dekat) kemungkinan nilai (-9,4544 pada 1 Juli 2003. 2003. Figure 1 shows the similarities between these two Gambar 1 menunjukkan kesamaan antara kedua datasets (stock prices on 30 September 2004 and 01 July dataset (harga saham pada tanggal 30 September 2004 dan 1 Juli 2003). 2003). It seems quite logical that 29 September 2004 Sepertinya cukup logis bahwa 29 September 2004 stock behaviour should follow the behaviour that of 01 perilaku saham harus mengikuti perilaku bahwa dari 01 July 2003. Juli 2003. 13 13 14 14 15 15 16 16 17 17 18 18 Open Buka High Tinggi Low Rendah Close Dekat Variables Variabel Pr Pr ic ic e e Matched Data (Past) Pencocokan Data (lalu) Known Data (Today) Dikenal Data (Today) Figure 1. Gambar 1. The current day's stock price behaviour Hari berjalan harga saham perilaku matched with past day's price data cocok dengan harga's data hari lalu 11 11 12 12 13 13 14 14 15 15 16 16 17 17 1 1 4 7 10 13 16 19 22 25 28 31 34 37 40 43 46 49 52 55 58 61 64 67 70 73 76 79 4 7 10 13 16 19 22 25 28 31 34 37 40 43 46 49 52 55 58 61 64 67 70 73 76 79 Day Hari Pr Pr i i c c e e

Page 14: 01578783 Stock Market Forecasting Using Hidden Markov Model

Actual Price Harga aktual Predicted Price Prediksi Harga Figure 2. Gambar 2. Actual Vs. Aktual Vs. Predicted stock price Prediksi harga saham Proceedings of the 2005 5th International Conference on Intelligent Systems Design and Applications (ISDA'05) Prosiding Konferensi Internasional ke-5 Tahun 2005 tentang Desain Sistem Cerdas dan Aplikasi (ISDA'05) 0-7695-2286-06/05 $20.00 © 2005 0-7695-2286-06/05 $ 20,00 © 2005 IEEE IEEE

Page 4 Page 4Table 1. Tabel 1. Dataset along with the matched past dataset Dataset bersama dengan dataset terakhir cocok 12 12 12.5 12.5 13 13 13.5 13.5 14 14 14.5 14.5 15 15 15.5 15.5 16 16 16.5 16.5 17 17 12 12 13 13 14 14 15 15 16 16 17 17 Actual Price Harga aktual P P r r ed ed i i c c t t e e d d P P r r i i ce ce Figure 3. Gambar 3. The correlation between predicted and Korelasi antara prediksi dan actual closing stock price penutupan harga saham aktual We, therefore, calculated the difference between the Kami, Karena itu, menghitung selisih antara

Page 15: 01578783 Stock Market Forecasting Using Hidden Markov Model

closing prices on 01 July 2003 and the next day 02 July harga penutupan pada 01 Juli 2003 dan pada hari berikutnya 2 Juli 2003. 2003. That is $17.36-$17.13 =$0.23.Then this difference Itu adalah $ 17,36-$ 17,13 = $ 0.23.Then perbedaan ini is added to the closing price on 29 September 2004 to ditambahkan ke harga penutupan pada tanggal 29 September 2004 forecast closing price for 30 September 2004. perkiraan harga penutupan 30 September 2004. Table 1 Tabel 1 shows the predicted and the actual prices of stock on 30 menunjukkan diprediksi dan harga sebenarnya saham pada tanggal 30 September 2004. September 2004. Figure 2 shows the prediction accuracy Gambar 2 menunjukkan akurasi prediksi of the model and Figure 3 shows the correlation among dari Gambar 3 menunjukkan model dan hubungan antara the predicted values and the actual values of the stock. memprediksi nilai-nilai dan nilai-nilai aktual saham. For the aforementioned experiment the mean Untuk percobaan tersebut rata-rata absolute percentage error (MAPE) = 2.01, and R kesalahan persentase absolut (MAPE) = 2,01, dan R 2 2 = = 0.87498. 0,87498. 4. 4. 1. 1. Stock price forecasts for some airlines Prakiraan harga saham untuk beberapa maskapai penerbangan We have trained four HMM for four different Kami telah melatih empat HMM untuk empat yang berbeda Airlines stock price. Airlines harga saham. Using the same training dataset we Menggunakan Dataset pelatihan yang sama kita trained four different (same architecture) ANN. dilatih empat berbeda (arsitektur yang sama) ANN. Then we Kemudian kita predicted the next few day's closing price of these three diprediksi beberapa hari penutupan Teman harga berikutnya dari ketiga stocks using the HMMs in aforementioned method and saham dengan menggunakan HMMs dalam metode tersebut dan we predicted the same day's closing price using ANN. kami memprediksikan hari penutupan harganya sama dengan jaringan syaraf tiruan. The Table 2 shows the information of the training Tabel 2 menunjukkan informasi pelatihan dataset and the test dataset while the Table 3 shows the dataset dan Dataset uji sedangkan Tabel 3 menunjukkan prediction accuracy of these two models. akurasi prediksi dari kedua model. Table 2. Tabel 2. Information on training and test datasets Informasi tentang pelatihan dan uji dataset Training Data Pelatihan Data Test Data Data Uji Stock Saham Name Nama

Page 16: 01578783 Stock Market Forecasting Using Hidden Markov Model

From Dari To Untuk From Dari To Untuk British Inggris Airlines Airlines 17/09/2002 17/09/2002 10/09/2004 10/09/2004 11/09/2004 11/09/2004 20/01/2005 20/01/2005 Delta Delta Airlines Airlines 27/12/2002 27/12/2002 31/08/2004 31/08/2004 01/09/2004 01/09/2004 17/11/2004 17/11/2004 Southwest Barat daya Airlines Airlines 18/12/2002 18/12/2002 23/07/2004 23/07/2004 24/07/2004 24/07/2004 17/11/2004 17/11/2004 Ryanair Ryanair Holdings Saham Ltd. Ltd 06/05/2003 06/05/2003 06/12/2004 06/12/2004 07/12/2004 07/12/2004 17/03/2005 17/03/2005 Table 3. Tabel 3. Prediction accuracy of ANN and the Prediksi keakuratan JST dan proposed method metode yang diusulkan ANN JST (MAPE) (MAPE) Proposed method Usulan metode (MAPE) (MAPE) British Inggris Airlines Airlines 2.283 2.283 2.629 2.629 Delta Airlines Delta Airlines 9.147 9.147 6.850 6.850 Southwest Barat daya Airlines Airlines 1.673 1.673 2.011 2.011

Page 17: 01578783 Stock Market Forecasting Using Hidden Markov Model

Ryanair Ryanair Holdings Ltd. Holdings Ltd 1.492 1.492 1.928 1.928 5. 5. Conclusion Kesimpulan ANN is well researched and established method JST baik diteliti dan didirikan metode that has been successfully used to predict time series yang telah berhasil digunakan untuk memprediksi deret waktu behaviour from past datasets. perilaku dari dataset lalu. In this paper, we proposed Dalam tulisan ini, kami mengusulkan the use of HMM, a new approach, to predict unknown penggunaan HMM, pendekatan baru, untuk memprediksi diketahui value in a time series (stock market). nilai dalam suatu kurun waktu (pasar saham). It is clear from Hal ini jelas dari Table 3 that the mean absolute percentage errors Tabel 3 bahwa rata-rata persentase kesalahan absolut (MAPE) values of the two methods are quite similar. (MAPE) nilai dari dua metode tersebut sangat mirip. Whilst, the primary weakness with ANNs is the inability Sementara, kelemahan utama dengan Anns adalah ketidakmampuan to properly explain the models. untuk benar menjelaskan model. According to Repley Menurut Repley “the design and learning for feed-forward networks are "Desain dan belajar untuk maju jaringan pakan Opening Pembukaan price harga High Tinggi price harga Low Rendah price harga Closing Penutupan price harga Predicted Prediksi closing price harga penutupan (30 Sep 2004) (30 Sep 2004) Actual Sebenarnya closing price harga penutupan (30 Sep 2004) (30 Sep 2004) Today's data 29 Hari ini 29 data Sep 2004 Sep 2004 $13.63 $ 13,63 $13.73 $ 13,73 $13.49 $ 13,49 $13.62 $ 13,62 Matched data Pencocokan data pattern using Pola menggunakan

Page 18: 01578783 Stock Market Forecasting Using Hidden Markov Model

HMM HMM 01 Jul 2003 1 Juli 2003 $17.1 $ 17,1 $17.2 $ 17,2 $16.83 $ 16,83 $17.13 $ 17,13 Next day's data Hari berikutnya's data 02 Jul 2003 2 Juli 2003 $17.36 $ 17,36 $13.85 $ 13,85 $13.85 $ 13,85 Proceedings of the 2005 5th International Conference on Intelligent Systems Design and Applications (ISDA'05) Prosiding Konferensi Internasional ke-5 Tahun 2005 tentang Desain Sistem Cerdas dan Aplikasi (ISDA'05) 0-7695-2286-06/05 $20.00 © 2005 0-7695-2286-06/05 $ 20,00 © 2005 IEEE IEEE

Page 5 Page 5hard”. keras ". Judd [18] and Blum and Rivest [19] showed this Judd [18] dan Blum dan Rivest [19] menunjukkan ini problem to be NP- complete. masalah yang harus NP-lengkap. The proposed method Metode yang diusulkan using HMM to forecast stock price is explainable and menggunakan HMM untuk meramalkan harga saham dapat dijelaskan dan has solid statistical foundation. memiliki landasan statistik yang kuat. The results show Hasil penelitian menunjukkan potential of using HMM for time series prediction. potensi menggunakan HMM untuk seri prediksi waktu. In Dalam our future work we plan to develop hybrid systems pekerjaan di masa depan, kami berencana untuk mengembangkan sistem hibrida using AI paradigms with HMM to further improve AI menggunakan paradigma dengan HMM untuk lebih meningkatkan accuracy and efficiency of our forecasts. akurasi dan efisiensi dari perkiraan kami. 6. 6. References Referensi [1] Kuo RJ, Lee LC and Lee CF (1996), Integration of [1] Kuo RJ, CF LC dan Lee Lee (1996), Integrasi Artificial NN and Fuzzy Delphi for Stock market Buatan NN dan Fuzzy Delphi Saham pasar forecasting, IEEE International Conference on Systems, peramalan, IEEE Konferensi Internasional mengenai Sistem, Man, and Cybernetics, Vol. Man, dan Cybernetics, Vol. 2, pp. 1073-1078. 2, hal 1073-1078. [2] Kimoto T, Asakawa K, Yoda M and Takeoka M (1990), [2] Kimoto T, Asakawa K, M Yoda dan M Takeoka (1990), Stock market prediction system with modular neural Pasar saham prediksi dengan sistem saraf modular networks, Proc. jaringan, Proc. International Joint Conference on Neural Bersama Internasional Konferensi Syaraf

Page 19: 01578783 Stock Market Forecasting Using Hidden Markov Model

Networks, San Diego, Vol. Jaringan, San Diego, Vol. 1, pp. 1-6. 1, hal 1-6. [3] White H (1998), Economic Prediction Using Neural [3] H White (1998), Prediksi Ekonomi Menggunakan Syaraf Networks: The Case of IBM Daily Stock Returns, Jaringan: Kasus IBM Pengembalian Saham harian, Proceedings of the Second Annual IEEE Conference on Prosiding IEEE Konferensi Tahunan Kedua pada Neural Networks, Vol. Neural Networks, Vol. 2, pp. 451-458. 2, hal 451-458. [4] Chiang WC, Urban TL and Baldridge GW (1996), A [4] Chiang WC, TL Urban dan GW Baldridge (1996), A Neural Network Approach to Mutual Fund Net Asset Neural Network Pendekatan Aktiva Bersih Reksa Dana Value Forecasting. Nilai Peramalan. Omega, Vol. Omega, Vol. 24 (2), pp. 205-215. 24 (2), pp 205-215. [5] Kim SH and Chun SH (1998), Graded forecasting using [5] Kim SH dan Chun SH (1998), peramalan Graded menggunakan an array of bipolar predictions: application of sebuah array dari prediksi bipolar: aplikasi probabilistic neural networks to a stock market index. jaringan syaraf probabilistik ke indeks pasar saham. International Journal of Forecasting, Vol. International Journal of Forecasting, Vol. 14, pp. 323- 14, hal 323 - 337. 337. [6] Romahi Y and Shen Q (2000), Dynamic Financial [6] Y Romahi dan Q Shen (2000), Dinamis Keuangan Forecasting Peramalan with dengan Automatically Otomatis Induced Induced Fuzzy Kabur Associations, Proceedings of the 9 Asosiasi, Proceedings of the 9 th th international internasional conference on Fuzzy systems, pp. 493-498. konferensi pada sistem Fuzzy, hal 493-498. [7] Thammano A (1999), Neuro-fuzzy Model for Stock [7] Thammano A (1999), Neuro-fuzzy Model Saham Market Prediction, Proceedings of the Artificial Neural Prediksi pasar, Proceedings of the Syaraf Tiruan Networks in Engineering Conference, ASME Press, New Jaringan di Konferensi Teknik, ASME Press, New York, pp. 587-591. York, hal 587-591. [8] Abraham A, Nath B and Mahanti PK (2001), Hybrid [8] Abraham A Nath B, dan Mahanti PK (2001), Hybrid Intelligent Systems for Stock Market Analysis, Sistem Cerdas untuk Analisis Pasar Saham, Proceedings of the International Conference on Prosiding Konferensi Internasional Computational Science. Komputasi Sains. Springer, pp. 337-345. Springer, hal 337-345.

Page 20: 01578783 Stock Market Forecasting Using Hidden Markov Model

[9] Raposo R De CT and Cruz AJ De O (2004), Stock 9] Raposo [R De CT dan Cruz AJ De O (2004), Bursa Market prediction based on fundamentalist analysis with Pasar prediksi berdasarkan analisis fundamentalis dengan Fuzzy-Neural Networks. Fuzzy-Neural Networks. http://www.labic.nce.ufrj.br/downloads/3wses_fsfs_2002 http://www.labic.nce.ufrj.br/downloads/3wses_fsfs_2002 .pdf . Pdf [10] Cao L and Tay FEH (2001), Financial Forecasting [10] Cao L dan FEH Tay (2001), Peramalan Keuangan Using Support Vector Machines, Neural Computation Menggunakan Mesin Support Vector, Perhitungan Neural and Application, Vol. dan Aplikasi, Vol. 10, pp. 184-192. 10, hal 184-192. [11] Huang X, Ariki Y, Jack M (1990), Hidden Markov [11] Huang X, Ariki Y, M Jack (1990), Markov Tersembunyi Models for speech recognition. Model untuk pengenalan suara. Edinburgh University Edinburgh University Press. Tekan. [12] Jelinek F, Kaufmann M, Mateo CS (1990), Self- [12] Jelinek F, M Kaufmann, Mateo CS (1990), Self- organized language modelling for speech recognition, in bahasa terorganisir pemodelan untuk pengenalan suara, dalam Readings in Speech Recognition (Eds. Alex Waibel and Bacaan dalam Pengakuan Speech (Eds. Alex Waibel dan Kai-Fu Lee), Morgan Kaufmann, San Mateo, California, Kai-Fu Lee), Morgan Kaufmann, San Mateo, California, pp. 450-506. hal 450-506. [13] Xie H, Anreae P, Zhang M, Warren P (2004), Learning [13] Xie H, P Anreae, Zhang M, P Warren (2004), Belajar Models for English Speech Recognition, Proceedings of Model untuk bahasa Inggris Pengakuan Pidato, Proceedings of the 27 27 th th Conference on Australasian Computer Science, Konferensi Australasian Ilmu Komputer, pp. 323-329. hal 323-329. [14] Liebert MA (2004), Use of runs statistics for pattern [14] Liebert MA (2004), Penggunaan statistik berjalan untuk pola recognition in genomic DNA sequences. pengakuan dalam urutan DNA genom. Journal of Jurnal Computational Biology, Vol. Computational Biology, Vol. 11, pp. 107-124. 11, hal 107-124. [15] Vinciarelli A and Luettin J (2000), Off-line cursive script [15] Vinciarelli A dan Luettin J (2000), Off-line script kursif recognition based on continuous density HMM, pengakuan berdasarkan kepadatan terus menerus HMM, Proceedings of the 7 Prosiding dari 7 th th International Workshop on Lokakarya Internasional

Page 21: 01578783 Stock Market Forecasting Using Hidden Markov Model

Frontiers in Handwriting Recognition, Amsterdam, pp. Perbatasan di Pengakuan Tulisan Tangan, Amsterdam, hal 493-498. 493-498. [16] Li Z, Wu Z, He Y and Fulei C (2005), Hidden Markov [16] Li Z, Wu Z, la Y dan C Fulei (2005), Markov Tersembunyi model-based fault diagnostics method in speed-up and model berbasis diagnosa kesalahan metode dalam kecepatan-up dan speed-down process for rotating machinery. kecepatan-down proses untuk memutar mesin. Mechanical Mekanis Systems and Signal Processing, Vol. Sistem dan Pengolahan Sinyal, Vol. 19(2), pp. 329-339. 19 (2), pp 329-339. [17] Rabiner RL (1989), A Tutorial on Hidden Markov [17] RL Rabiner (1989), A Tutorial on Hidden Markov Models Model and dan Selected Dipilih Applications Aplikasi in di Speech Pidato Recognition, Proceedings of the IEEE, Vol. Pengakuan, Proceedings of the IEEE, Vol. 77(2), pp. 77 (2), pp 257-286. 257-286. [18] Judd JS, (1990), Neural Network design and Complexity [18] Judd JS, (1990), Neural Network desain dan Kompleksitas of Learning. Pembelajaran. MIT Press, USA. MIT Press, USA. [19] Blum AL and Rivest RL, (1992), Training a 3-node [19] Blum AL dan Rivest RL, (1992), Pelatihan 3-node Neural Networks is NP- complete. Neural Networks adalah NP-lengkap. Neural Networks, Neural Networks, Vol. Vol. 5, pp. 117-127. 5, hal 117-127. Proceedings of the 2005 5th International Conference on Intelligent Systems Design and Applications (ISDA'05) Prosiding Konferensi Internasional ke-5 Tahun 2005 tentang Desain Sistem Cerdas dan Aplikasi (ISDA'05) 0-7695-2286-06/05 $20.00 © 2005 0-7695-2286-06/05 $ 20,00 © 2005 IEEE IEEE

Page 22: 01578783 Stock Market Forecasting Using Hidden Markov Model
Page 23: 01578783 Stock Market Forecasting Using Hidden Markov Model
Page 24: 01578783 Stock Market Forecasting Using Hidden Markov Model
Page 25: 01578783 Stock Market Forecasting Using Hidden Markov Model