Application of Markov Chains to Stock Trends

Problem statement: Modeling of the Dow Jones Industrial Average is frequently attempted in order to determine trading strategies with maximum payoff. Changes in the DJIA are important since movements may affect both individuals and corporations profoundly. Previous work showed that modeling a market as a random walk was valid and that a market may be viewed as having the Markov property. Approach: The aim of this research was to determine the relationship between a diverse portfolio of stocks and the market as a whole. To that end, the DJIA was analyzed using a discrete time stochastic model, namely a Markov Chain. Two models were highlighted, where the DJIA was considered as being in a state of (1) gain or loss and (2) small, moderate, or large gain or loss. A portfolio of five stocks was then considered and two models of the portfolio much the same as those for the DJIA. These models were used to obtain transitional probabilities and steady state probabilities. Results: Our results indicated that the portfolio behaved similarly to the entire DJIA, both in the simple model and the partitioned model. Conclusion: When treated as a Markov process, the entire market was useful in gauging how a diverse portfolio of stocks might behave. Future work may include different classifications of states to refine the transition matrices.


INTRODUCTION
As infamously stated by Adam Smith in Wealth of Nations, "and he is in this...led by an invisible hand to promote an end that was no part of his intention." That is, markets are unpredictable, pure and simple and a working model cannot be constructed which reflects their movements. This, however, does not discourage the creation of such models whose aim is to accurately predict movements in the various markets (Agwuegbo et al., 2010). This research analyzes market trends by determining probabilities that the market transitions between various states. A similar study was conducted by Agwuegbo et al. (2010). Closing prices of the market are considered so that analysis can be done in a discrete manner and the transition probabilities are utilized as parts of Markov chains to model the market. First, the concept of a random variable and a random walk is introduced. Second, Markov theory and properties of Markov chains are discussed. Finally, two models of the Dow Jones Industrial Average (DJIA) and two models of a specific portfolio of stocks in the DJIA are introduced and analyzed (Jones and Smith, 2009).

MATERIALS AND METHODS
A random walk is said to exhibit the Markov property if the position of the walk at time n depends only upon the position of the walk at time n-1 (Winston, 2004). If we call our random variable X n , then Eq. 1: Is independent of X n-2 , X n-3 ,…,X 1 so that the state of X at time n depends only upon the state of X at step n-1. Here each p ij for j =1,2,… is a probability row vector describing every possible trasition from state i to any other available state in the system.
The process of moving from one state of the system to another with the associated probabilities of each transition is known as the chain (Winston, 2004). It is said that every step taken in a chain possessing the Markov property depends only upon the immediately preceding step. It can easily be seen how calculating probabilities of a series, or chain, of events in a Markov system is greatly simplified due to this Markov property. Instead of concerning ourselves with the entire path a random variable might have taken to arrive at its current state, we need only consider its state directly before a given point of interest.
The transition probabilities form an m_m transitional probability matrix T, where: Each row of T is the probability distribution relating to a transition from state i to state j.
States i and j are said to communicate if there exists a path between them (Winston, 2004). It must be true that i is reachable from j in a finite number of transitions and also that j is reachable from i in a finite number of transitions for any two states i and j to communicate. A state i is said to be periodic if all paths leading from state i back to i have a length that is a multiple of some integer k, such that k > 0 for the smallest possible k (Winston, 2004). If all states of a chain communicate a nd are not periodic, then the chain is said to be ergodic.
A chain is said to have a steady state distribution if there exists a vector p such that given a transition matrix T we have Eq. 4: If a chain is ergodic then we are guaranteed the existence of this steady state vector p (Isaacson and Madsen, 1985;Winston, 2004). This steady state vector can be viewed as the distribution of a random variable in the long run.
This steady state probability vector p of an m state random walk can also be obtained as (Isaacson and Madsen, 1985) Eq. 5: Given this formulation of a transition matrix and its steady state, we can set up a system of classification of the Dow Jones Industrial Average (DJIA). The idea of using Markov chains to forecast the behavior of stock prices is popular since potential investors are interested in market trends which might lead to an optimum investment strategy [?]. For this study, three applications of Markov analysis will be considered, namely:  (1), each day was classified as having closed higher or lower than the previous day, thus allowing classification of two states, namely: State 1: Closing value is less than closing value of the previous day State 2: Closing value is greater than or equal to the closing value of the previous day Since an investor is generally creating a portfolio of stocks, application (2) compiles a portfolio of popular companies and models the portfolio in the same ways which application (1) modeled the entire DJIA. The portfolio of choice consisted of JP Morgan Chase, Apple, Google, Intel and Qualcomm. Closing prices of these five companies were gathered from January 4, 2010 to December 31, 2010. Then, the states are: State 1: Value of the portfolio closes lower than previous day State 2: Value of the portfolio closes higher than previous day The transition and steady state probabilities were then compared to closing price data for the portfolio gathered from January 3, 2011 to February 18, 2011 to test the integrity of the model. For application (3), the average change in the closing value of the DJIA was examined. Based on the 2010 data, gains and losses were each partitioned into three subcategories each, namely, small, moderate and large. Transitions for this experiment consisted of moving from a category of gain or loss one day to a category of gain or loss the next, namely: The intervals indicated in parentheses were obtained by determining the absolute average of the market's daily changes. This experiment is meant to be more precise than the first since the concept of the market moving 'up' or 'down' is now better defined.
For model (4), a portfolio partitioned gain and loss model was constructed in the same manner as model (3). The same portfolio described in application (2)

RESULTS
The transition matrix T1 for model 1, accurate to four decimal places, was found to be: so that π 2 = (0.4584, 0.5416). Comparing (1) and (2) we see that the entire market and the portfolio achieve roughly the same steady state, indicating that in the long run both will have similar probability distributions with a slightly higher chance of any given day being a day of gains. This bodes well for investors, as they can see that a diversified portfolio will behave similarly to the entire market and that over a long period of time the number of gain days will outnumber the days of loss. For the third model, the transition matrix was found to be: We found:

DISCUSSION
The matrices T1 and T2 indicate that given a day is in either state there is a greater chance of transitioning to a state of gain than a state of loss. The good news for investors is that the steady state probability vectors p1 and p2 show that there is a greater probability of a day being a day of gains than a day of losses. This was found to be true of both the portfolio and the entire DJIA.
There was no steady state obtained for model 4, indicating that the chain is not ergodic. Notice that in both T 3 and T 4 each row vector contains a majority of the probabilities in columns three and four, indicating that as not matter what state a day occupies, there is a high probability that the next day will be a day of small loss or small gain. This is encouraging for investors since the market will not be prone to large, sustained swings either up or down. We also found that the steady state distribution of model 3 resembled a discrete normal distribution with roughly 68.04% of the days predicted to be in states three and four, or the middle of the distribution and roughly 89.21% of the data falling within the middle four states.

CONCLUSION
This research shows that a diverse portfolio of stocks will mirror the movements of the entire market. That is, the portfolio will show a great propensity to have small gains and losses and show probabilistic immunity to consecutive days of great loss and gain. Therefore, a portfolio of this nature will yield a slow steady growth as there are likely to be more days of gain than days of loss.