A Machine Learning Approach
Total Page:16
File Type:pdf, Size:1020Kb
0DVWHU7KHVLV 6RIWZDUH(QJLQHHULQJ 7KHVLVQR06( $XJXVW $0DFKLQHOHDUQLQJDSSURDFK ,QILQDQFLDOPDUNHWV &KULVWLDQ(Z| Department of Software Engineering and Computer Science Blekinge Institute of Technology Box 520 S E – 372 25 Ronneby i Sweden This thesis is submitted to the Department of Software Engineering and Computer Science at Blekinge Institute of Technology in partial fulfillment of the requirements for the degree of Master of Science in Software Engineering. The thesis is equivalent to 20 weeks of full time studies. &RQWDFW,QIRUPDWLRQ Author: Christian Ewö Address: Solvägen 11, s-39351 Kalmar, SWEDEN E-mail: [email protected] Phone: +46 739803781 External advisor: Dr. Peter Andras The University of Newcastle upon Tyne Address: Claremont Tower, School of Computing Science, University of Newcastle Phone: +44 191 2227946 University advisor: Prof. Paul Davidsson Department of Software Engineering and Computer Science Department of Internet : www.bth.se/ipd Software Engineering and Computer Science Phone : +46 457 38 50 00 Blekinge Institute of Technology Fax : + 46 457 271 25 Box 520 S E – 372 25 Ronneby ii Sweden $%675$&7 In this work we compare the prediction performance of three optimized technical indicators with a Support Vector Machine Neural Network. For the indicator part we picked the common used indicators: Relative Strength Index, Moving Average Convergence Divergence and Stochastic Oscillator. For the Support Vector Machine we used a radial-basis kernel function and regression mode. The techniques were applied on financial time series brought from the Swedish stock market. The comparison and the promising results should be of interest for both finance people using the techniques in practice, as well as software companies and similar considering to implement the techniques in their products. .H\ZRUGV Financial time series, Indicator Optimization, Support Vector Machines, Prediction. i $&.12:/('*(0(17 I would like to thank my supervisors: Dr. Peter Andras at the University of Newcastle upon Tyne Thanks for all help and support during the project. Your help and knowledge in the areas of forecasting time series with machine learning techniques were invaluable. Prof. Paul Davidsson at Blekinge Institute of Technology Thanks for all critical opinions, feedback and advices. ii &217(176 $%675$&7 , $&.12:/('*(0(17,, &217(176 ,,, ,1752'8&7,21 %$&.*5281' 352%/(0'(),1,7,21 35(352&(66,1* 4.1 SPLIT CORRECTIONS ...............................................................................................................7 4.2 DETRENDING..........................................................................................................................9 4.3 DATA PARTITIONING ............................................................................................................10 4.4 RESCALING...........................................................................................................................10 4.5 PRINCIPAL COMPONENT ANALYSIS......................................................................................11 68332579(&7250$&+,1(6 5.1 INTRODUCTION.....................................................................................................................13 5.2 PREDICTION ACCOMPLISHMENT...........................................................................................15 7(&+1,&$/,1',&$7256 6.1 RELATIVE STRENGTH INDEX ................................................................................................18 6.2 MOVING AVERAGES.............................................................................................................19 6.3 STOCHASTIC OSCILLATOR....................................................................................................19 6.4 MOVING AVERAGE CONVERGENCE DIVERGENCE ................................................................20 6.5 OPTIMIZATION......................................................................................................................21 (9$/8$7,21 )857+(5:25. &21&/86,21 5()(5(1&(6 10.1 BOOKS..................................................................................................................................34 10.2 ARTICLES .............................................................................................................................34 10.3 WEBPAGES ...........................................................................................................................36 iii ,1752'8&7,21 Today there exist several techniques for analyzing and predicting the future in a large amount of domains, for example in financial markets with stocks, exchange rates, raw material, electricity supply rates etc. In this work the financial markets is what we focus at but predictions of time series like water consumption, unemployment ratios and harvest of different crops etc. also exist. There exist many forecasting techniques such as traditional statistical approaches like ARIMA and Hidden Markov (linear models) but also different machine learning approaches, such as artificial neural networks (see chapter 2). In the financial market technical analysis is a popular way to analyze time series. One way of performing it is the identification of different patterns that often occurs before sudden price drops etc. Another way of performing technical analysis is to use indicators. Basically they are calculations of the data history and they are compared with different values with purpose to generate buy, hold and sell signals. The main question in this work was whether machine learning approaches had been compared with traditional technical indicators or not. Something discovered in the survey to be not the case, therefore a comparison is carried out between three common used indicators: Relative Strength Index, Moving Average Convergence Divergence and Stochastic Oscillator and a Support Vector Machine Neural Network (SVM). The latter was picked because it has the promising feature it provides a way to determine the minimal network model describing the data [Haykin 1999], but also because it has not been explored as much as many other neural networks in the domain. To make it more challenging for the SVM, we will first optimize the indicators. The report is structured as followed: • In the %DFNJURXQG chapter (chapter 2) the result of the literature survey is stated. The survey was necessary to get the grip of this complex domain and to investigate what has been done in research. • In the 3UREOHP GHILQLWLRQ chapter (chapter 3) we define and motivate the problem/uncertainty to solve discovered in chapter 2, which was the lack of comparison between artificial neural networks and optimized technical indicators. • In the 3UHSURFHVVLQJ chapter (chapter 4) everything is stated about what was done with the data before feeding it to the SVM. The pre processing involves split corrections, detrending, partitioning, rescaling and principal component analysis (PCA). The latter is a way to determine the right input dimension to the SVM. • The 690 chapter (chapter 5) contains a short SVM introduction giving the reader a picture of the idea behind SVM. It also contains information about the SVM library used and the different kernels and modes tried out as well as the prediction results. • In the 7HFKQLFDOLQGLFDWRUV chapter (chapter 6) we present the indicators used in the comparison as well as the optimization and results of them. • The (YDOXDWLRQ chapter (chapter 7) contains all information about how the comparison between the optimized technical indicators and the SVM predictions 1 were carried out. The results from the comparisons are stated in both tables and diagrams. • In the )XUWKHUZRUN chapter (chapter 8) we discuss things in the report that lies out of scope of the problem definition but however are close related to the work. For the readers it can bring ideas for future implementation and research. • In the &RQFOXVLRQ chapter (chapter 9) we discuss the meaning of our comparison results, and what conclusions can be drawn from it. • In the 5HIHUHQFHV chapter (chapter 10) all reference sources like books, articles and web pages are stated. 2 %$&.*5281' During the last three decades lots of research has been made in the prediction of time series, which basically means a sequence of data related to time. Useful data suitable for prediction can be found in many different domains, in finance the data often origin from stock markets and foreign exchange among others. From the beginning the research has mainly been done in the domains of Econometrics and Finance, where different linear approaches has grown through techniques like for example ARIMA and Kalman filters. The former stands for Autoregressive Integrated Moving Average model, which is a linear nonstationary model. With different operators it converts the data to stationary which basically means excluding trends and seasonal effects, which often occurs in time series [Chatfield 1989]. The latter dates from the sixties and was first introduced by Kalman and assumes each state variable to be distributed according to a Gaussian distribution, a new state can then be calculated as a linear function from the previous ones [Chatfield 1989]. Hidden Markov models can also be worth some attention. They are stochastic processes generated by an underlying Markov chain and a set of observation distributions associated with its hidden states. The Markov chain is a process of random variables where n+1 is dependent of n but not the previous values [Rabiner