You are on page 1of 4

The 4th Joint International Conference on Information and Communication Technology, Electronic and Electrical Engineering (JICTEE-2014)

Predict The Stock Exchange of Thailand - Set


Warut Sirijunyapong, Adisorn Leelasantitham and Waranyu Wongseree
Supapogrn Kiattisin Department of Electrical and Computer Engineering
Technology of Information System Management Faculty of Engineering, King Mongkut’s University Of
Faculty of Engineering, Mahidol University Technology North Bangkok Bangsue, Bangkok 10800
Puttamonthon, Nakorn Pathom 73170, Thailand Thailand
vicente_14_lp@hotmail.com, adisorn.lee@mahidol.ac.th, waranyu1979@hotmail.com
tom_kiattisin@hotmail.com

Abstract— This paper proposes an investment in the stock


exchange of Thailand (SET) using ARIMA model and support II. DATA AND PROCESS
vector machine. Today, the investors are interesting to invest the This paper is focused on the stock of Financial
stock market because it provides for higher profits than ones Sector, especially three important banks of Thailand which are
from deposit banking. Although the stock market can provide a
Bangkok Bank Public Company Limited (BBL), Siam
high benefit for investors, it comes with a high risk too. Thus, this
is a reason why we are proposing ARIMA model and Support
Commercial Bank Public Company Limited (SCB), and
vector machine. ARIMA model is one of the most popular Kasikornbank Public Company Limited. All data are
approaches to forecast. Support vector machine is the structure retrieving from eFin Smart Portal (Version 4.6.1) support by
of minimization of risk and supports high dimension data. Both Finansia Syrus Securities Public Company Limited, which
of them can be reduced a risk to investors before their decisions provide records of all stock in Stock Exchange of Thailand.
to invest on stocks. Stock prices are changing every day which the reasons of
prices changing are depend on many factors such as, politics,
Keywords-component; Arima; SVM; Stock market; Stock; SET; economics, GDP, even or bad news and good news about their
Efin;DMI; MACD; RSI; companies.
I. INTRODUCTION
Timestamp SCB.Open SCB.High SCB.Low SCB.Close
In the asset management in the present, earning interests
2/1/2013 183.5 186 183 184.5
from a deposit with commercial banks or financial institutions Table.I Exemplifies SCB Data prices from eFin Smart Portal
are considered as one of options to grow money efficiently.
However, a motivation for the deposit interest is slightly low From Table.I, SCB prices on Jan 2, 2013 are present. Show
since the rates are rather low nowadays. the first price of the day, and the highest prices of the day,
Therefore, an investment in the stock market is an SCB low are the lowest prices of the day, and SCB close are
interesting option. It provides opportunities to enhance higher the most important price of the day because this price are the
profits when compared to deposit banking. Nonetheless, there last price of that day.
are risks on stock investing. The risks can be turning a small
boost from good earnings into a suffering of financial losses.
Consequently, investing tools are used amongst investor
groups so as to determine a stock pricing by educating from
various economic factors. Due to the cycle of the behavior of
stock-market prices, theories of statistics and mathematics are
applying for this research. Hence, technical analysis indicator
tools are created to fit diverse application; such as, MACD
(Moving Average Convergence Divergence), RSI (Relative
Strength Index), Fast and Slow Stochastic, DMI (Direction Fig.1 SCB prices
Movement Index) and etc. Each tool are generate reliable buy From Fig.1, it shows SCB prices from the beginning
and sell signals for traders to analyze stock trends. of the year so as to present when the prices are growing up to
Insofar as there is no any tool that is able to exactly indicate the highest price and when they are going down to the lowest
the future price on a stock, it is vital for investors to study in- price in this year. In this case, we are retrieving closed prices
depth and analyzing the best investment strategies. In doing of stock data from Jan 2, 2013 to Oct 31, 2013 to run on
so, the investors are satisfied the level of investment risks as ARIMA model.
well as gain profits as speculated on stocks.

978-1-4799-3855-1/14/$31.00 ©2014 IEEE


III. ARIMA MODEL ‫ ݕ‬ൌ ߱‫׎‬ሺ‫ݔ‬ሻ+b (3)
Box and Jenkins [13], the ARIMA model has been
Where ‫(׎‬x) is call the feature, which is nonlinear mapped
one of the most popular approaches to forecasting.
from the input space x. The coefficients w and b are estimated
In an ARIMA model, the future value of a variable is
by minimizing.
supposed to be a linear combination of past values and past ଵ ଵ
errors, expressed as follows:- ܴሺ‫ܥ‬ሻ ൌ ‫ ܥ‬σே ‫ ܮ‬ሺ݀ ǡ ‫ ݕ‬ሻ ൅ ȁȁ߱ȁȁଶ (4)
ே ௜ୀଵ ఌ ௜ ௜ ଶ
ȁ݀ െ ‫ݕ‬ȁ െ ߝȁ݀ െ ‫ݕ‬ȁ ൒ ߝ (5)
‫ ܮ‬ሺ݀ǡ ‫ݕ‬ሻ ൌ ቄ

Ͳܱ‫ݎ݄݁ݐ‬
‫ݕ‬௧ ൌ ߠ଴ ൅ ‫׎‬ଵ ‫ݕ‬௧ିଵ ൅ ‫׎‬ଶ ‫ݕ‬௧ିଶ ൅ ‫ ڮ‬൅ ‫׎‬௣ ‫ݕ‬௧ െ ‫ ݌‬൅ ߝ௧ െ ߠଵ ߝ௧ିଵ (1)
െ ߠଶ ߝ௧ିଶ െ ‫ ڮ‬െ ߠ௤ ߝ௧ି௤ Where both C and ߝ are prescribed parameters. The first term
‫ܮ‬ఌ (d, y) is call the ߝ -intensive loss function. The ݀௜ is the
Where ‫ݕ‬௧ is the actual value and ߝ௧ is the random actual stock price in the i period. This function indicates that
error at time t, ‫׎‬௜ and ‫׎‬௝ are the coefficients, p and q are errors below ߝ are not penalized. The term
integers that are often referred to as autoregressive and ଵ
‫ ܥ‬ቀ ቁ σே௜ୀଵ ‫ܮ‬ఌ ሺ݀௜ ǡ ‫ݕ‬௜ ሻ is the empirical error. The second term
moving average polynomials respectively. Basically, this ே

method has three phases: model identification, parameter ȁȁ߱ȁȁଶ , measures the flatness of the function. C evaluates the

estimation and diagnostic checking. For example, the ARIMA trade-off between the empirical risk and the flatness of the
(1,1,0) model can be represented as follows:- model. Introducing the positive slack variables ߴ and ߴ ‫ כ‬,
which represent the distance from the actual values to the
corresponding boundary values of ߝ -tube. Eq. (4) is
‫ݕ‬௧ ൌ ߠ଴ ൅ ‫׎‬ଵ ‫ݕ‬௧ିଵ ൅ ߝ௧ െ ߠଵ ߝ௧ିଵ (2) transformed to the following constrained formation:
Minimize:

‫כ‬
ͳ ் ‫כ‬ ‫כ‬ (6)
ܴሺ߱ǡ ߴǡ ߴ ሻ ൌ ‫ ݓݓ‬൅ ‫ ܥ‬൭෍ሺߴ௜ ൅ ߴ௜ ሻ൱
ʹ
௜ୀଵ
Subjected to:
߱‫׎‬ሺ‫ݔ‬௜ ሻ ൅ ܾ௜ െ ݀௜ ൑ ߝ ൅ ߴ௜ ‫כ‬ (7)
݀௜ െ ߱‫׎‬ሺ‫ݔ‬௜ ሻ െ ܾ௜ ൑ ߝ ൅ ߴ௜ ‫כ‬ (8)
ߴ௜ ǡ ߴ௜ ‫ כ‬൒ Ͳ
i = 1,2,…..,N.
Finally, introducing Lagrangian multipliers and
maximizing the dual function of Eq. (6) changes Eq. (6) to the
following form:
ே ே
(9)
ܴሺ‫ݔ‬௜ െ  ‫ݔ‬௜‫ כ‬ሻ ൌ  ෍ ݀௜ ሺ ‫ݔ‬௜ െ  ‫ݔ‬௜‫ כ‬ሻ െ ߝ ෍ሺ ‫ݔ‬௜ െ  ‫ݔ‬௜‫ כ‬ሻ
௜ୀ௟ ௜ୀ௟

Fig. 2 Predictive ARIMA Model ே ே


ͳ
െ ෍ ෍ሺ‫ݔ‬௜ െ  ‫ݔ‬௜‫ כ‬ሻ
Fig. 2 shows the price prediction of SCB bank. The ʹ
௜ୀଵ ௝ୀଵ
green area is SCB price to be in the future, the red line is SCB
Real price, and the blue line is SCB Forecast price. ‫ݔ‬൫‫ݔ‬௝ െ  ‫ݔ‬௝‫ כ‬൯‫ܭ‬൫‫ݔ‬௜ ǡ ‫ݔ‬௝ ൯

The ARIMA model is basically a data-oriented with the constraints


approach that is adapted from the structure of the data
themselves. However, any significant nonlinear data set limit ே
(10)
the ARIMA. Therefore, the proposing hybrid model uses the ෍ሺ‫ݔ‬௜ െ ‫ݔ‬௜‫ כ‬ሻ ൌ Ͳǡ
SVMs dealing with the nonlinear data pattern. ௜ୀଵ

Ͳ ൑ ‫ݔ‬௜ ൑ ‫ܥ‬ǡ
IV. SUPPORT VECTOR MACHINES
Ͳ ൑ ‫ݔ‬௜‫ כ‬൑ ‫ܥ‬ǡ
The support vector machines are structure of the risk
minimization, [14] SVM will seek to minimize an upper ݅ ൌ ͳǡʹǡ ǥ ǡ ܰǤ
bound of the generalization error instead of the empirical error
as in other neural networks. Additionally, the SVMs models
generate the regress function by applying a set of high ‫ݔ‬௜ and‫ݔ‬௜ ‫ כ‬are call Lagrangian multipliers.They satisfy the
dimensional linear functions. The SVM regression function is equalities,
formulated as follows.
‫ݔ‬௜ ‫ݔ כ‬௜‫ כ‬ൌ Ͳǡ Fig.5 BBL ARIMA Model


(11)
݂ሺ‫ݔ‬ǡ ߙǡ ߙ ‫כ‬ሻ
ൌ ෍ሺ ‫ݔ‬௜ െ ‫ݔ‬௜‫ כ‬ሻ‫ܭ‬ሺ‫ݔ‬ǡ ‫ݔ‬௜ ሻ ൅ ܾ
௜ୀଵ
Here, K(x, x) is call the kernel function. The value of the
kernel is equal to the inner product of two vectors ‫ݔ‬௜ and ‫ݔ‬௝ in
the feature space ‫׎‬ሺ‫ݔ‬௜ ሻ and ‫׎‬ሺ‫ݔ‬௝ ሻ , such that ‫ܭ‬൫‫ݔ‬௜ ǡ ‫ݔ‬௝ ൯ ൌ
‫׎‬ሺ‫ݔ‬௜ ሻ ‫׎ כ‬൫‫ݔ‬௝ ൯ any function that satisfying Mercer’s condition
Fig.6 KBANK SVM Model
can be used as the Kernel function. The Gaussian kernel
function is specific in this study. The SVMs are employing to
estimate the nonlinear behavior of the forecasting data set
because Gaussian kernels tend to give good performance
under general smoothness assumptions.
‫ܭ‬൫‫ݔ‬௜ ǡ ‫ݔ‬௝ ൯ ൌ ‡š’ሺെȁห‫ݔ‬௜ െ ‫ݔ‬௝ หȁଶ Ȁሺʹߪ ଶ ሻሻ (12)

Fig.7 KBANK ARIMA Model

Fig. 3 Support Vector Machine Model


Fig. 3 showed us about price prediction of SCB Bank using
SVM method for 5 day later.

V. EXPERIMENTAL RESULT

Fig.8 SCB SVM Model

Fig. 4, Fig. 6, Fig. 8 show us about price prediction of BBL Kbank and SCB
Bank using SVM method for 5 day later.

Fig.4 BBL SVM Model

Fig.9 SCB ARIMA Model


Fig. 5, Fig. 7, Fig. 9 show us about price prediction information exchanges with several factors. That may be
of BBL Kbank and SCB. Green area mean price to be in the happened unexpectedly before it is possible. It is impossible to
future, Red line mean Real price, Blue line mean SCB model predictions to be correct 100 %. However, there is the
Forecast price. advantage of SVM models that accommodate large and high
The results from Gretl, Arima method. dimension data. In this paper proposes a comparison ARIMA
model and SVM model to find performances and
BBL AVG
disadvantages of each model.
Forecast Price 206 206 206 206 206 206
Real Price 206 208 202 204 207 205.4 ARIMA is suitable for a usage with the data where it
Table.II BBL Forecasting Data From Gretl is linear, but ARIMA model cannot work with huge data. And
SVM can provide results better than the ARIMA in terms of
KBANK AVG the data size which is bigger and has a high dimension data. In
Forecast Price 190 190 190 190 190 190
future work, Dynamic time warping technique as a kernel
Real Price 185.5 180 184.5 186 186 184.4
Table.III Kbank Forecasting Data From Gretl function is an interesting thing to improve forecasting model.

SCB AVG VII. ACKNOWLEDGEMENT


Forecast Price 164 164 164 164 164 164 The authors need to thank the advisors of the Technology of
Real Price 161 157 160.5 166.5 166.5 162.3
Information System Management Mahidol University for
Table.IV SCB Forecasting Data From Gretl
good recommendation.
This results are from Weka, Support vector machine
REFERENCES
BBL AVG [1] Shahriar Shafiee , Erkan Topal : An overview of global gold market and
Forecast Price 206 207 208 209 210 208 gold price forecasting & 2010 Elsevier Ltd. All rights reserved.
Real Price 206 208 202 204 207 205.4 [2] Volkan S Ediger Sertac Akar : ARIMA forecasting of primary energy
Table.V BBL Forecasting Data From Weka demand by fuel in Turkey Energy Policy 35 (2007) 1701–1708
[3] พงษ์ศิริ ศิริพานิช ปราณี นิลกรณ์ สุดา ตระการเถลิงศักดิ : Time Series Forecasting using a
KBANK AVG combined ARIMA and Artificial Neural Network Model การประชุมวิชาการด้าน
Forecast Price 189 188 188 187 188 188 การวิจยั ดําเนินงานแห่งชาติประจําปี ๒๕๕๐
Real Price 185.5 180 184.5 186 186 184.4 [4] Nancy Tran, Member, IEEE, and Daniel A. Reed, Senior Member, IEEE
Table.VI Kbank Forecasting Data From Weka :Automatic ARIMA Time Series Modeling for Adaptive I/O Prefetching
IEEE TRANSACTIONS ON PARALLEL AND DISTRIBUTED
SCB AVG SYSTEMS, VOL. 15, NO. 4, APRIL 2004
Forecast Price 164 163.5 163 162.5 162 163 [5] Rajesh G. Kavasseri Krithika Seetharaman : Day-ahead wind speed
Real Price 161 157 160.5 166.5 166.5 162.3 forecasting using f-ARIMA models Renewable Energy 34 (2009) 1388–
Table.VII SCB Forecasting Data From Weka 1393
[6] Konstantinos Kalpakis, Dhiral Gada, and Vasundhara Puttagunta :
Distance Measures for Effective Clustering of ARIMA Time-Series’ ,
From Table II – VII, results from Gretl and SVM are
Data Mining, 2001. ICDM 2001, Proceedings IEEE International
illustrated. SVM can provide the higher accuracy result than Conference
Gretl because the stock data has a lot of data and high [7] Charisios Christodoulos , Christos Michalakelis, Dimitris Varoutas :
dimension, SVM can handle a type of this data as well. Forecasting with limited data: Combining ARIMA and diffusion models ,
Technological Forecasting & Social Change 77 (2010) 558–565
[8] Laurence E. Blose : Gold prices, cost of carry, and expected inflation ,
Journal of Economics and Business 62 (2010) 35–47
[9] Hongzhan NIE , Guohui LIU , Xiaoman LIU, Yong WANG : Hybrid of
VI. CONCLUSION ARIMA and SVMs for Short-Term Load Forecasting , 2012 International
Conference on Future Energy, Environment, and Materials
[10] Theodoros Koutroumanidis, Lazaros Iliadis , Georgios K. Sylaios : Time-
In first section of this paper gets data from eFin
series modeling of fishery landings using ARIMA models and Fuzzy
Smart Portal (Version 4.6.1) supported by Finansia Syrus Expected Intervals software , Environmental Modelling & Software 21
Securities Public Company Limited. We are get three main (2006) 1711e1721
banks of Thailand which are Bangkok Bank Public Company [11] สาวิตรี โรจน์ประทักษ์ (Sawitree Rojpratak)* สุเมธ แก่นมณี (Sumeth
Limited (BBL), Siam Commercial Bank Public Company Kaenmanee)**: A Comparative Study of Stock Price Forecasting of
SET100 in Stock Exchange of Thailand by Using Monte Carlo and
limited (SCB), and Kasikornbank Public Company Limited Box-Jenkins Methods , KKU Res J (GS) 11 (2) : April - June 2011
(Kbank) to make a forecasting model by ARIMA and SVM. [12] Ping-Feng Pai , Chih-Sheng Lin : A hybrid ARIMA and support vector
ARIMA is one of the most methods people use. A way that is machines model in stock price forecasting , Omega 33 (2005) 497 – 505
appropriate for forecasting time series data (Time Series Data) [13] Box GEP, Jenkins G. Time series analysis, forecasting and control. San
Francisco, CA: Holden-Day; 1970.
in this work, we have imported the value in the prediction data [14] Vapnik V. The nature of statistic learning theory. New York: Springer;
future by the past stock data and tolerances. (Stochastic error 1995.
term) of import use. And SVM Model is one way to use in [15] Zhang G. Peter Times series forecasting using a hybrid ARIMA and
financial markets. The characteristics of the data are time neural network model. Neurocomputing2003;50:159–75.
[16] Pack DJ. In defense of ARIMA modeling. International Journal of
series data with a data structure, no clear pattern, and Forecasting 1990;6:211–8.
uncertainty of the direction of movement speed. There are [17] Granger CWJ. Combining forecasts—twenty years later. Journal of
external factors that cannot be control like a lot of price Forecasting 1989;8:167–73.

You might also like