20
1 ECE 529 Digital Signal Processing Project Report On Stock Market Analysis Using Adaptive Filters By Priyanka Goswami May 2017 Department of Electrical and Computer Engineering The University of Arizona

Stock analysis report

Embed Size (px)

Citation preview

Page 1: Stock analysis report

1

ECE 529 Digital Signal Processing

Project Report

On

Stock Market Analysis Using Adaptive Filters

By

Priyanka Goswami

May 2017

Department of Electrical and Computer Engineering

The University of Arizona

Page 2: Stock analysis report

2

CONTENTS

Abstract

1.1 Introduction

1.2 Adaptive Prediction Algorithms for Market Analysis

1.2.1 Kalman Filter

1.2.2 Multiple Linear Regression

1.2.3 Hybrid Adaptive Filters

1.2.4 Chaikin Oscillator

1.2.5 Bollinger Bands

1.3 Implementation of Prediction Algorithms

1.4 Result and Analysis

Conclusion

References

Page 3: Stock analysis report

3

ABSTRACT

With the substantial increase in the amount of data collected all over the world form various

stock markets, it has become impossible to use traditional statistic and mathematical calculation

for analyzing the data and using it for predicting trends like the opening and closing prices or highs

and lows of the day for a company stock. Another crucial factor is the speed at which the data is

generated. Hence it has become important to use concepts of digital signal processing for carrying

out this type of analysis and prediction. Over the years many diverse types of filter and prediction

algorithms have been developed which can, with a high amount of accuracy, predict stock market

trends.

This project will involve studying some of the popular filters and prediction algorithms used

for stock market analysis and how they have been modified over the years to improve performance.

This includes evaluating the techniques based on performance parameters such as speed,

complexity and accuracy of prediction. In the next stage, some of the above algorithms will be

implemented in MATLAB and their performance will be analyzed using recent stock market data

of some popular companies. In the last section, an overall analysis of the results achieved will be

discussed followed by conclusion.

Page 4: Stock analysis report

4

1.1 Introduction

Prediction algorithms have been a part of mathematical statistics since long and generally

involved complex manual calculations that were time consuming, even for a small dataset. But

from the late 1900’s with the increase in use of computers for defense based applications, there

was a need for prediction algorithms that were more suited to the recent technology. This was

further motivated by the fact that there was a significant increase in the data being collected

(especially from radars), thus making it impractical to use traditional statistics. With this data being

available in digital form, it became apparent that there was a need for digital prediction techniques

that could utilize the available computation resources [1]. In 1960, R.E. Kalman introduced a new

linear prediction algorithm, now known as the Kalman Filter. Since then many different prediction

algorithms have been developed, based on the principles of probability and statistics from

mathematics, but adapted for processing substantial amounts of digital data.

With the advent of globalization in the late half of 20th century and growth and digitization of

financial markets all over the world, these prediction algorithms were applied for market analysis

and predicting stock market trends. Additionally, since most stock market data can be viewed as

discrete signals (values sampled at regular time intervals like hourly, daily, monthly or yearly), it

was easy to adapt existing filter techniques for stock market analysis. But it additionally his

required the algorithms to have the following two main characteristics:

• Accuracy – This was vital since most stock market predictions need to be done in real

time and they need to be accurate and precise, else it could lead to major financial

losses. To ensure this, it was necessary that the filters are not static and can adapt to

numerous factors and changes in real time and accordingly make predictions. This

meant that the prediction algorithms needed to use feedback and this lead to

development of Adaptive Filters.

• Speed and Ability to process large data – The stock market trends depend on a large

no. of factors like history of the stock prices, previous day closing prices, opening

prices, day highs and lows as well as external factors like market trends of different

countries, etc. All this translates to large amount of data that must be processed in a

limited time to make effective predictions.

The project will focus on the use of adaptive filters for analyzing stock market trends. Adaptive

filters are recursive and use feedback to perform error correction. This makes them suited for

making accurate predictions, as they can factor in the market volatility. The market data is

generally available in the form of charts (histograms, pie charts, etc.) or in time series form, for a

stock. An efficient adaptive filter can be used to determine/ predict the market trends a stock, with

certain a high probability of successful trend prediction, which can help investors take guided

decisions. One approach for this is to predict the opening and closing prices of stocks, based on

previous data, that has been collected over months or years. The project will involve studying and

Page 5: Stock analysis report

5

some popular adaptive filters and carrying out an analysis based on performance (speed,

complexity and accuracy of prediction) such as the Adaptive Kalman Filter, Multiple Linear

Regression, Normal Equation Method, Least Mean Square and Recursive Least Squares and

Chaikin Oscillator algorithms. Additionally, a study of Adaptive Hybrid Filters will also be done

to determine its advantages over the previously described algorithms.

Based on the above study, some of the algorithms like Adaptive Kalman Filter, Multiple Linear

Regression, etc. will be developed and implemented in MATLAB. For carrying out the analysis,

stock market data (daily opening and closing prices, daily high and low prices and volume of trade)

for a fixed period (1 year) will be used. The aim of the project will be to determine the most

optimum filter that can be used for stock market analysis and prediction.

1.2 Adaptive Prediction Algorithms for Market Analysis

Adaptive filters are a class of digital filters, that adjust their coefficients, to adapt to changes

in the signal, by using a form of feedback mechanism. They are essential for systems with unknown

specifications or having some form of volatility that is time varying. Using the feedback, they can

identify the error and accordingly change their response, according to the changes in input signal.

This makes them highly adapt for stock market analysis. The figure below shows a simplified

model of an adaptive filter. In the system, x(k) is the input signal and y(k) is the system output.

Using feedback loop the error signal e(k) is generated, where e(k) = d(k) – y(k), where d(k) is the

desired system output.

Figure. 1 Block diagram of simple Adaptive Filter [15]

This section will include a brief description about the different adaptive prediction algorithms

like the Kalman Filter, Multiple Linear Regression, Normal Equation Method, Least Mean Square,

Recursive Least Square. These prediction algorithms were chosen based on previously published

work [1], [2], [3], [4], [11] and are some of the popular algorithms used for stock market analysis.

This will also include a brief study about Hybrid Adaptive Filters and the performance

Page 6: Stock analysis report

6

improvements achieved by them. A brief description about Chaikin Oscillators and Bollinger

Bands and their use and importance in stock market analysis will also be included.

1.2.1 Kalman Filter

The Kalman Filter [5], published in 1960 and named after its inventor R E. Kalman, is a

recursive algorithm used for the discrete data linear filtering problem by minimizing the estimated

error covariance [6] and can be used to track any moving target and predict its future position from

previous measurements, even if noise is present [2]. It consists of set of equations that can be used

as a predictor and error corrector and has a wide variety of applications like motion tracking and

analysis, navigation, position estimation, feature tracking and financial analysis.

The discrete Kalman filter algorithm consists of two main steps – Time Update and

Measurement Update. In the equations, 𝐴 is a 𝑛 𝑥 𝑛 matrix describing the previous state of the

system while 𝐵 describes the effect of input on the output of the system. The variables 𝑤(𝑘)and

𝑣(𝑘) are random variables, representing the process and measurement noise.

• The Time Update Equations – This involves computing and forwarding the current system

state and the error covariance [6]. These values are used to get an estimate for the next time

step. These are considered as the predictor equations. The governing equations are shown

below –

𝑥′𝑘 = 𝐴 𝑥′𝑘−1 + 𝐵 𝑢𝑘 𝑎𝑛𝑑 𝑃′𝑘 = 𝐴 𝑃𝑘−1 𝐴𝑇 + 𝑄 𝐸𝑞𝑛. (1)

• The Measurement Update Equations – These equations are responsible for adding the new

measurements (obtained from a feedback mechanism) to the value calculated in the previous

step to give a more accurate result. These are the error corrector equation. The governing

equations are shown below –

𝐾𝑘 = 𝑃′𝑘 𝐻𝑇 (𝐻 𝑃′

𝑘 𝐻𝑇 + 𝑅)−1 ; 𝑥𝑘 = 𝑥𝑘′ + 𝐾𝑘 (𝑧𝑘 − 𝐻 𝑥𝑘

′ ) 𝑎𝑛𝑑

𝑃𝑘 = (𝐼 − 𝐾𝑘 𝐻)𝑃𝑘′ 𝐸𝑞𝑛. (2)

The two steps are executed in a feedback loop shown below in figure 2.

Page 7: Stock analysis report

7

Figure 2. The Kalman Filter Algorithm

1.2.2 Multiple Linear Regression

Multiple Linear Regression is a statistical analysis technique used to determine the relationship

between two or more “explanatory variables” and a “response variable” by using a linear equation

[7]. The response variables and the explanatory variables are related to each other like the opening

price and the highest price of the stock on a day (explanatory variables) and the closing price (the

response variable). The linear equation is of the following form:

𝑦 = 𝛼0 + 𝑥1 𝛼1 + 𝑥2 𝛼2 + ⋯ + 𝑥𝑛 𝛼𝑛 𝐸𝑞𝑛. (3)

where y is the response variable, x is the explanatory variable, n is the no. of observations and

α are coefficients used for curve fitting of the population regression line and computed using

statistical software.

The Normal Equation Method is similar to Linear Regression (using a single explanatory

variable), but uses a 𝑚 𝑥 𝑛 matrix, where m is the number of training variables and n is the number

of independent variables [3]. The main difference between Multiple Linear Regression and The

Normal Equation method, in terms of computation, is that Normal Equation takes less number of

iterations to converge as it uses the least square estimation. The Multiple Linear Regression takes

multiple iterations to converge as it uses gradient descent technique. But as discussed in [3], the

Multiple Linear Regression gives more accurate predictions as compared to Normal Equation.

1.2.3 Least Mean Square Adaptive Filter

The Least Mean Square (LMS) is one of the most popular adaptive filter algorithms because

of it slow complexity, fast convergence and stable behavior [8]. It was first introduced in 1959 by

Widrow and Hoff. It uses multiple iterations to reduce the minimum mean square error by

correcting the weight matrix using gradient descent. The figure below shows the LMS algorithm

with transversal filter.

Time Update

Equations

Measurement Update

Equations

Page 8: Stock analysis report

8

Figure 3. The Least Mean Square Adaptive Filter algorithm [9].

It uses the FIR Least Mean Square filter, that is similar to the Weiner filter [5], but does not

use auto – correlation. It consists of the following main components – the input signal x(n), the

weight vector w, the filtered output y(n) and the error signal e(n) = d(n) – y(n). The concerning

equations are –

y(n) = = w * x(n) and e(n) = d(n) – y(n) Eqn. (4)

In comparison to the LMS adaptive filter, the Recursive Least Squares (RLS) algorithm

computes the filter coefficients by computing the minimum of sum of the | e(n) |, i.e. the error

signal. RLS gives a better performance in time varying conditions, but for most market stocks,

unless affected by external factors, most major company stocks show a uniform performance over

longer time periods. Additionally, the RLS algorithm is highly complex and not stable in nature

[4].

1.2.4 Chaikin Oscillator

The Chaikin Oscillator was developed by Marc Chaikin in the 1970s and is extensively used

in stock market analysis to predict the future performance of a stock i.e. if it will be bullish (an

upward stock trend) or bearish (a downward stock trend). It uses the Accumulation/Distribution

momentum to indicate the future trends. The A/D is calculated using the stocks daily closing prices

C, daily high H and low prices L and the total volume V of stock traded in one day. The values are

calculated by subtracting a 10-day and a 3-day exponential moving average of the A/D line, i.e.

the Moving Average Convergence Divergence (MACD) [8]. The A/D is calculated as follows

[11]:

𝐴𝐷 = 𝑐𝑢𝑚𝑎𝑙𝑡𝑖𝑣𝑒 𝑡𝑜𝑡𝑎𝑙 𝑜𝑓 (𝐶−𝐿)−(𝐻−𝐶)

(𝐻−𝐿)∗ 𝑉 𝐸𝑞𝑛. (5)

Based on these values, it can be determined by investors and market analysts whether to sell

or buy a stock.

Page 9: Stock analysis report

9

1.2.5 Bollinger Bands

A trading tool invented in 1980s by John Bollinger, it is used for observing the volatility of a

stock based on historical data. The Bollinger bands are adaptive in nature and can be used for

different periods like short term (hourly, daily or weekly) or long term (monthly or yearly) to study

the general trading pattern of a stock and make informed decision.

The Bollinger Bands are computed over an n period moving average with the bands drawn

above and below at interval defined by the multiple of the standard deviation [12]. It basically

consists of three bands:

• The Middle Band which is the moving average (MA) of the stock prices taken over n

days.

• The Upper Band computed as (MA + Kσ) which gives the (maximum possible) higher

price ranges of the stock.

• The Lower Band computed as (MA – Kσ) which gives the (minimum possible) lower

price ranges of the stock.

σ is the standard deviation taken over n period and the typical values for n and K are 20 and 2 [13].

In 2010, Bollinger introduced two other indicators that could be used to make more accurate

analysis, the %b and the Bandwidth which are calculated as follows –

%𝑏 =(𝐿𝑎𝑠𝑡 𝑝𝑟𝑖𝑐𝑒−𝐿𝑜𝑤𝑒𝑟 𝐵𝑎𝑛𝑑)

(𝑈𝑝𝑝𝑒𝑟 𝐵𝑎𝑛𝑑−𝐿𝑜𝑤𝑒𝑟 𝐵𝑎𝑛𝑑) 𝐵𝑎𝑛𝑑𝑤𝑖𝑑𝑡ℎ =

(𝑈𝑝𝑝𝑒𝑟 𝐵𝑎𝑛𝑑−𝐿𝑜𝑤𝑒𝑟 𝐵𝑎𝑛𝑑)

𝑀𝑖𝑑𝑑𝑙𝑒 𝐵𝑎𝑛𝑑 𝐸𝑞𝑛. (6)

It has been observed that for most stocks [14], the prices are always between the two bands

and any “breakouts” are considered as unusual activity and caused due to external factors or

circumstances.

1.2.6 Hybrid Adaptive Filters

Hybrid Adaptive filters are a combination of transformation techniques like the Discrete

Cosine Transform along with the previously mentioned prediction algorithms. Some of the popular

hybrid adaptive filters used for different applications like reducing noise in wireless channel, color

images, etc., besides being applied for stock market analysis. Some of the popular Hybrid Adaptive

Filters are DCT – LMS and DCT – RLS. In the work published in [4], these filters are used for

carrying out market analysis, with the performance measured against adaptive filters like the

Kalman Filter, LMS and RLS, along with simple filters like the moving average filter. Based on

the analysis, it can be said that though more computationally intensive compared to adaptive filters,

hybrid adaptive filters give better performance and more accurate predictions for almost all the

stocks studied. Additionally, compared to conventional filters, adaptive filters give more accurate

predictions compared to conventional filters, especially for stocks showing sudden price changes

and high volatility over a time period.

In stock market analysis, investment firms and investors use a combination of these tools to

accurately predict stock market trends and make informed decisions. These digital signal

Page 10: Stock analysis report

10

processing algorithms have made it convenient to process enormous amounts of data in short time

periods (assuming sufficient computing resources are available).

1.3 Implementation of Prediction Algorithms

In this section, the implementation of some of the adaptive prediction algorithms discussed in

the above section. All the algorithms have been developed and implemented and analyzed using

MATLAB. For the study, initially a simple moving average filter is designed, followed by the

adaptive Kalman Filter and a combination of pre-filtering followed by adaptive Kalman filter is

used to compare performances. Then the Multiple Linear Regression filter (from the Statistical

and Machine Learning Toolbox) is implemented. The aim is to accurately predict the closing prices

of the stock for a day.

The Moving Average Filter takes the average of n-k days to predict the closing price of the

stock on day n. For the analysis, different values of k were used like 5, 10, 15 and 20. The code

for the main computation is shown below:

Figure 4. Computing Moving Average for a stock

The next filter implemented in MATLAB is the Adaptive Kalman Filter. The filter was

created based on Eqn. (1) and Eqn. (2) –

𝑥′𝑘 = 𝐴 𝑥′𝑘−1 + 𝐵 𝑢𝑘 𝑎𝑛𝑑 𝑃′𝑘 = 𝐴 𝑃𝑘−1 𝐴𝑇 + 𝑄 𝐸𝑞𝑛. (1)

𝐾𝑘 = 𝑃′𝑘 𝐻𝑇 (𝐻 𝑃′

𝑘 𝐻𝑇 + 𝑅)−1 ; 𝑥𝑘 = 𝑥𝑘′ + 𝐾𝑘 (𝑧𝑘 − 𝐻 𝑥𝑘

′ ) 𝑎𝑛𝑑

𝑃𝑘 = (𝐼 − 𝐾𝑘 𝐻)𝑃𝑘′ 𝐸𝑞𝑛. (2)

The values of A and B are set at 1 and 0.83, while Pk-1 is the variance of the closing prices and

𝑥𝑘−1′ is the mean of the closing prices take over a year. Figure 6 shows the main algorithm of the

Kalman filter.

Page 11: Stock analysis report

11

Figure 6. Adaptive Kalman Filter

The Multiple Linear Regression Filter was implemented using the regress (y, X) command

of MATLAB Statistical and Machine Learning Toolbox. For this filter, the daily opening and high

prices of the stock was used to predict the day’s closing price. In the command regress (y, X), y is

the matrix of responses and X is the matrix of predictors for corresponding responses. The output

is a set of coefficients for the filter, which is then used in a linear equation to predict the values of

the day’s closing price, shown below:

y_predict = b(1) + b(2)*x1 + b(3)*x2 + b(4)*x1.*x2;

Here, b(n) are the filter coefficients, x1 and x2 are the opening and daily high prices and

y_predict is the closing price

The next predictor implemented is the Bollinger Bands, which is developed using the

following equations:

Middle Band = Moving Average (MA) for n = 20

Upper Band = MA + Kσ Lower Band = MA – Kσ, K = 2 and σ = standard deviation.

The MATLAB implementation is shown in the figure below:

Page 12: Stock analysis report

12

Figure 7. Implementation of Bollinger Bands

Another predictor implemented is the Chaikin Oscillator, which is used more understanding the

trend rather than predict daily prices. If the oscillator gives values that are greater than 0, then it is

assumed that the stock will see an upward trend in the future, while values below 0 show a

downward trend. The stock’s closing price, daily high and low and the volume traded is used to

calculate the Accumulation/Distribution curve using the equation shown below and using that and

the command chaikosc (high, low, close, volume) is used to determine the final oscillator values.

𝐴𝐷(𝑘) = (𝐶𝑙𝑜𝑠𝑒(𝑘)−𝐿𝑜𝑤(𝑘))−(𝐻𝑖𝑔ℎ(𝑘)−𝐶𝑙𝑜𝑠𝑒(𝑘))

(𝐻𝑖𝑔ℎ(𝑘)−𝐿𝑜𝑤(𝑘))∗ 𝑉𝑜𝑙𝑢𝑚𝑒(𝑘)

In the next section, the results achieved using each predictor is shown and discussed.

1.2.4 Result and Analysis

For carrying out the analysis, stock market data (daily opening and closing prices, daily high

and low prices and volume of trade) for a fixed period (1 year) will be used, with the samples taken

daily. The stock prices of 10 companies from NASDAQ, New York Stock Exchange (NYSE) and

Dow Jones Stock Exchange are used for the project. The companies were chosen at random and 1

year trading history for these stocks were taken from www.google.com/finance and were available

in the form of Excel sheets. MATLAB command xlsread (filename, range) was used to transport

the data to MATALB and use for further analysis.

For the Moving Average Filter, the closing prices were predicted using different values of k,

and it is observed that for smaller values of k, the moving average filter gives a more accurate

prediction. It is the simplest filter that can be used and can be used for analyzing a small data set

within a brief period (like hourly or daily). Figure 8 shows the closing prices predicted by the

moving average filter for different values of k. The above observation can be also seen in the graph.

Page 13: Stock analysis report

13

Figure 8. Closing price of stock using Moving Average Filter

The Kalman filter showed high prediction accuracy for stock that were less volatile. Using

the difference between the current sample and one previous sample as the system noise improved

the performance substantially. For periods of high volatility or sudden transitions from high to low

prices or vice versa over a few days, caused the filter to make predictions lower than the actual

prices. Also, the filter worked better for a larger no. of samples. Figure 9 shows the actual closing

prices and the prices predicted by the filter, for four different stocks.

Page 14: Stock analysis report

14

Figure 9. Daily closing prices predicted using Kalman Filter

To observe the effects of pre-filtering on prediction accurach, the Kalman Filter was

implemented along with a simple moving avg pre – filter. Altohough the response was improved

for periods of sudden volatility and a smoother curve was achived, the overall accuracy decreased.

Figure 10 shows the closing price predicted using moving average prefilter and Kalman Filter.

Figure 10. Comparison of predicted closing prices (with and without pre-filtering)

The Multiple Linear Regression Filter, although having a higher complexity compared to

the Kalman filter, gives much more accurate predictions for the closing prices, even for periods of

high fluctuations and this can be seen in figure 11.

Page 15: Stock analysis report

15

Figure 11. Closing prices predicted using the Multiple Linear Regression Filter

The Bollinger Bands and Chaikin Oscillators are used for studying the market or stock trends

and based on that decide if a stock should be bought or sold. The Bollinger band width depends

on the number of steps taken from the standard deviation. For higher values of K, the bandwidth

of the bands increases. Since none of the stocks analyzed had sudden changes, the prices were

within the range. The Bollinger Bands were also used to check if the prices predicted, lied within

the acceptable range. Figure 12 shows the Bollinger bands for two stocks.

Page 16: Stock analysis report

16

Figure 12. Bollinger Bands for the daily closing prices of two stocks

Figure 13 shows the Chaikin Oscillator and the closing prices of two stocks. As seen in the

highlighted region, when the oscillator values go above 0, an increasing trend is seen and when

below 0 a decreasing trend is seen. This trend is not for a single day’s closing price, but rather over

a period of time. The term “increase” and “decrease” is also with respect to a series of previous

values. The Chaikin Oscillator and Bollinger Bands can accurately predict stock market trends,

unless some sudden external factor causes the stock price to fluctuate higher than usual.

Figure 13. Chaikin Oscillator of two stocks and the closing price trends

For analyzing the prediction accuracy between Kalman Filter and Multiple Linear Regression

Filter, the mean of difference between the actual closing price and the predicted price was taken.

This was done since for stocks with higher values, the error would also be higher and so a single

fixed value cannot be used for comparing all the stocks. A fixed period of 200 days was taken, to

maintain uniformity for all the stocks, as for some stocks, the total number of days of trading was

different. The algorithm for calculating the percent of correct predictions is shown below:

Page 17: Stock analysis report

17

Figure 12. Calculating the accuracy of prediction

The table below shows the mean of difference between actual and predicted closing prices of

stocks and the % accuracy for Kalman and Multiple Linear Regression.

Stock Mean of diff. of daily actual and

predicted closing price (in $)

Accuracy of prediction (%)

Kalman MLR Kalman MLR

Company 1 0.84 0.46 50.22% 78.79%

Company 2 0.27 0.18 50.65% 67.96%

Company 3 0.48 0.32 49.78% 72.29%

Company 4 4.07 3.51 51.51% 51.95%

Company 5 1.64 0.97 44.15% 77.92%

Company 6 0.50 0.37 53.91% 62.61%

Company 7 0.16 0.13 51.30% 55.65%

Company 8 1.36 1.15 51.30% 54.35%

Company 9 8.89 6.48 50.87% 66.96%

Company 10 3.74 1.39 57.83% 82.17%

Average Accuracy (%) 51.15% 67.07%

Table 1. Analysis of Adaptive Kalman Filter and Multiple Linear Regression Filter

From the above data, it can be observed that the Multiple Linear Regression (MLR) filter has

a higher prediction accuracy compared to the Kalman Filter. The average accuracy of prediction

is higher for the MLR filter compared to Kalman. Additionally, for stocks showing less variations,

Kalman and MLR give comparable prediction accuracy, like for Company 4 in Table 1 the

accuracy is 51.51% and 51.95% for Kalman and MLR respectively. As seen in figure 13, although

Page 18: Stock analysis report

18

there is increase and decrease in the stock price, there are no sudden drastic changes and the actual

change in stock price is less compared to the stock value.

Figure 13. Overall analysis of daily closing price for Company 4

Page 19: Stock analysis report

19

CONCLUSION

Prediction algorithms have become an important part stock market analysis and are extensively

used by investors, stock analysts and investment firms to accurately predict stock market trends

and stock prices. The discrete form of the market data makes it adapt for such digital processing.

Also, these prediction algorithms have been designed for processing substantial amounts of digital

data with high accuracy, since a wrong prediction can result in financial losses amounting to

billions of dollars.

Adaptive filters are recursive and use feedback to perform error correction. This makes them

suited for making accurate predictions, as they can factor in the market volatility. An efficient

adaptive filter can be used to determine/ predict the market trends a stock, with certain a high

probability of successful trend prediction, which can help investors take guided decisions. One

approach for this is to predict the opening and closing prices of stocks, based on previous data,

that has been collected over months or years. In the project, some popular adaptive filters were

studied and analyzed based on performance (speed, complexity and accuracy of prediction) such

as the Adaptive Kalman Filter, Multiple Linear Regression, Normal Equation Method, Least Mean

Square and Recursive Least Squares and Chaikin Oscillator algorithms. Additionally, a study of

Adaptive Hybrid Filters will also be done to determine its advantages over the previously described

algorithms.

Based on the above study, Moving Average Filter, Adaptive Kalman Filter, Multiple Linear

Regression Filter, Bollinger Bands and Chaikin Oscillator were developed and implemented in

MATLAB. For carrying out the analysis, daily stock market data, over a period of 1 year, of 10

companies belonging to different stock exchanges was used. The aim of the project was to

determine the most optimum filter that can be used for stock market analysis and prediction. Based

on the analysis carried out the Multiple Linear Regression filter gives a higher prediction accuracy

compared to the Kalman filter, especially for stock having high volatility.

Additionally, using the different filter predictions and the Chaikin Oscillator, the overall

project developed in MATLAB can be used as a complete package to carry out accurate and

efficient stock market analysis and trend study.

Page 20: Stock analysis report

20

REFERENCES

[1]. Rick Martinelli, “Market Data Prediction with an Adaptive Kalman Filter”, Haiku

Laboratories, December 1995, [online]: ww.haikulabs.com/mdpwakf.htm

[2]. Rick Martinelli and Neil Rhoads, ‘Predicting Market Data with a Kalman Filter”, Haiku

Laboratories, 2009, [online]: http://www.haikulabs.com/pmdwkf26.htm

[3]. S. Iyer, N. Kamdar, B. Soparkar, “Stock Market Prediction using Digital Signal Processing

Models”,

International Journal of Computer Applications (0975 – 8887), pp. 35 – 39, [online]:

www.ijcaonline.org

[4]. B. B. Nair et al., "Application of hybrid adaptive filters for stock market prediction," 2010

International Conference on Communication and Computational Intelligence (INCOCCI),

Erode, 2010, pp. 443-447

[5]. Kalman, R.E., "A new approach to linear filtering and prediction problems", ASME

Transactions, Series D, 82, 35-45, (1961)

[6]. Greg Welch, Gary Bishop, An Introduction to the Kalman Filter, University of North Carolina

at Chapel Hill, Chapel Hill, NC, 1995

[7]. Multiple Linear Regression, [online]: http://www.stat.yale.edu/Courses/1997-

98/101/linmult.htm

[8]. N. Sireesha, K. Chithra and T. Sudhakar, "Adaptive filtering based on least mean square

algorithm," 2013 Ocean Electronics (SYMPOL), Kochi, 2013, pp. 42-48.doi:

10.1109/SYMPOL.2013.6701910

[9]. Giovanis, Eleftherios, “Applications of Least Mean Square (LMS) Algorithm Regression in

Time-Series Analysis”, (August 28, 2010), [online] : https://ssrn.com/abstract=1667440 or

http://dx.doi.org/10.2139/ssrn.1667440

[10]. Chaikin Oscillator, [online]:http://www.investopedia.com/terms/c/chaikinoscillator.asp

[11]. Chaikin Stock Research, [online]: https://en.wikipedia.org

[12]. John Bollinger, “Bollinger Bands”, [online]: https://www.bollingerbands.com/bollinger-

bands

[13]. “Bollinger Bands”, [online]: https://en.wikipedia.org/wiki/Bollinger_Bands

[14]. “Bollinger Bands”, [online]: http://www.investopedia.com/terms/b/bollingerbands.asp

[15]. Paulo S.R. Diniz, Adaptive Filtering Algorithms and Practical Implementation, 3rd ed., New

York: Springer Science+Business Media, 2008

[16]. MATLAB Documentation, [online]: www.mathworks.com

[17]. Stock Data from https://www.google.com/finance