Stock Market Trend Analysis Using Hidden Markov Models



Similar documents
FOREX TRADING PREDICTION USING LINEAR REGRESSION LINE, ARTIFICIAL NEURAL NETWORK AND DYNAMIC TIME WARPING ALGORITHMS

Hardware Implementation of Probabilistic State Machine for Word Recognition

PERFORMANCE ANALYSIS OF HYBRID FORECASTING MODEL IN STOCK MARKET FORECASTING

CS 2750 Machine Learning. Lecture 1. Machine Learning. CS 2750 Machine Learning.

Supply Chain Forecasting Model Using Computational Intelligence Techniques

Forecasting of Economic Quantities using Fuzzy Autoregressive Model and Fuzzy Neural Network

Forecasting Of Indian Stock Market Index Using Artificial Neural Network

2. IMPLEMENTATION. International Journal of Computer Applications ( ) Volume 70 No.18, May 2013

A Hybrid Tabu Search Method for Assembly Line Balancing

AUTOMATION OF ENERGY DEMAND FORECASTING. Sanzad Siddique, B.S.

Stock Trading by Modelling Price Trend with Dynamic Bayesian Networks

HMM Based Enhanced Security System for ATM Payment [AICTE RPS sanctioned grant project, Affiliated to University of Pune, SKNCOE, Pune]

Tagging with Hidden Markov Models

HYBRID PROBABILITY BASED ENSEMBLES FOR BANKRUPTCY PREDICTION

A New Approach to Neural Network based Stock Trading Strategy

GOAL-BASED INTELLIGENT AGENTS

Dimension Reduction. Wei-Ta Chu 2014/10/22. Multimedia Content Analysis, CSIE, CCU

Ericsson T18s Voice Dialing Simulator

Machine learning for algo trading

A Neural Network and Web-Based Decision Support System for Forex Forecasting and Trading

Estimation of the COCOMO Model Parameters Using Genetic Algorithms for NASA Software Projects

Application of Hidden Markov Model in Credit Card Fraud Detection

Reinforcement Learning

PREDICTION OF FINANCIAL TIME SERIES WITH HIDDEN MARKOV MODELS

Designing a Decision Support System Model for Stock Investment Strategy

3 Results. σdx. df =[µ 1 2 σ 2 ]dt+ σdx. Integration both sides will form

STOCK MARKET FORECASTING TECHNIQUES: A SURVEY

Hidden Markov Models in Bioinformatics. By Máthé Zoltán Kőrösi Zoltán 2006

Hidden Markov Models

Tutorial on Markov Chain Monte Carlo

Spot me if you can: Uncovering spoken phrases in encrypted VoIP conversations

Sales Forecast for Pickup Truck Parts:

Reinforcement Learning

STOCK PREDICTION SYSTEM USING ANN

Intrusion Detection via Machine Learning for SCADA System Protection

Hidden Markov Models 1

A Sarsa based Autonomous Stock Trading Agent

A Genetic Programming Model for S&P 500 Stock Market Prediction

Introduction to Algorithmic Trading Strategies Lecture 2

Cash Forecasting: An Application of Artificial Neural Networks in Finance

Advanced Signal Processing and Digital Noise Reduction

Stock Market Index Prediction by Hybrid Neuro- Genetic Data Mining Technique

The relation between news events and stock price jump: an analysis based on neural network

Performance Evaluation and Prediction of IT-Outsourcing Service Supply Chain based on Improved SCOR Model

Practice Problems for Homework #8. Markov Chains. Read Sections Solve the practice problems below.

Adaptive Demand-Forecasting Approach based on Principal Components Time-series an application of data-mining technique to detection of market movement

Adaptive Business Intelligence

PREDICTING STOCK PRICES USING DATA MINING TECHNIQUES

An Environment Model for N onstationary Reinforcement Learning

International Journal of Software and Web Sciences (IJSWS)

A Wavelet Based Prediction Method for Time Series

Genetic algorithms for solving portfolio allocation models based on relative-entropy, mean and variance

Using Markov Decision Processes to Solve a Portfolio Allocation Problem

Studying Achievement

Fuzzy Candlestick Approach to Trade S&P CNX NIFTY 50 Index using Engulfing Patterns

Hidden Markov Models with Applications to DNA Sequence Analysis. Christopher Nemeth, STOR-i

Simulating the Multiple Time-Period Arrival in Yield Management

Speech: A Challenge to Digital Signal Processing Technology for Human-to-Computer Interaction

Forecasting Stock Prices using a Weightless Neural Network. Nontokozo Mpofu

A Proposed Prediction Model for Forecasting the Financial Market Value According to Diversity in Factor

Lecture 6. Artificial Neural Networks

A New Approach in Software Cost Estimation with Hybrid of Bee Colony and Chaos Optimizations Algorithms

Comparing Neural Networks and ARMA Models in Artificial Stock Market

ARTIFICIAL INTELLIGENCE METHODS IN EARLY MANUFACTURING TIME ESTIMATION

NTC Project: S01-PH10 (formerly I01-P10) 1 Forecasting Women s Apparel Sales Using Mathematical Modeling

NTC Project: S01-PH10 (formerly I01-P10) 1 Forecasting Women s Apparel Sales Using Mathematical Modeling

DATA MINING IN FINANCE

Machine Learning and Pattern Recognition Logistic Regression

CHAPTER 7 STOCHASTIC ANALYSIS OF MANPOWER LEVELS AFFECTING BUSINESS 7.1 Introduction

Optimal Replacement of Underground Distribution Cables

A DISCRETE TIME MARKOV CHAIN MODEL IN SUPERMARKETS FOR A PERIODIC INVENTORY SYSTEM WITH ONE WAY SUBSTITUTION

Prediction of Stock Performance Using Analytical Techniques

Probabilistic Credit Card Fraud Detection System in Online Transactions

STRATEGIC CAPACITY PLANNING USING STOCK CONTROL MODEL

11. Time series and dynamic linear models

Modeling learning patterns of students with a tutoring system using Hidden Markov Models

Supply planning for two-level assembly systems with stochastic component delivery times: trade-off between holding cost and service level

INTEGRATED OPTIMIZATION OF SAFETY STOCK

Predict Influencers in the Social Network

Dr Anitha S Pillai Professor and Head, Department of MCA, Hindustan University, Chennai, Tamil Nadu, India

Machine Learning in FX Carry Basket Prediction

Machine Learning.

COMBINING THE METHODS OF FORECASTING AND DECISION-MAKING TO OPTIMISE THE FINANCIAL PERFORMANCE OF SMALL ENTERPRISES

Computational Neural Network for Global Stock Indexes Prediction

Cell Phone based Activity Detection using Markov Logic Network

Bayesian Statistics: Indian Buffet Process

Neural Networks for Machine Learning. Lecture 13a The ups and downs of backpropagation

Lecture 8 February 4

Classification of Fingerprints. Sarat C. Dass Department of Statistics & Probability

Optimized Fuzzy Control by Particle Swarm Optimization Technique for Control of CSTR

TOURISM DEMAND FORECASTING USING A NOVEL HIGH-PRECISION FUZZY TIME SERIES MODEL. Ruey-Chyn Tsaur and Ting-Chun Kuo

Neural Networks in Data Mining

IN current film media, the increase in areal density has

Machine Learning and Data Mining. Fundamentals, robotics, recognition

Feature Subset Selection in Spam Detection

LECTURE 4. Last time: Lecture outline

Transcription:

Stock Market Trend Analysis Using Hidden Markov Models Kavitha G School of Applied Sciences, Hindustan University, Chennai, ndia. E-mail: kavithateam@gmail.com *Udhayakumar A School of Computing Sciences, Hindustan University, Chennai, ndia E-mail: aukumar7@gmail.com Nagarajan epartment of nformation Technology, Math Section, Salalah College of Technology, Salalah, Sultanate of Oman E-mail: drnagarajan75@gmail.com Abstract Price movements of stock market are not totally random. n fact, what drives the financial market and what pattern financial time series follows have long been the interest that attracts economists, mathematicians and most recently computer scientists [7]. This paper gives an idea about the trend analysis of stock market behaviour using Hidden Markov Model (HMM). The trend once followed over a particular period will sure repeat in future. The one day difference in close value of stocks for a certain period is found and its corresponding steady state probability distribution values are determined. The pattern of the stock market behaviour is then decided based on these probability values for a particular time. The goal is to figure out the hidden state sequence given the observation sequence so that the trend can be analyzed using the steady state probability distribution(π ) values. Six optimal hidden state sequences are generated and compared. The one day difference in close value when considered is found to give the best optimum state sequence. Keywords-Hidden Markov Model; Stock market trend; Transition Probability Matrix; Emission Probability Matrix; Steady State Probability distribution. NTROUCTON A growing economy consists of prices falling, not rising, says Kel Kelly[9]. Stock prices change every day as a result of market forces. There is a change in share price because of supply and demand. According to the supply and demand, the stock price either moves up or undergoes a fall. Stock markets normally reflect the business cycle of the economy: when the economy grows, the stock market typically reflects this economic growth in an upward trend in prices. n contrast, when the economy slows, stock prices tend to be more mixed. Markets may take time to form bottoms or make tops, sometimes of two years or more. This makes it difficult to determine when the market hits a top or a bottom[3]. The Stock Market patterns are non-linear in nature, hence it is difficult to forecast future trends of the market behaviour. n this paper, a method has been developed to forecast the future trends of the stock market. The Latent or hidden states, which determine the behaviour of the stock value, are usually invisible to the investor. These hidden states are derived from the emitted symbols. The emission probability depends on the current state of the HMM. Probability and Hidden Markov Model give a way of dealing with uncertainty. Many intelligent tasks are sequence finding tasks, with a limited availability of information. This naturally involves hidden states or strategies for dealing with uncertainty.. LTERATURE SURVEY n Recent years, a variety of forecasting methods have been proposed and implemented for the stock market analysis. A brief study on the literature survey is presented. Markov Process is a stochastic process where the probability at one time is only conditioned on a finite history, being in a certain state at a certain time. Markov chain is Given the present, the future is independent of the past. HMM is a form of probabilistic finite state system where the actual states are not directly observable. They can only be estimated using observable symbols associated with the hidden states. At each time point, the HMM emits a symbol and changes a state with certain probability. HMM analyze and predict time series or time depending phenomena. There is not a one to one correspondence between the states and the observation symbols. Many states are mapped to one symbol and vice-versa. Hidden Markov Model was first invented in speech recognition [2,3], but is widely applied to forecast stock market data. Other statistical tools are also available to make forecasts on past time series data. Box Jenkins[2] used Time series analysis for forecasting and control. White[5,8,9] used Neural Networks for stock market forecasting of BM daily stock returns. Following this, various studies reported on the effectiveness of alternative learning algorithms and prediction methods using ANN. To forecast the daily close and morning open price, Henry [6] used ARMA model. But all these conventional methods had problems when non linearity exists in time series. Chiang et al.[4] have used ANN to forecast the end-of-year net asset value of mutual funds. Kim and Han [] found that the complex dimensionality and buried *Corresponding author

noise of the stock market data makes it difficult to reestimate the ANN parameters. Romahi and Shen [4] also found that ANN occasionally suffers from over fitting problem. They developed an evolving rule based expert system and obtained a method which is used to forecast financial market behaviour. There were also hybridization models effectively used to forecast financial behaviour. The drawback was requirement of expert knowledge. To overcome all these problems Hassan and Nath [5] used HMM for a better optimization. Hassan et al. [6] proposed a fusion model of HMM, ANN and GA for stock Market forecasting. n continuation of this, Hassan [7] combined HMM and fuzzy logic rules to improve the prediction accuracy on non-stationary stock data sets. Jyoti Badge[8] used technical indicators as an input variable instead of stock prices for analysis. Aditya Gupta and Bhuwan hingra[] considered the fractional change in Stock value and the intra-day high and low values of the stock to train the continuous HMM. n the earlier studies, much research work had been carried out using various techniques and algorithms for training the model for forecasting or predicting the next day close value of the stock market, for which randomly generated Transition Probability Matrix (TPM), Emission Probability Matrix (EPM) and prior probability matrix have been considered. n this paper, the trend analysis of the stock market is found using Hidden Markov Model by considering the one day difference in close value for a particular period. For a given observation sequence, the hidden sequence of states and their corresponding probability values are found. The probability values of π gives the trend percentage of the stock prices. ecision makers make decisions in case of uncertainty. The proposed approach gives a platform for decision makers to make decisions on the basis of the percentage of probability values obtained from the steady state probability distribution.. A. Basics of HMM RESEARCH SET UP HMM is a stochastic model where the system is assumed to be a Markov Process with hidden states. HMM gives better accuracy than other models. Using the given input values, the parameters of the HMM ( λ) denoted by A, B and π are found out. Hidden Sequence s s 2... o o 2... Observation Sequence HMM consists of Fig. Trellis iagram A set of hidden or latent states (S) A set of possible output symbols (O) A state transition probability matrix (A) probability of making transition from one state to each of the other states Observation emission probability matrix (B) probability of particular state Prior probability matrix (π ) s o emitting/observing a symbol at a probability of starting at a particular state An HMM is defined as λ=(s, O, A, B, π ) where S={s,s 2,,s N } is a set of N possible states N M O={o,o 2,,o M } is a set of M possible observation symbols A is an NxN state Transition Probability Matrix (TPM) B is an NxM observation or Emission Probability Matrix (EPM) π is an N dimensional initial state probability distribution vector and A, B and π should satisfy the following conditions:

N a ij j= M b ij j= N i= i = where i N; = where i N; π = where π i The main problems of HMM are: Evaluation, ecoding, and Learning. Evaluation problem Given the HMM λ = { A, B, π} and the observation sequence O=o o 2... o M, the probability that model λ has generated sequence O is calculated. Often this problem is solved by the Forward Backward Algorithm (Rabiner, 989) (Rabiner, 993). ecoding problem Given the HMM λ = { A, B, π} and the observation sequence O=o o 2... o M, calculate the most likely sequence of hidden states that produced this observation sequence O. Usually this problem is handled by Viterbi Algorithm (Rabiner,989) (Rabiner,993). Learning problem Given some training observation sequences O=o o 2... o M and general structure of HMM (numbers of hidden and visible states), determine HMM parameters λ = { A, B, π} that best fit training data. The most common solution for this problem is Baum- Welch algorithm (Rabiner,989) (Rabiner,993) which is considered as the traditional method for training HMM. n this paper, BM daily close value data for a month period is considered. Two observing symbols and have been used: indicates ncreasing, indicates ecreasing. f Today s close value Yesterday s close value >, then observing symbol is f Today s close value Yesterday s close value < then observing symbol is There are six hidden states assumed and are denoted by the symbol S,,,,, where S indicates very low ; indicates low ; indicates moderate low indicates moderate high ; indicates high ; indicates very high. The States are not directly observable. The situations of the stock market are considered hidden. Given a sequence of observation we can find the hidden state sequence that produced those observations. B. atabase The complete set of data for the proposed study has been taken from yahoofinance.com. The Table given below shows the daily close value of the stock market: Table. aily close value for finding differences in one day, two, three, four, five, six close value S.NO C.V.in. day.in.3 77.9 2 77.39 -.52 3 76.5 -.89 -.4 4 75.86 -.64 -.53-2.5 5 77.45.59.95.6 -.46 6 79.33.88 3.47 2.83.94.42 7 79.5.8 2.6 3.65 3. 2.2.6 8 79.5 -.36 -.8.7 3.29 2.65.76 9 79.95.8.44.62 2.5 4.9 3.45 78.56 -.39 -.59 -.95 -.77. 2.7 79.7.5 -.88 -.8 -.44 -.26.62 2 77.4 -.67 -.6-2.55 -.75-2. -.93 3 77.28 -.2 -.79 -.28-2.67 -.87-2.23 4 77.95.67.55 -.2 -.6-2 -.2 5 77.33 -.62.5 -.7 -.74 -.23-2.62 6 76.7 -.63 -.25 -.58 -.7-2.37 -.86 7 77.73.3.4 -.22.45.33 -.34 8 77.7 -.66.37 -.26 -.88 -.2 -.33 9 77.9.83.7.2.57 -.5.62 2 75.7-2.2 -.37-2.3 - -.63-2.25 C.V Close value O.S.in. 2 O.S O.S.in4 ; O.S Observing symbol.in. day - difference in day close value;.in.2 - difference in 2 close value;.in.3 - difference in 3 close value;.in.4 - difference in 4 close value;.in.5 - difference in 5 close value;.in.6 - difference in 6 close value O.S.in. 5 O.S.in. 6 O.S

V. CALCULATON The various probability values of TPM, EPM and π for difference in one day, two, three, four, five, six close value close value are calculated as given below. A. Probability values of TPM, EPM and π for difference in one day close value: TRANSTON Table. Transition table with probability values for difference in one day close value S S.5.5 S S.5.5.43.43.57.43.5.5.25.25.5.5.5 Fig 2. TPM S.5.7 Fig 3. EPM.5.29.429.429.574.429.5.5.25.25.5 B. Probability values of TPM, EPM and π for difference in two close value: S S.4.4.2.33.33.33.33.7.5 Fig 4. TPM S.6.33.5.4.67.5 Fig 5. EPM

Table. Transition table with probability values for difference in two close values Table V. Transition table with probability values for difference in three close values TRANSTON S S.4.4.2 TRANSTON S.33.33.33.33.67.5 S.5.5.25.75.2.2.2.2.2.5.5 C. Probability values of TPM, EPM and π for difference in three close value: S.2.5 S.5.25.2.5.5.75.2.2.5 Fig 6. TPM S.5.4.5.6 Fig 7. EPM.2.5.5.5. Probability values of TPM, EPM and π for difference in four close value: S S.33.33.33.33.67.67.33.33.67 Fig 8. TPM S.67.33.67.33.67.33 Fig 9. EPM

Table V. Transition table with probability values for difference in five close values Table V. TRANSTON Transition table with probability values for difference in four close values S S.33.33.33.33.67.67.33 TRANSTON S S.5.25.25.33.67.5.5.5.5.33.67 E. Probability values of TPM, EPM and π for difference in five close value: S S.5.25.25.33.67.5.5.5.5 Fig. TPM S.25.5.75.5 Fig. EPM F. Probability values of TPM, EPM and π for difference in six close value: S S.5.5.5.5.33.33.33.5.5 S Fig 2. TPM.67.33 Fig 3. EPM

Table V. Transition table with probability values for difference in six close values The fitness function used for finding the fitness value of sequence of states is defined by TRANSTON S S.5.5 Fitness = compare( i, j).5.5 V. SCUSSON.33.33.33.5.5 The MATLAB function Hmmgenerate is used to generate a random sequence of emission symbols and states. The length of both sequence and states to be generated is denoted by L. The HMM matlab toolbox syntax is : [Sequence, States] = Hmmgenerate ( L, TPM, EPM), see [] For instance, f the nput is given as, TPM = [ ;.5.5 ;.43.43.57.43;.5.5 ;.25.25.5 ;.5.5]; EPM = [ ;.5.5;.7.29; ; ; ]; [sequence,states] = hmmgenerate(7, TPM, EPM) 'Sequence Symbols',{'',''},... 'Statenames',{'very low';'low';'moderate low';'moderate high';'high';'very high'} Then the Output of few randomly generated sequences and states is given below: Sequence: ε Using the terative procedure, for each TPM and EPM framed we get an optimum sequence of states generated. The length of the sequence generated is taken as L=7, for instance. The optimum sequence of states obtained from the one day difference TPM and EPM is. ε S Similarly,we get 5 more such optimum sequences of states for 2 day difference, 3 day difference, 4 day difference, 5 day difference, 6 day difference TPM and EPM respectively as follows: 2. ε S S S S S 3. ε S S 4. ε S 5. ε S S S S S 6. ε S S states : sequence : ε states : S Using the fitness function we compute the fitness value for each of the optimum sequence of states obtained. where ε denotes the start symbol.

Table V. S.No. Comparison of Six Optimum State Sequences Comparison of 6 optimum sequence of states Calculated value Fitness = compare( i, j). (,2) + (,3) + (,4) + (,5) + (,6) 2. (2,) + (2,3) + (2,4) + (2,5) + (2,6).29.76 3. (3,) + (3,2) + (3,4) + (3,5) + (3,6).86.54 4. (4,) + (4,2) + (4,3) + (4,5) + (4,6).43.7 5. (5,) + (5,2) + (5,3) + (5,4) + (5,6) 2.4.47 6. (6,) + (6,2) + (6,3) + (6,4) + (6,5) 2.4.47 V. CONCLUSON n this paper, results are presented using Hidden Markov Model to find the trend of the stock market behavior. The highest is the fitness value, the better is the performance of the particular sequence. One day difference in close value when considered is found to give the best optimum sequence. t is observed that at any point of time over years, if the stock market behaviour pattern is the same then we can observe the same steady state probability values as obtained in one day difference of close value, which clearly determines the behavioural pattern of the stock market. V. REFERENCES [] Aditya Gupta and Bhuwan hingra, Non-Student members, EEE, Stock Market Prediction Using Hidden Markov Models, 22. [2] G. E. P. Box and G. M. Jenkins, Time series analysis: forecasting and control. San Fransisco, CA: Holden- ay, 976. [3] r. Bryan Taylor, The Global Financial ata Guide to Bull and Bear Markets, President, Global Financial ata, nc. [4] W.C. Chiang, T. L. Urban and G. W. Baldridge, A neural network approach to mutual fund net asset value forecasting, Omega nternational Journal of Management Science.,Vol. 24 (2), pp. 25 25,996. [5] Halbert White, Economic prediction using neural networks: the case of BM daily stock returns, epartment of Economics, University of California, San iego. [6] Henry M. K. Mok, Causality of interest rate, exchange rate and stock prices at stock market open and close in Hong Kong, Asia Pacific Journal of Management,Vol. (2), pp. 23 43,993. [7] Hassan Rafiul, Nath Baikunth and Michael Kirley, HMM based Fuzzy Model for Time Series Prediction, EEE nternational Conference on Fuzzy Systems., pp. 22-226,26. [8] Jyoti Badge, Forecasting of ndian Stock Market by Effective Macro- Economic Factors and Stochastic Model, Journal of Statistical and Econometric Methods, Vol. (2),pp. 39-5,SSN: 224-384 (print), 224-376 (online) Sciencepress Ltd, 22. [9] Kel Kelly, A growing economy consists of prices falling, not rising, How the Stock Market and Economy Really Work, 2. [] K.J. Kim and. Han, Genetic algorithms approach to feature discretization in artificial neural networks for the prediction of stock price index, Expert Systems with Applications, Vol.9,pp. 25 32,2. [] K. Murphy, HMM Toolbox for MATLAB, nternet: http://www.cs.ubc.ca/~murphyk/software/hmm/hmm.html, Oct. 29, 2. [2] L. Rabiner and B. Juang, Fundamentals of Speech Recognition, Prentice-Hall, Englewood Cliffs,NJ, 993. [3] L.R Rabiner, A tutorial on HMM and Selected Applications in Speech Recognition, n:[wl], proceedings of the EEE,Vol. 77 (2), pp. 267-296,993. [4] Y. Romahi and Q. Shen, ynamic financial forecasting with automatically induced fuzzy associations, n Proceedings of the 9th international conference on fuzzy systems., pp. 493 498,2. [5] Md. Rafiul Hassan and Baikunth Nath, Stock Market forecasting using Hidden Markov Model: A New Approach, Proceeding of the 25 5 th international conference on intelligent Systems esign and Application -7695-2286-6/5, EEE, 25. [6] Md. Rafiul Hassan, Baikunth Nath and Michael Kirley, A fusion model of HMM, ANN and GA for stock market forecasting, Expert systems with Applications., pp. 7-8,27. [7] A. S. Weigend A.. Back, What rives Stock Returns?-An ndependent Component Analysis, n Proceedings of the EEE/AFE/NFORMS 998 Conference on Computational ntelligence for Financial Engineering, EEE, New York., pp. 4-56,998. [8] H.White, Economic prediction using neural networks: the case of BM daily stock returns, n Proceedings of the second EEE annual conference on neural networks.,, pp. 45 458,988. [9] H.White, Learning in artificial neural networks: a statistical perspective, Neural Computation., Vol., pp. 425 464,989.