0% found this document useful (0 votes)
122 views

Predicting Stock Price Using Fuzzy Grey Prediction System: Y.-F. Wang

jj

Uploaded by

Niloy Abu Naser
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
122 views

Predicting Stock Price Using Fuzzy Grey Prediction System: Y.-F. Wang

jj

Uploaded by

Niloy Abu Naser
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Expert Systems

with Applications
PERGAMON Expert Systems with Applications 22 (2002) 33±39
www.elsevier.com/locate/eswa

Predicting stock price using fuzzy grey prediction system


Y.-F. Wang
Department of Information Management, Chang Gung Institute of Nursing, Kwei-Shan, Tao-Yuan, Taiwan

Abstract
The purpose of this paper is to predict the stock price instantly at any given time. One problem with predicting stock prices is that there
may be a large or small difference in two continuous sets of data. The other problem is that the volume of stock data is so large that it affects
our ability to use it. To solve these problems, we constructed a data mart to reduce the size of stock data and combined fuzzi®cation
techniques with the grey theory to develop a fuzzy grey prediction as one of predicting functions in our system to predict the possible answer
immediately. To demonstrate that our system is working correctly, we used our prediction system to analyse stock data and to predict the
stock price promptly at a speci®c time. The system can effectively help stock dealers deal with day trading. q 2001 Published by Elsevier
Science Ltd.
Keywords: Stock price; Fuzzy grey prediction

1. Introduction The timing of buying/selling stock is based on determin-


ing the best time to buy and sell stocks given the constant
Investors have been trying to ®nd a way to predict stock ¯uctuation of stock prices. However, humans have a
prices accurately, but have had less than successful results. dif®cult time doing this because of the complexity of the
Kuo, Chen and Hwang (2001) showed that there are many stock market, as showed in Lee and Jo (1999).
studies which address prediction of stock price that have The problem with predicting stock prices is that the
generally employed the time series analysis techniques volume of data is too huge to in¯uence the ability of
(Kendall & Ord, 1990) and multiple regression models. using information (Fayyad, Shapiro & Smyth, 1996;
Most of them only consider quantitative factors like tech- Widom, 1995). Analyzing stock price data over several
nical indexes. Recently, arti®cial intelligence techniques years may involve only a few thousand records, but these
like arti®cial neural networks (ANNs) and genetic algo- must be selected from millions. A stockbroker who serves
rithms (GAs) have been applied to this area. However, the tens of thousands of customers each year may generate up to
above-mentioned concern still exists (Baba & Kozaki, 1992; 170 GB of stock data at any given time. Multiyear trend
Mahfoud & Mani, 1996). Kim and Han (2000) showed that analysis of the stock price thus still presents a problem
ANNs had some limitations in learning the patterns because due to the vast amount of data involved. It is, therefore,
stock price data has tremendous noise and complex dimen- important to devise ef®cient methods to analyse and predict
sionality. Moreover, the sheer quantity of stock data some- stock prices. For this reason, we constructed a data mart
times interferes with the learning of patterns. (Demarest, 1994), a relational database, to clean and reduce
Kuo et al. (2001) pointed out that numerous factors, such the size of the stock data so only the useful data is down-
as macro-economical and political events, can have a major loaded and reformatted into the data mart (Liu & Setiono,
in¯uence on stock prices. Even the psychology of investors 1996). Consequently, the size of these stock data is reduced
can generate index oscillation. Therefore, it is not suf®cient from approximately 600 MB per day to approximately
to restrict stock price prediction to just some technical 1 MB per day. The advantage of using reformatted data is
indexes in such a complicated environment. This explains that reformatted data is more easily understood and used by
why experienced stock experts and brokers can make more users, as shown in Table 1. Since our database stores the
accurate decisions than average investors, since they do not reformatted data supported, the minimum time interval is
only consider the technical indexes but also qualitative 5 min.
factors based on their experience and knowledge. The grey theory that was ®rst proposed by (Deng, 1982,
1989a,b) avoids the inherent defects of conventional
E-mail address: [email protected] (Y.-F. Wang). statistic methods and only requires a limited amount of
0957-4174/01/$ - see front matter q 2001 Published by Elsevier Science Ltd.
PII: S 0957-417 4(01)00047-1
34 Y.-F. Wang / Expert Systems with Applications 22 (2002) 33±39

Table 1
Reformatted relational database

StockNo Date Time Open High Low Close Vol Invol OutVol Amt

2311 2000/07/24 09:10:00 8650 8750 8550 8750 192 118 74 16627
2311 2000/07/24 09:15:00 8750 8750 8650 8650 123 104 19 10694
2311 2000/07/24 09:20:00 8650 8700 8600 8650 88 48 40 7621
2311 2000/07/24 09:25:00 8650 8700 8650 8700 35 22 13 3032
2311 2000/07/24 09:30:00 8650 8650 8650 8650 64 64 0 5534
2311 2000/07/24 09:35:00 8650 8650 8650 8650 161 161 0 13923
2311 2000/07/24 09:40:00 8650 8650 8600 8650 221 220 1 19011
2311 2000/07/24 09:45:00 8600 8650 8600 8650 139 136 3 11955
2311 2000/07/24 09:50:00 8600 8650 8600 8600 73 58 15 6299
2311 2000/07/24 09:55:00 8650 8650 8600 8600 59 25 34 5089
2311 2000/07/24 10:00:00 8600 8600 8550 8550 100 41 59 8588
2311 2000/07/24 10:05:00 8550 8600 8550 8600 77 69 8 6586
2311 2000/07/24 10:10:00 8600 8600 8550 8600 39 21 18 3342
: : : : : : : : : : :
: : : : : : : : : : :

data to estimate the behaviour of unknown systems (Deng, x (1)(k 1 p) can be calculated by
1982, 1989a,b). Therefore, we use the grey theory to  
develop an ef®cient method to solve the problems of stock …1† …0† b 
x …k 1 p† ˆ x …1† 2 1 2 ea e2a…k1p21† …2†
price prediction. In this paper, we adopt the most commonly a
used GM(1,1) for our fuzzy grey prediction. The forecasting
step is then generated dynamically from the most recently where p is the forecasting step, a and b are the development
system behaviour by the proposed method to reduce pre- coef®cient and the grey input respectively (Wong, Liang,
dication errors. Feng & Chiang, 1998). In this paper, we will use formula (2)
The other problem with predicting stock prices is that to predict the stock price.
price difference can vary greatly over 2 h. For instance, it As pointed out by Deng (1982), the constraint of grey
is often dif®cult to classify patients as fully sick (Kacprzyk prediction model GM(1,1) is that the ratio, x (0)(k 2 1)/
& Iwanski, 1992). Therefore, crisp data mining approaches x (0)(k), must be in the period of [0.1345, 7.389]; otherwise,
may not be appropriate for these situations. To solve this the grey prediction model GM(1,1) is not suitable to use for
problem, we employ a fuzzi®cation technique into our fuzzy predicting the behaviour of the system. Therefore, we
grey prediction (FGP) as one of predicting functions in our propose a fuzzy grey prediction method to overcome this
system to predict the stock price in the next hour. Using our problem.
system not only enables the user to know the stock price in Essentially, the traditional grey predictions use a ®xed
any given hour, but also to follow stock price trends. In forecasting step to predict the system behaviour. It can
order to demonstrate that our method works correctly, reduce or prevent overshoot. However, the appropriate fore-
we considered the stock price analysis problem over 300 casting step is hard to ®nd. To solve this problem, Chiang,
weekdays of trading. Wang, Lee and Shi (1999) developed a new method to
discover a suitable forecasting step dynamically from the
most recent system behaviour. Expanding on formula (2),
2. Preliminaries this formula can be rewritten as:
!
Dr Deng initialed the grey theory in 1982. He used a grey 0 1 …1† …0† b
predictor to predict the system behaviour and fed the p ˆ 2 loge x …k 1 p 2 1† 1 loge x …1† 2
a a
predicting information back to the decision-making mech- !!
anism to indicate an appropriate control action. The most
commonly used GM(1,1) model for the grey prediction is 2 loge 1 2 e2a 2k …3†
described as follows (Deng, 1989b):

x…1† ˆ IAGO´GM…1; 1†´AGO´x…0† …1† where p 0 is the new forecasting step.


To predict the value of x (1)(6), only use a series of ®ve
where x (0) ˆ (x (0)(1),x (0)(2),¼,x (0)(k)) is a non-negative historical data, x (0)(1),¼,x (0)(5), to discover the appropriate
original data sequence and k$4; moreover, x (1) is a predict- forecasting step for x (1)(6). In formula (3), let that
ing value of x (0), AGO takes the accumulated generating x (0)(5) ˆ x (1)(k 1 p 2 1), and the value b/a is computed by
operation on x (0), and IAGO takes the inverse accumulated x (0), where x (0) ˆ (x (0)(1),¼,x (0)(4)). Consequently, we can
generating operation on x (1). Hence, the predicating value of ®nd out a new forecasting step p 0 for x (1)(6) by formula
Y.-F. Wang / Expert Systems with Applications 22 (2002) 33±39 35

Fig. 1. The simpli®ed architecture of the system.

(3). Then, let x (0) ˆ (x (0)(2),¼,x (0)(5)) and apply formula (2) the graphic display tool is not much more friendly
to predict the value of x (1)(6). than commercial products, it is a useful tool that can
be used to analyse stock price trends effectively. It
includes window-based interactive dialog boxes,
3. Fuzzy grey prediction system mouse-driven menus and scroll bars. As shown in
Fig. 2, the input screen of the system can be separated
Our system was written with Visual BASIC on an
into two regions for input selection:
IBM PC and includes two major modules: graphic
display tool, prediction agent. The simpli®ed architec-
² StockNo/Name region;
ture of the system is given in Fig. 1. In the proposed
² Function groups region.
system, users can check the stock price through the
graphic display tool. Since the predicting process is an
application oriented process, different applications may
need different predicting approaches. In this paper, we 3.1.1. StockNo/Name region
introduce only fuzzy grey prediction in the prediction This includes one text box. Users can input the speci®c
agent. stock number or stock name they are interested in.

3.1. Graphic display tool


3.1.2. Function groups region
This subsection provides a brief introduction of the This contains one combo box, the drop down list appears
graphic display tool. The graphic display tool was after the users press this box, which includes the functional
developed to display the speci®c stock price. Though keywords: Stock Price, Stock Trend, Buy/Sell Detail, News,
Company Information. Some of partial functions are brie¯y
introduced as follows:

² Stock Price Function displays the selected stock current


market dealing price, the price of buying and selling as
well as the highest and lowest price and volume and so
forth.
² Stock Trend Function displays the selected stock price
over the past 6 years diagram. The stock price data can be
grouped into daily, weekly, or monthly.
² Buy/Sell Detail Function displays the selected stock price
buying or selling detail report, which includes the time of
Fig. 2. The input screen of the system. buying or selling, volume, price, etc.
36 Y.-F. Wang / Expert Systems with Applications 22 (2002) 33±39

Table 2 Table 4
Stock price on 5 February 2001 Table of m price(t[price])

Date Time Stock price m price(t[price]) Time m price(t[price])

2001/02/05 09:00 35.81 1 " 09:00 0.9864


2001/02/05 10:00 35.20 0.9662 Group 1 : :
2001/02/05 11:00 34.29 0.9169 # 09:00 1
2001/02/05 12:00 33.48 0.8741 " 10:00 0.9327
2001/02/05 13:00 35.20 0.9662 Group 2 : :
2001/02/05 13:30 35.01 0.9777 # 10:00 0.9665
: : :
: : :
: : :
" 14:00 0.9887
3.2. Prediction agent using fuzzy grey prediction Group 6 : :
# 14:00 0.9678
The stock price is distinct each hour and can be in¯u-
enced by numerous factors at any given time. For example,
as shown in Tables 2 and 3, many factors contributed to the
The following is an example of predicting the stock price
differences seen in the stock price between 5 February 2001
by using fuzzy grey prediction.
and 15 August 2000 because of many reasons. To solve this
problem, we employ fuzzi®cation techniques on the FGP so
3.2.1. Example
that the proposed methods can be used to predict the stock
Consider the stock price at 09:00am in Table 5. We want
price promptly and effectively. In Tables 2 and 3, the value
to predict the stock price at 09:00am on 10 February.
m price(t[price]) is the degree of the stock price at a speci®c
Let x (1)(5) ˆ m price(t[price]) at 09:00am on 9 February ˆ
trading hour on that day, and the membership function of
0.774 and x (0) ˆ (1, 0.853, 0.652, 0.386). According to
m price is given as:
formula (3), we ®nd out that the forecasting step with
mprice …x† ˆ …x=y†2 ; respect to m price(t[price]) at 09:00am on 9 February is
22.590. Now, let x (0) ˆ (0.853, 0.652, 0.386, 0.774). By
where x is the stock price at a speci®c trading hour on one formula (2), we know that m price(t[price]) at 09:00am
day, and y is the highest stock price during trading hours on on 10 February is 0.560. Compared with the actual data
the same day. on 9 February, as shown
Particularly, the change rate at an hour interval of the pin Table
p6, wep
get the follow-
ing error ratio: ( 0:560 2 0:544) 4 0:544 ˆ 0.0146.
stock price may vary slightly every day. Since different Accordingly, the predicting error ratio is 1.46%.
times present different speci®c behaviours, we can pre-clas-
sify stock price data into different time groups if we
consider only the behaviour of stock price of trading 4. Experimental results
hours on weekdays. We can pre-classify tuples in the data-
base with the 'Time' attribute value so that the tuples are In this paper, all the data was collected from a stock-
divided into six groups. As shown in Table 4, each group has broker's mainframe in Taiwan stock market recorded
the same values for the attribute 'Time'. Consequently, every 5 min. The trading hours in Taiwan stock market is
stock price has the same behaviour in the same group from 9:00am to 13:30pm without lunch break on weekdays.
(Chiang, Chow & Wang, 2000). To simplify data processing, the data was grouped into
The advantages of the results of fuzzi®cation and hours assuming the trading time is from 9:00am to
pre-classi®cation are that this process can highlight the 14:00pm on weekdays.
stock price characteristics. Moreover, we can use formula To demonstrate how effective our system is, we used
(2) to predict the stock price because the stock price data is data from September 2000 to February 2001 as training
pre-classi®ed and fuzzed. examples, and data from March 2001 to April 2001 as
testing examples.
Table 3
Stock price on 15 August 2000 Table 5
The m price(t[price]) of last week
Date Time Stock Price m price(t[price])
Date Time m price(t[price])
2000/08/15 09:00 86.91 1
2000/08/15 10:00 85.23 0.9617 2001/02/05 09:00 1
2000/08/15 11:00 83.02 0.9125 2001/02/06 09:00 0.853
2000/08/15 12:00 80.92 0.8669 2001/02/07 09:00 0.652
2000/08/15 13:00 82.47 0.9004 2001/02/08 09:00 0.386
2000/08/15 13:30 82.15 0.9452 2001/02/09 09:00 0.774
Y.-F. Wang / Expert Systems with Applications 22 (2002) 33±39 37

Fig. 3. Stock price from September 1994 to May 2001 (by month).

Table 6 Double-clicking the diagram area displays the chart


The actual data on 9 February shown in Fig. 4, which shows weekly stock price data up
to a 1-year period. At this moment, we can double-click
Date Time Stock price m price(t[price])
again, as shown in Fig. 5, to see the daily stock price over
2001/02/10 09:00 30.70 0.544 a 4-month period. Double-click again as shown in Fig. 6 to
2001/02/10 10:00 32.46 0.608 display a line chart for 9±13 h stock prices on 3 May 2001.
2001/02/10 11:00 41.20 0.980 After seeing these diagrams, we concluded that they might
2001/02/10 12:00 35.63 0.733
2001/02/10 13:00 35.02 0.841
show a relationship between the stock price and time. In
2001/02/10 13:30 41.63 1 other words, the knowledge to be discovered is the relation-
ship between the stock price ranking and time in this case.

4.1. Checking stock price using the graphic display tool 4.2. Predicting stock price using prediction agent

The graphic display tool can also display both historical The advantage of using fuzzy grey prediction in our
and current stock price data for comparison purposes. First prediction agent is that only a few data inputs are needed
of all, after entering StockNo and choosing the `Stock Price' to predict stock behaviour. To assess the accuracy of our
function on the input screen as shown in Fig. 2, press the method, we conducted several experiments, similar to
`GO' button to generate the stock price diagram shown in Section 3.2.1. Consequently, the value of m price(t[price]) at
Fig. 3. In Fig. 3, the bar chart and line chart represent the highest is always equal to 1. Therefore, when we know
high/low value and average value of the stock price for each the m price(t[price]) at 09:00, we can infer the highest stock
month, respectively. price. In the Section 3.2.1, the highest stock price is:

Fig. 4. Stock price from January 2000 to May 2001 (by week).
38 Y.-F. Wang / Expert Systems with Applications 22 (2002) 33±39

Fig. 5. Stock price from January 2001 to May, 2001 (by day).
p
30.7 4 0:56 ˆ 41.026. After running 180 trials, the aver- References
age deviation from the predicted values is less than 9%. The
result shows that our fuzzy grey prediction is feasible. Baba, N., & Kozaki, M. (1992). An intelligent forecasting system of stock
price using neural networks, Proc. IJCNN.
Chiang, D. A., Wang, Y. F., Lee, S. L., & Shi, C. H. (1999). Analyzing
mainframe resource usage by dynamic grey prediction. The Journal of
5. Conclusion Grey System, 11 (2), 97±106.
Chiang, D. A., Chow, L. R., & Wang, Y. F. (2000). Mining time series data
by a fuzzy linguistic summary system. Fuzzy Sets and Systems, 112 (3),
In the proposed system, the graphic display tool can assist 419±432.
users in checking the historical stock data or the current Demarest, M. (1994). Building the data mart. DBMA Magazine, 7 (8),
situation of the stock market. The prediction agent can be 44±45.
used to predict the stock price at any given moment when Deng, J. (1982). Control problems of grey system. Systems & Control
Letters, 1 (5), 288±294.
after trading begins. In addition, the proposed system can
Deng, J. (1989a). Introduction to grey system theory. The Journal of Grey
still be used to effectively predict stock prices even without System, 1 (1), 1±24.
using the graphic display tool. Deng, J. (1989b). Properties of multivariable grey model GM(1,1). The
In our system, most parameters are defaulted and cannot Journal of Grey System, 1 (1), 25±42.
be changed by the user. Therefore, we plan to develop a Fayyad, U., Piatesky-Shapiro, G., Smyth, P., & The, K. D. D. (1996).
more ¯exible interface for users in the near future. At process for extracting useful knowledge from volumes of data. ACM
Comm., 39 (11), 27±34.
present, we just simply ignore the data for that day when Kacprzyk, J., & Iwanski, C. (1992). Fuzzy logic with linguistic quanti®ers
missing data appears. In the future, we will consider the in inductive learning. Fuzzy logic for the management of uncertainty
problem of missing data and develop more useful agents (pp. 465±478). New York: John Wiley & Sons Ltd.
for our system. Kendall, S. M., & Ord, K. (1990). Time series, (3rd ed). New York: Oxford
University Press.
Kim, K. J., & Han, I. (2000). Genetic algorithms approach to feature
discretization in arti®cial neural networks for the prediction of stock
price index. Expert Systems with Applications, 19, 125±132.
Kuo, R. J., Chen, C. H., & Hwang, Y. C. (2001). An intelligent stock trading
decision support system through integration of genetic algorithm based
fuzzy neural network and arti®cial neural network. Fuzzy Sets and
Systems, 118, 21±45.
Lee, K. H., & Jo, G. S. (1999). Expert system for predicting stock market
timing using a candlestick chart. Expert Systems with Applications, 16,
357±364.
Liu, H., & Setiono, R. (1996). Dimensionality reduction via discretization.
Knowledge-Based Systems, 9 (1), 67±72.
Mahfoud, S., & Mani, G. (1996). Financial forecasting using genetic
algorithms. Appl. Arti®cial Intell., 10, 543±565.
Widom, J. (1995). Research problems in data warehousing. Proceedings of
the Fourth International Conference on Information and Knowledge
Management, Baltimore, 25±30 November.
Wong, C. C., Liang, W. C., Feng, H. M., & Chiang, D. A. (1998). Dynamic
grey prediction control design. The Journal of Grey System, 10 (2),
Fig. 6. Stock price on 3 May 2001 (every 5 min). 123±131.

You might also like