Application chain model, the probabilities of the share price

Application of Markov chain in the movement of Stock Prices:Case Study of Bank of America and JP Morgan ChaseBusayo AworunseDepartment of Systems Science and Industrial EngineeringBinghamton University, State University of New York, Binghamton, NY [email protected] this paper, Markov chains model was used to analyze and predict the stock price movements of two banks, namely Bank of America (BOA) and J.P. Morgan Chase (JPM). Using Markov chain model, the probabilities of the share price decreasing, remaining the same and increasing were computed for the future. Daily data involving the share prices of the two named banks from 1984 to 2017 were imported from Yahoo Finance Real Time Price into Excel spreadsheet, where the difference between the same day open and close prices were analyzed to determine the transition matrices for the banks. Using MATLAB to compute the powers of the transition matrices, equilibrium was attained in seven years for BOA and five years for JPM. Irrespective of the current state of the share price, the long-run probabilities of the share price decreasing, remaining the same and increasing for each bank were established. Furthermore, the probabilities of the banks moving from a given present state to a future state were predicted.Keywords: Stock Market, Markov Chain, Stock Prediction IntroductionThe ceaseless pursuit of an investor is being able to predict effectively the stock market in order to minimize his or her risk. Faulty predictions could force the billions of dollars traded everyday down the drain resulting in catastrophic loss by investors hoping to profit in one way or another. However, accurate forecast of the trends of the stock index can help investors to acquire opportunities for gaining profit in the stock exchange. The 2008 financial crises were partly due to inadequate comprehension of the market reaction, and a good knowledge of the stock market prediction might help to forestall similar occurrence in the future. Literature ReviewThe stock markets are dynamic and exhibit wide variation, and the prediction of the stock market thus becomes a highly challenging task because of the highly non-linear nature and complex dimensionality (Guresen et al, 2011; Lee et al, 2002).The unstable environment and its strong connection to numerous stochastic factors such as political events, general economic conditions, and traders’ expectations further add to its complexity (Ticknor 2013). Stock prices skyrocket with little reason, and then plummet quickly and investors are concerned about the future of stock of which this research intends to proffer solution (Anvwar and Philip, 1997).Many models or approaches are available for forecasting the direction of the stock market index movement. Approaches such as using support vector machines (SVM), artificial neural network (ANN), social media analysis, data mining, sentiment analysis and regression have been applied with positive results (Huang et al ,2005; Kara et al ,2011). However, this project is poised at using Markov chain model to predict same day open and close prices share price movements using the dataset from share prices of the BOA and JPM. Markov Chain Model    Definition  of Markov Chain A Markov chain is a stochastic process which consists of a finite number of states with some knownprobability P_ij, where P_ij is the probability that the process will, when in state i, next make a transition into state j.For a Markov chain, the conditional distribution of any future state? X?_(n+1), given the past states? X?_(0,) X_1,?…,X?_(n-1) and the present state X_n, is independent of the past states and depends only on the present state. This fundamental Markov chain property is written mathematically as P_ij=P{X_(n+1)=j?X_n=i,X_(n-1)=i_(n-1),…,X_1=i_1,X_0=i_0 } for all states i_0,i_1,…,i_(n-1),i,j and all n?0 (Ross, M. 2010).Since the probabilities are nonnegative and since the process must make a transition into some state, we have the following: P_ij?0, i,j?0, and ?_(j=0)^???P_ij=1?, for i=0,1,…. Transition MatrixThe transition matrix P is the matrix describing the Markov chain. It is the most important tool for analyzing a Markov chain. The general form of the transition matrix is shown in Figure 1.          Figure 1: Transition MatrixIn the transition matrix P: ROWS represent NOW, or FROM(X_n). COLUMNS represent NEXT, or TO(X_(n+1)). Entry (i,j) is the CONDITIONAL probability that NEXT =j, given that NOW =i: the probability of going FROM state i TO state j. P is a square matrix (N × N), because X_(n+1) and X_n both take values in the same state space S (of size N). Rows of P should each sum to 1. Columns of P do not in general sum to 1. The t-step Transition ProbabilitiesThe transition matrix P_ij is the probability of making a transition FROM state i TO state j in aSINGLE step. The t-step transition probabilities are therefore given by the matrix P^t (Ross, M. 2010). The Probability Distribution of StatesLet {X_1,X_2  X_3,…X_N} be a Markov chain with N × N transition matrix P. If the probability distribution of X_0 is given by the 1×N row vector ?=(?_1  ?_2  ?_3,…?_N ) , then the probability distribution of X_t  is given by the 1 × N row vector  ?P^t. Class StructureStates i and j are in the same communicating class if there is some way of getting from state i to state j, and there is some way of getting from state i to state j. It needn’t be possible to get between i and j in a single step, but it must be possible over some number of steps to travel between them both ways.A Markov chain or transition matrix P is said to be irreducible if all the states of the Markov chain is a single communicating class. PeriodicityThe period d(i) of a state i is d(i)=gcd?{t:(P^t )_ii>0}, the greatest common divisor of the times at which return is possible.The state i is said to be periodic if d(i)>1 and aperiodic if d(i)=1If state i is aperiodic, it means that return to state i is not limited only to regularly repeating times.If a Markov chain is irreducible and has one aperiodic state, then all states are aperiodic. Equilibrium DistributionAn irreducible, aperiodic Markov chain, with finite state space, automatically finds its own way to an equilibrium distribution as the chain wanders through time. Once a chain has hit an equilibrium distribution, it stays there forever. The equilibrium distribution does not depend upon the starting conditions. At equilibrium, P_t converges to a fixed matrix with all rows equal as t approaches infinity(Ross, M. 2010).Vector ?=(?_1  ?_2  ?_3,…?_N ) is an equilibrium distribution for P if: ?P=? ?_(i=1)^N???_i=1? ?_i?0 for all i. Analysis and Results Derivation of the Three-State Transition MatricesThe Markov chain for the banking stock consists of three states which are clearly defined as follows:State SPU = Bank share price remains the same (unchanged).State SPD = Bank share price decreases. State SPI = Bank share price increases.The transition state matrix for the three-state Markov chain follows the pattern shown in Table 1. Each entry PRS represents the probability that a particular present state R changes to the next state S. For instance, the probability that an increase in the share price (SPI state) will be followed by a decrease in the share price (SPD state) is the entry P32. The other transitions are similarly defined.Table 1: Transition State Matrix. Next StatePresent State SPD SPU SPISPD P11 P12 P13SPU P21 P22 P23SPI P31 P32 P33This research covered the share prices of BOA and JPM. The daily data on share prices of the two named banks from 1984 to 2017 were collected from Yahoo Finance Real Time Price.Using Microsoft Excel, the numbers of the following nine transitions for each bank for 34 years of observation were recorded in Tables 2 and Table3. State SPU to SPU,  State SPU to SPD, State SPU to SPI, State SPD to SPU  State SPD to SPD State SPD to SPI State SPI to SPU State SPI to SPD State SPI to SPITable 2: Share Price Transition for BOA SPD SPU SPI Sum of RowSPD 1875 175 1905 3955SPU 184 69 209 462SPI 1897 217 2016 4130Table 3: Share Price Transition for JPM SPD SPU SPI Sum of RowSPD 2009 196 1911 4116SPU 200 48 197 445SPI 1908 200 1875 3983The transition matrix for each bank was formed from Table 2 and Table3 by dividing each row by the corresponding sum of row. The division ensures that the sum of entries in a row is equal to unity, as required by a true transition matrix.The share price transition matrices for BOA and JPM are shown respectively in Table 4 and Table 5.Table 4: Share Price Transition Matrix for BOA SPD SPU SPISPD 0.474083 0.044248 0.481669SPU 0.398268 0.149351 0.452381SPI 0.459322 0.052542 0.488136Table 5: Share Price Transition Matrix for JPM SPD SPU SPISPD 0.488095 0.047619 0.464286SPU 0.449438 0.107865 0.442697SPI 0.479036 0.050213 0.470751 Interpretation of the Transition Matrix For BOA, the probability that the bank share price that: Decreases will still decrease is 0.474083. Decreases will remain the same is 0.044248. Decreases will increase is 0.481669. Remains unchanged will still decrease is 0.398268. Remains unchanged will still remain the same is 0.149351. Remains unchanged will still increase is 0.481669. Increases will still decrease is 0.459322. Increases will remain the same is 0.052542. Increases will still increase is 0.488136.This reveals that the event that the share price of BOA that increases will still increase has the highest probability and, therefore, most likely to occur. The event that the share price that decreases will remain the same has the lowest probability and, therefore, least likely to occur. For JPM, the probability that the bank share price that  Decreases will still decrease is 0.488095. Decreases will remain the same is 0.047619. Decreases will increase is 0.464286. Remains unchanged will still decrease is 0.449438. Remains unchanged will still remain the same is 0.107865. Remains unchanged will still increase is 0.442697. Increases will still decrease is 0.479036. Increases will remain the same is 0.050213. Increases will still increase is 0.470751.This reveals that the event that the share price of JPM that decreases will still decrease has the highest probability and, therefore, most likely to occur. The event that the share price that decreases will remain the same has the lowest probability and, therefore, least likely to occur. Transition Diagrams The transition diagrams describing pictorially the Markov chains of the two banks of interest are shown in Figure 1 and Figure 2. The transition diagrams show the transitions between the different states in the chain.It is evident that the Markov chains shown in Figures 1 and 2 are irreducible and aperiodic.Therefore, the Markov chain will converge to an equilibrium distribution in the long-run. Figure 1: Transition Diagram for BOA. Figure 2: Transition Diagram for JPM. Powers of the Transition Matrix for BOA    P=?(0.474083&0.044248 &[email protected]&0.149351&[email protected]&0.052542&0.488136)    P^2=?( 0.463618&0.052894&[email protected]&0.063697&[email protected]&0.053819&0.483287)    P^3=?(  0.462936&0.053817&[email protected] 0.462165&0.054926&[email protected] 0.462869&0.053913&0.483218)    P^4=?(  0.462870&0.053912&[email protected] 0.462791&0.054026&[email protected] 0.462863&0.053922&0.483215)    P^5=?(  0.462863&0.053922&[email protected]  0.462855&0.053934&[email protected]  0.462862&0.053923&0.483215)    P^6=?(  0.462862&0.053923&[email protected]  0.462861&0.053924&[email protected]  0.462862&0.053923&0.483215)    P^7=?(  0.462862&0.053923&[email protected]  0.462862&0.053923&[email protected]  0.462862&0.053923&0.483215)After a period of 7 years, equilibrium distribution that does not depend upon the starting conditions is attained. This is shown in P^7 with all the rows having similar entries. This convergence of P^T, where T is the number of years, means that for T is equal to or greater than 7 years, no matter which state we start in we always have the following probabilities: The probability of the share price decreasing (state SPD) is 0.462862. The probability of the share price remaining unchanged (state SPU) is 0.053923 The probability of the share price increasing (state SPI)  is 0.483215If it is equally likely that the share price can start in a state at the present, then the probability distribution (?) of the states is  ?=(1/3   1/3   1/3).The probability distribution of the states after 1 year is  (1/3  1/3  1/3)P=(1/3  1/3  1/3)?(0.474083&0.044248 &[email protected]&0.149351&[email protected]&0.052542&0.488136)=0.443891   0.082047   0.474062The probability distribution of the states after 2 years is   (1/3  1/3  1/3) P^2=(1/3  1/3  1/3)?( 0.463618&0.052894&[email protected]&0.063697&[email protected]&0.053819&0.483287)=0.460865   0.056803   0.482332The probability distributions of the states up to the next 7 years were similarly calculated and the results are shown in Table 6.     Table 6: The Probabilities of the Share Price Decreasing, Remaining the Same and Increasing ProbabilityYears from now Decreasing Remaining the same Increasing1 0.443891 0.082047 0.4740622 0.460865 0.056803 0.4823323 0.462657 0.054219 0.4831254 0.462841 0.053954 0.4832055 0.462860 0.053926 0.4832146 0.462862 0.053924 0.4832157 0.462862 0.053923 0.483215 Powers of the Transition Matrix for JPM:    P=?(0.488095&0.047619&[email protected]&0.107865&[email protected]&0.050213&0.470751)    P^2=?( 0.482048&0.051692&[email protected]&0.055266&[email protected]&0.051865&0.466245)             P^3=?(  0.481873&0.051943&[email protected] 0.481748&0.052154&[email protected] 0.481866&0.051953&0.466181)              P^4=?(  0.481864&0.051958&[email protected] 0.481856&0.051970&[email protected] 0.481864&0.051958& 0.466178)                      P^5=?(  0.481863&0.051959&[email protected]  0.481863&0.051959&[email protected]  0.481863&0.051959&0.466178)After a period of 5 years, equilibrium distribution that does not depend upon the starting conditions is attained. This is shown in P^5 with all the rows having similar entries. This convergence of P^T, where T is the number of years, means that for T greater than or equal to 5years, no matter which state we start in we always have the following probabilities: The probability of the share price decreasing (state SPD) is 0.481863. The probability of the share price remaining unchanged (state SPU) is 0.051959 The probability of the share price increasing (state SPI)  is  0.466178If it is equally likely that the share price can start in a state at the present, then the probability distribution (?) of the states is  ?=(1/3   1/3   1/3).The probability distribution of the states after 1 year is  (1/3  1/3  1/3)P=(1/3  1/3  1/3)?(0.488095&0.047619&[email protected]&0.107865&[email protected]&0.050213&0.470751)=0.472190   0.068566   0.459245The probability distribution of the states after 2 years is   (1/3  1/3  1/3) P^2=(1/3  1/3  1/3)?( 0.482048&0.051692&[email protected]&0.055266&[email protected]&0.051865&0.466245)=0.481284   0.052941   0.465775The probability distributions of the states up to the next 7 years were similarly calculated and the results are shown in Table 7.  Table 7: The Probabilities of the Share Price Decreasing, Remaining the Same and Increasing ProbabilityYears from now Decreasing Remaining the same Increasing1 0.472190 0.068566 0.4592452 0.481284 0.052941 0.4657753 0.481829 0.052017 0.4661544 0.481861 0.051962 0.4661775 0.481863 0.051959 0.4661786 0.481863 0.051959 0.4661787 0.481863 0.051959 0.466178Comparing the long-run share price movement of the two banksThe long-run performance of the two banks is shown in Table 8. The table reveals the following: The probability of a bank share price depreciating or appreciating in the long-run is approximately equal to 0.5. This means that, given a particular state of the share price, there is an equal likelihood that the share price will either decrease or increase in the long-run (five years for BOA and seven years for JPM). The probability that the share price will remain the same is very small.Table 8: Long-Run Performance of the Two BanksProbability of the share price BOA JPMDecreasing 0.462862 0.481863Remaining the same 0.053923 0.051959Increasing 0.483215 0.466178 Conclusions and Future WorkIn this study, Markov chains model was used to analyze and predict the probability of the stock price movements for BOA and JPM. The following are the findings from this research work: From the derived transition matrices for the individual banks, it is possible to predict the probability of moving from a given state to another state for a particular step in years. This is shown in Table 6 and Table 7. Despite the current state of the bank share price, it is possible to predict the long-run probabilities of the share price decreasing, remaining unchanged and increasing. This is shown in Table 8. It is possible for an investor to have a foreknowledge that the probability of a bank share price decreasing or increasing in the long-run is 0.5. Therefore, an investor who buys a share today has equal possibility of the share price appreciating or depreciating by 2024 (steps of 7 years from now) for BOA or 2022 (steps of 5 years from now) for BOA. The long-run probability of BOA shares remaining the same is 0.053923  while that of JPM is 0.051959.As stated earlier, this research focused on same day open and close prices. Further work can be extended focusing on: Next day open share price to the previous day close price. Next day close share price to previous day close share price Next day open share price to previous day open share price. Interaction of all Scenarios. Application for Markov Chain to the Cryptocurrency Market. ReferencesAnvwar, B. and Philip, S. (1997). Quantitative Methods for Business Decision 14th Edition. International Thompson Business Press, Canada.Gholamiangonabadi D, Mohseni Taheri SD, Mohammadi A, Menhaj MB, editors. Investigating the performance of technical indicators in electrical industry in Tehran’s Stock Exchange using hybrid methods of SRA, PCA and Neural Networks. Therm Power Plants IEEE 2014; 2014:75–82.Guresen E, Kayakutlu G, Daim TU. Using artificial neural network models in stock market index prediction. Expert Syst Appl. 2011; 38(8):89–97.Huang W, Nakamori Y, Wang S. Forecasting stock market movement direction with support vectormachine. Comput Oper Res. 2005; 32(10):13–22.Kara Y, Boyacioglu MA, Baykan ÖK. Predicting direction of stock price index movement using artificial neural networks and support vector machines: The sample of the Istanbul Stock Exchange. Expert Syst Appl. 2011; 38(5):11–19.Lee T, Chiu C. Neural network forecasting of an opening cash price index. Int J Syst Sci. 2002; 33(3):29–37.Ross, M. (2010) Introduction to Probability Models 10th Edition. Academic Press publications, USA.Ticknor, J. (2013). “A Bayesian regularized artifical neural network for stock market forecasting”. In: Expert Systems with Applications 40.14, pp. 5501–5506. AppendixM-fileThe code will terminate when the rows of Tn are equal up to the specified decimal places.% Bank of Americaformat longT=0.474083,0.044248,0.481669;0.398268,0.149351,0.452381;0.459322,0.052542,0.488136 for n = 2:100  %assumed max value of n is 100    n   Tn = T^n     L=min(Tn);     H=max(Tn);     A=abs(H-L);       G=max(A);   if G < 0.000001  % decimal places assumed      break  endend% J.P. Morganformat longT=0.488095,0.047619,0.464286;0.449438,0.107865,0.442697;0.479036,0.050213,0.470751for n = 2:100   %assumed max value of n is 100    n   Tn = T^n     L=min(Tn);     H=max(Tn);     A=abs(H-L);    G=max(A);   if G < 0.000001   % decimal places assumed      break  endend

x

Hi!
I'm Dianna!

Would you like to get a custom essay? How about receiving a customized one?

Check it out