Predicting Stock Prices - Worcester Polytechnic Institute

MQP HS1 3699

Predicting Stock Prices

A Major Qualifying Project Report Submitted to the Faculty of the

WORCESTER POLYTECHNIC INSTITUTE In partial fulfillment of the requirements for the

Degree of Bachelor of Science by

__________________________________ Shuchi S. Mitra

__________________________________ Michael J. Riggieri

APPROVED: __________________________________________________ Professor Hasanjan Sayit, Advisor

January 27, 2011

Abstract

Page |2

Using the stochastic processes called Markov Chains, we sought out to predict the immediate future stock prices for a given company. We found the moving averages for the data and the grouped them into four different states of results. We then applied Markov Chain calculations to the data to create a 4x4 transitional probability matrix. Using this transition matrix we solved a system of equations and found four steady states that were variables that represented the probability that a stock price for a given day would fall into one of the four states. When we use this information we can apply our actual

data to these equations and predict the next stock prices for the near future. We were able to successfully predict the next few days of stock prices using this method.

Page |3

Table of Contents

1. Introduction ..................................................................................................................................................4 2. Background ...................................................................................................................................................5

2.1 Markov Chains............................................................................................................................................6 2.2 Transition Probabilities ..............................................................................................................................6

2.2.1 Chapman-Kolmogorov Equations............................................................................................................7

2.2.2 Transition Matrix.......................................................................................................................................8 2.2.3 State Transition Diagrams........................................................................................................................8 2.3 Categorizing States of Markov Chains........................................................................................................9 2.3.1 Transient States.........................................................................................................................................9 2.3.2 Recurrent States and Absorbing States..................................................................................................10 2.3.3 Periodicity and Ergodicity.........................................................................................................................10 2.4 Properties of Markov Chains in the Long Run..................................................................................................12

2.4.1 Steady State Probabilities........................................................................................................................12 2.4.2 Applying Steady State Probabilities to the Transition Matrix............................................................13 2.5 First Passage Times..................................................................................................................................13

2.6 Stock Terminology.................................................................................................................................................15

3. Methodology...............................................................................................................................................16 3.1 Procedural Overview......................................................................................................................................16 3.2 Procedure and Project....................................................................................................................................18

4. Observations ...............................................................................................................................................44 5. Conclusions...............................................................................................................................................................45 6. Bibliography.............................................................................................................................................................47 7. Appendices...............................................................................................................................................................48

Page |4

1. Introduction

In our project, we were asked to analyze a year's worth of stock portfolio for a company and apply moving averages and Markov Chains to the data in hopes to predict the stock prices for the near future. We chose Google, as it is a company that everyone knows and the stock price data was well diverse and had enough information for many applications of moving averages.

The first thing we did was to apply moving averages to create an approximate evaluation of the data. In order to find moving averages, we first had to apply a moving average with an increment of five. This involves taking the sum of five days of stock and then dividing it by five. However, one can only do this starting at day five, because there was enough data to actually create a moving average. We eventually had a data set that included a moving average price and a closing price. We then needed to find a difference data set to apply Markov Chains too. We took the difference of the closing price and the moving average price. These differences were going to be what we applied Markov Chains too.

However, we first had to group the differences into four blocks. The reason why we did this was to create more accurate observations that it makes it more exact when we analyze the data. We then create a transition matrix. The entries in the matrix represented how many times the data points go from one block to another. This leads to 16 observations of data. For example, the first row of entries the matrix represents the number of times the data goes from the first block and stays in the first block, the number of times the data goes from the first block to the second block, the number of times the data goes from the first block to the third block, and the last entry of the row represents the number of times the data goes from the first block to the fourth block. All entries needed to be in decimal form, so the total number of observation points divided each entry.

With the matrix, we could now apply Markovian properties to our data. In other words, using Markovian properties we created a system of equations with the unknown variables being our steady states that we are aiming to obtain. These equations are sums of probabilities multiplied by our

Page |5

unknown variables. We then aimed to solve the system of equations to find our steady state probabilities.

With our steady state probabilities we were now able to predict where each immediate stock price can fall into an interval. These probabilities are now good indicators of where the stock prices will fall. We then observed the new data and made some observations. We noticed that a moving average with an interval of 5, was too small and it's resulting steady states were too close together to see an actual difference in intervals. We then increased it to an interval of 10 and found that there was an improved steady state differences, but still a little close. We were able to predict what the possible price range for a given day could be, but we also came to the conclusion that only four interval blocks may have not been a large enough selection. However, due to time constraints, if we did increase the number of blocks, there would be issues in completing the project on time. In conclusion, applying Markov Chains is an effective way to predict stock prices, but one needs to create a large enough intervals to get better results.

2. Background

2.1 Markov Chains

A Markov Chain is a stochastic process that has the Markovian property. Definition 1.1: A stochastic process is defined to be an indexed collection of random variables {Xt}, where the index t runs through a given set T, generally labeled with the set of nonnegative integers. The variable Xt is meant to represent a measurable characteristic, or point of interest. For example, if one were to look at a collection of muffins, some with blueberries and some without blueberries, the variable Xt can be used to label muffins with blueberries. Supposedly, if there were four blueberry muffins within a given collection, the set Xt could be designated as the set of blueberry muffins, with each muffin labeled as X1, X2, X3, or X4.Thus, it is evident from this example that stochastic processes are discrete collections of random variables.

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download