0% found this document useful (0 votes)
67 views

A Project Report: Submitted in Partial Fulfillment For The Award of The Degree of

This document is a project report submitted for a degree in soft computing. It aims to implement an artificial neural network to predict stock market prices. Specifically, it uses a recurrent neural network with long short-term memory. The report includes an introduction outlining the use of neural networks for stock prediction and an abstract. It then discusses the methodology, literature review, and aims to design a neural network model to forecast stock prices based on historical data.

Uploaded by

Shikhar Gupta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
67 views

A Project Report: Submitted in Partial Fulfillment For The Award of The Degree of

This document is a project report submitted for a degree in soft computing. It aims to implement an artificial neural network to predict stock market prices. Specifically, it uses a recurrent neural network with long short-term memory. The report includes an introduction outlining the use of neural networks for stock prediction and an abstract. It then discusses the methodology, literature review, and aims to design a neural network model to forecast stock prices based on historical data.

Uploaded by

Shikhar Gupta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 18

A PROJECT REPORT

Final Report

Submitted in partial fulfillment for the award of the degree of

B.Tech

in

ITE1015: SOFT COMPUTING


SLOT-F1+TF1
By

SHIKHAR GUPTA
(17BIT0081)

SHREEYANSH
(17BIT0214)

Under the guidance of

PROF. TAPAN KUMAR DAS


TOPIC
“PREDICTING STOCK MARKET PRICES USING
ARTIFICIAL NEURAL NETWORK (Recurrent Neural Network
(RNN) – Long Short-Term Memory)”

ABSTRACT

In this project we attempt to implement an Artificial Neural Network


approach to predict stock market prices. Artificial Neural networks are
very effectively implemented in forecasting stock prices, returns, and
stock modeling, and the most frequent methodology is the Back-
propagation algorithm. Prediction of financial markets has long been
an attraction in the minds of equity investors. Technical Analysis
provides a framework for studying investor behavior and generally
focuses only on price and volume data.

INTRODUCTION

In this project we attempt to implement an Artificial Neural Network


approach to predict stock market prices. Artificial Neural networks are
very effectively implemented in forecasting stock prices, returns, and
stock modelling, and the most frequent methodology is the Back-
propagation algorithm. Prediction of financial markets has long been
an attraction in the minds of equity investors. Technical Analysis
provides a framework for studying investor behavior and generally
focuses only on price and volume data. Typically, traders using this
type of approach concern themselves chiefly with timing and are
generally unaware of a company’s financial health. Traders using this
approach have short-term investment horizons and access to only price
and exchange data. With the advent of powerful computers much
attention has been focused on this field. Equity market prices depend
on many influences. Key factors that influence future equity prices can
be broadly divided into quantitative and qualitative types. Primary
quantitative factors include open rate, high rate, low rate, close rate
and volume for individual equities. Qualitative factors include
socioeconomic, political, international, regional and performance
factors to name but a few. The ability of neural networks to learn from
training data has not been overlooked and as such neural networks
have been applied to a range trading market applications of equity
markets. Equity market prices depend on many influences. Key factors
that influence future equity prices can be broadly divided into
quantitative and qualitative types. Primary quantitative factors include
open rate, high rate, low rate, close rate and volume for individual
equities. Qualitative factors include socioeconomic, political,
international, regional and performance factors to name but a few. Due
to the difficulty in accurately retrieving and quantifying historical
qualitative factors, network inputs used in the model presented here
have been confined to readily available quantitative data. However,
from quantitative factors the key qualitative factor of the market
sentiment can be derived. Market sentiment tells us if the market is
bullish, where high of confidence and rising prices prevail, or bearish,
where there is a lack of investor confidence and prices are in decline.
Thus historical data quantitatively reflects qualitative market
sentiment to some extent, which in turn should give indication of
future price movements.

MATLAB OVERVIEW

The name MATLAB stands for matrix laboratory. MATLAB is a


high-performance language for technical computing. It integrates
computation, visualization, and programming in an easy-to-use
environment where problems and solutions are expressed in familiar
mathematical notation.MATLAB is an interactive system whose basic
data element is an array that does not require dimensioning. This
allows solving many technical computing problems, especially those
with matrix and vector formulations, in a fraction of the time it would
take to write a program in a scalar noninteractive language such as C
or FORTRAN. The reason we have decided to use MATLAB for the
development of this project is its toolboxes. Toolboxes allow learning
and applying specialized technology. Toolboxes are comprehensive
collections of MATLAB functions (M-files) that extend the MATLAB
environment to solve particular classes of problems. It includes among
others image processing and neural networks toolboxes.

AIM:

In this project we attempt to implement an Artificial Neural Network


approach to predict stock market prices. Artificial Neural networks are
very effectively implemented in forecasting stock prices, returns, and
stock modelling, and the most frequent methodology is the Back
propagation algorithm. We outline the design of the Neural Network
model with its salient features and customisable parameters.

METHODOLOGY:-

We outline the design of the Neural Network model with its salient
features and customisable parameters. We select a certain group of
parameters with relatively significant impact on the share price of a
company. With the help of statistical analysis, the relation between the
selected factors and share price is formulated which can help in
forecasting accurate results. Although, share market can never be
predicted, due to its vague domain, this project aims at applying
Artificial Neural Network in forecasting the stock prices.We
normalise inputs so that input values lies between 0 and 1. We develop
three modules. First module is used for calculating weights by using
back propagation algorithm.Second module is used to find the
predictable stock rate after denormalisation by using weights we got
from first module. Third module is used for getting buying and selling
signals from predicted stock rates and the available stock rates. We got
predicted stock rate from trained network with different hidden layers,
we generate signals to know whether that stock should be buy or sell
and then compare it with the actual stock rate signals on those trading
days. By this comparison we got correctness of our prediction. After
performing this experiment we got different results with their
correctness as shown.
Literature Review-

Detecting trends of stock data is a decision support process. Although


the Random Walk Theory claims that price changes are serially
independent, traders and certain academicians have observed
that there is no efficient market analysis method. The movements of
market price are random and not predictable.
The artificial neural networks (ANN) have proved to be efficient in
the prediction of future earnings as proved many researchers . The
variable to be predicted can be dichotomous realization of the change
in earnings per share, adjusted for the drift in the prior earnings
changes and the predictor variables used can be identified, in this
study,. The Multi-Layer Perceptron (MLP) feed-forward neural
network architecture was used, due to its suitability as a classifier
and its implementation simplicity on a sequential computer. In
contrast with prior applications of ANNs in accounting, and business
in general, this study also focused in the selection of an efficient
and robust training algorithm. The complexity and the size of the
problem, in combination with the scattered nature of pooled
accounting data, demanded that a training algorithm should guarantee
convergence without oscillations and be relatively fast in order to be
used in such a problem .
Martin Wallance presented in his study how Neural networks provide
forecasts of market prices and actions. These can then form the basis
for trading the market in an automated system. A pre-trained network
is the natural choice for real-time trading. The implementation of
forecasts requires a strategy for dealing with adverse market moves;
the question of when to enter or exit the market is also largely
determined by forecasts, hence neural networks always have a role
in finance.

Two kinds of neural networks, a feed forward multi-layer Perceptron


(MLP) and an Elman recurrent network, are used to predict a
company's stock value based on its stock share value
history. The experimental results show that the application of MLP
neural network is more promising in predicting stock value changes
rather than Elman recurrent network and linear regression method.
However, based on the standard measures that will be presented in the
paper we find that the Elman recurrent network and linear regression
can predict the direction of the changes of the
stock value better than the MLP.

Based on the Neural Network toolbox of MATLAB software, Ma,


Wang and Dong constructed the Single-input Prediction Model
(SlPM) and the Multi-input Prediction Model (MlPM) respectively to
predict the stock price. The aim of this paper is to compare the
accuracy of prediction respectively using the Single-input Prediction
Model (SlPM) and Multi-input Prediction Model (MlPM). BP neural
network can effectively predict the short-term trend of the stock
market. With the introduction of self adaptive learning rate method
and additional momentum method, the improved BP model has
obvious advantages compared to the basic model in the aspects of
convergence speed and prediction performance.

After completing several simulations for predicting several stocks


based on the past historical data using fuzzy neural network with the
Back-Propagation learning algorithm, it is conclusive that the average
error for simulations using lots of data is smaller than that using less
amount of data. That is, the more data for training the neural network,
the better prediction it gives. If the training error is low, predicted
stock values are close to the real stock values. After completing
several simulations for predicting several stocks based on the past
historical data using fuzzy neural network with the Back-Propagation
learning algorithm, it is conclusive that the average error for
simulations using lots of data is smaller than that using less amount of
data. That is, the more data for training the neural network, the better
prediction it gives. If the training error is low, predicted
stock values are close to the real stock values.

Survey of existing literature reveals that there are different types of


ANN models used for predicting the stock market. Many researchers
noted that slight parameter changed causes major variations in the
behaviour of the network. So there is no theory which could be
guideline for finding best network topology. Recently, Pratap and
Ambika proposed trigonometric functional link artificial neural
network (FLANN) model employs standard least mean square (LMS)
algorithm with search-then-converge scheduling. The network could
effectively calculate learning rate parameter that changes with time
and may require less experiments to train the model. Here FLANN is
used for long term as well as short term stock market prediction . This
covers up to a large extent, the study done on prediction of stock
market using artificial neural network. Still there is further scope for
the work which is presently being done in this field.

Dataset used-
Yahoo finance-

IMPLEMENTATION:-
MATLAB CODE:
Part 1: Data processing

clc
clear
all
close
all
C=csvread(strcat('CHO(1) (1).csv'),1,1);
% Opening stock value for the day
Open = C(:,1);
Open = Open.';
% Highest stock value for the day
High = C(:,2);
High = High.';
% Lowest stock value for the day
Low = C(:,3);
Low = Low.';
% Closing stock value for the day
Close = C(:,4);
Close = Close.';
% Simple Moving Average for 10 and 50 days
SMA_10 = tsmovavg(Open,'s',10);
SMA_50 = tsmovavg(Open,'s',50);
% Exponential Moving Average for 10 and 50 days
EMA_10 = tsmovavg(Open,'e',10);
EMA_50 = tsmovavg(Open,'e',50);
% Input vector of the input variables
Input = {Open; High; Low; SMA_10; EMA_10; SMA_50;
EMA_50}; Input = cell2mat(Input);

Part 2: Building the RNN


% Construction of feed-forward neural network net =
newff([minmax(Open); minmax(High); minmax(Low);
minmax(SMA_10);
minmax(EMA_10); minmax(SMA_50); minmax(EMA_50)], [abs(floor(7)),
1],{'purelin',
'purelin', 'transIm'},'traingdx');
% Maximum number of
iterations
net.trainparam.epochs =
8000; % Desired Tolerance
value net.trainparam.goal =
1e-5; % learning rate
initialisation
net.trainparam.lr = 0.001;
% using full data to train the neural
network net.divideFcn ='dividetrain';
net = train(net, Input, Close);
t = net(Input);
% eveluating the performance of the neural network - using mse as
% the measuring standard
perf = perform(net, Close,
t); view(net);
% Plot generation of the market
values x = 1:size(Close,2); plot(x,
Close, x, Open, x, High, x, Low);
legend(‘Close','Open','High','Low'
);

RNN PART 3 - MAKING THE PREDICTIONS AND


VISUALISING THE RESULTS
%% Testing the constructed neural network
% Opening sample test data
C_t = csvread(strcat('CHO(1) (1).csv'),1,1);
Open_t = C_t(:,1);
Open_t = Open_t.';
High_t = C_t(:,2);
High_t = High_t.';
Low_t = C_t(:,3);
Low_t = Low_t.';
Close_t = C_t(:,4);
Close_t = Close_t.';
ma=50;
SMA_10_t = tsmovavg(Open_t, 's', 10);
SMA_50_t = tsmovavg(Open_t, 's', 50);
EMA_10_t = tsmovavg(Open_t, 'e', 10);
EMA_50_t = tsmovavg(Open_t, 'e', 50);
Input_t = {Open_t; High_t; Low_t; SMA_10_t; EMA_10_t; SMA_50_t;
EMA_50_t}; Open_t = C_t(:,1);
Input_t = cell2mat(Input_t); %
Plotting the final output graph
answer = ones(1, size(Close_t,
2)); answer_t = ones(1,
size(Close_t, 2));
for i=1:size(Close_t, 2)
answer(i) = net([Input_t(1, i); Input_t(2,i); Input_t(3, i); Input_t(4, i);
Input_t(5, i);
Input_t(6, i); Input_t(7, i)]);
answer_t(i) = Close_t(i);
end
x = 1:size(answer(ma:end), 2);
plot(x, [answer(ma:end-50) answer(end-50:end-1)*NaN], x,
answer_t(ma:end)); axis([0 200 -2 2])
legend('Actual Value','PredictedValue')
xlabel('Data Points');
ylabel('Closing Stock Market Value');
title('Stock Market Prediction using Neural
Networks');
acc=corr(answer(ma:end)',answer_t(ma:end)');
pr=sprintf('Acc is %2f',acc); msgbox(pr)

OUTPUT:-
PLOT-
Inference

There are a number of time series techniques that can be implemented


on the stock prediction dataset, but most of these techniques require a
lot of data preprocessing before fitting the model.The predicted values
are of the same range as the observed values in the train set (there is
an increasing trend initially and then a slow decrease).

Application and Future Prospects


There are two prices that are critical for any investor to know: the
current price of the investment he or she owns, or plans to own and its
future selling price.
Despite this, investors are constantly reviewing past pricing history
and using it to influence their future investment decisions. Some
investors won't buy a stock or index that has risen too sharply, because
they assume it's due for a correction, while other investors avoid a
falling stock because they fear it will continue to deteriorate. Our
model makes it easier fro customers to wisely invest in the right
stocks.
Recently, a novel model named procedural neural networks, (PNNs)
was proposed to deal with data modeling problems, especially for
time series with huge data of multi dimension. Different from the
traditional multilayer back propagation neural network (BNNs),
the data in PNN are accumulated along the time axis before or after
combining the contribution of the space components. While collecting
these data, different components do not have to be sampled
simultaneously, but in the same intervals.
References:-
1.https://www.sciencedirect.com/science/article/pii/ S0893608014002135
2.https://www.sciencedirect.com/science/article/pii/ S0893608016301800
3.http://asmedl.org/data/Journals/JETPEZ/926524/ gtp_135_1_012801.pdf
4.Fundamentals of neural networks-Book by Laurene V. Fausett
5.https://en.wikipedia.org/wiki/Stock_market_prediction

You might also like