0% found this document useful (0 votes)
3 views19 pages

Navam Mini Project

This project report focuses on using deep learning algorithms, specifically LSTM, to predict stock market fluctuations based on historical data from the Indian stock market. It outlines the methodology, including data collection, preprocessing, model training, and evaluation, while also discussing the challenges and limitations of stock market predictions. The report concludes with insights on future applications of machine learning in financial predictions.

Uploaded by

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

Navam Mini Project

This project report focuses on using deep learning algorithms, specifically LSTM, to predict stock market fluctuations based on historical data from the Indian stock market. It outlines the methodology, including data collection, preprocessing, model training, and evaluation, while also discussing the challenges and limitations of stock market predictions. The report concludes with insights on future applications of machine learning in financial predictions.

Uploaded by

khajurianavam
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Mini Project Report on

Stock Market Predictions Using Deep Learning Algorithms


Submitted in partial fulfillment of the requirement for the award of the degree of

BACHELOR OF TECHNOLOGY
IN
COMPUTER SCIENCE & ENGINEERING

Submitted by:
Student Name University Roll No.
Navam Khajuria 2019729

Under the Mentorship of


Dr A. Suresh Kumar

Department of Computer Science and Engineering


Graphic Era (Deemed to be University)
Dehradun, Uttarakhand
January 2023
CANDIDATE’S DECLARATION

I hereby certify that the work which is being presented in the project report entitled “Stock market predictions
using deep learning algorithms.” in partial fulfillment of the requirements for the award of the Degree of
Bachelor of Technology in Computer Science and Engineering of the Graphic Era (Deemed to be University),
Dehradun shall be carried out by the under the mentorship of Mentor Name, Designation, Department of
Computer Science and Engineering, Graphic Era (Deemed to be University), Dehradun.

Name Navam Khajuria University Roll no 2019729


Table of Contents

Chapter No. Description Page No.


Chapter 1 Introduction 1
Chapter 2 Literature Survey 3
Chapter 3 Methodology 6
Chapter 4 Result and Discussion 10
Chapter 5 Conclusion and Future Work 15
References
Chapter 1

Introduction

1.1 PROBLEM STATEMENT: Use deep learning algorithms to predict


stock market fluctuations.

This project is about machine learning using deep learning algorithms, and the application
of them to Stocks. The project will focus on an Artificial Intelligence (AI) based stock
market prediction system that makes predictions based on historical data and optimization
algorithms.

1.2 Background

The stock market is a financial market where valid trading takes place that allows
companies to raise money by offering stock shares and corporate bonds, as well as
allowing investors to participate in the financial achievements of companies. Investors
gain profits through capital gains and earn income through dividends.

The stock market is known for being volatile, dynamic and nonlinear. Accurate stock price
prediction is extremely challenging because of multiple factors, such as politics, global
economic conditions, unexpected events, a company's financial performance etc. In short:
Stock market is not a smooth entity that offers predictable return on investments (ROI).

1.3 Report overview

We will be using LSTM (Long-Short Term Memory) and regression methodology on


Indian stock market dataset in our following project.

1
In Deep Learning, LSTM stands for Long Short-Term Memory. It is a variety of
Recurrent Neural Networks (RNNs) that are capable of learning long-term
dependencies, especially in sequence prediction problems.

Regression is the study of predicting a continuous variable using linear or nonlinear


relationships. Regression analysis is used to test the hypothesis that two or more
variables are linearly related.

This makes it valuable in many fields, including economics, sociology, biology and
computer science. In finance, regression analysis can be used as a tool for finding out
whether any variable has predictive power over many others in terms of portfolio
returns.

The dataset for this project is Indian stock market.

1.4 Indian stock market

The National Stock Exchange of India Limited (NSE) is one of the leading stock
exchanges in India, based in Mumbai. It is one of the largest derivatives exchanges in
the country, processing over 23 million contracts per day. NSE has over 100 pan-India
relationships with leading financial institutions, banks and insurance companies.

2
Chapter 2

Literature Survey

2.1 Overview of stock market predictions.

The stock market is one of the most significant events that has attracted people from

various backgrounds be it educational or business. It has been very successful in

attracting people from various backgrounds and professions, and the nonlinear nature

of the stock market has made it a research topic for many years. People decide to invest

in the stock market based on some prior research knowledge or some prediction. In

terms of prediction, many people look for tools or methods that would minimize their

risks and maximize their profits and hence machine learning technologies have become

a recent trend in the stock market prediction whose prediction is based on the existing

stock price values eventually as an outcome of training on their previous values.

2.2 Overview of deep learning.

The deep learning is one of the most powerful approaches for solving complex

problems in computer vision and artificial intelligence. The main objective of this book

is to give you a comprehensive view on the state-of-the-art research and development

on DL, especially in computer vision and natural language processing. A systematic

literature review methodology has provided insights into ML applications across a wide

range of information technology (IT) and scientific domains. The following are four

highly cited articles that used this methodology. Wen et al. (2012) employed a

systematic literature review to evaluate empirical studies of ML models for software

development effort estimation (SDEE).

3
2.3 Overview on LSTM

LSTM is a memory unit that allows you to learn new values even while the input has

not changed. LSTM recurrent neural network can achieve faster data processing and

multi-step learning, which has been attracting attention in the field of deep learning. If

you want to use these models on your own projects, you can refer to our training

resources.

LSTM cells, specially trained with recurrent or long-term dependencies, are difficult to

train and suffer from the exploding / vanishing gradient problem. To overcome this

shortcoming when learning long-term dependencies, the LSTM architecture was

introduced. An LSTM cell is a high-level computational unit that possesses high

capability in continuously learning information in favor of its output given by many

previous outputs. The learning ability of LSTM impacted several fields from both a

practical and theoretical perspective, so that it became a state-of-the-art model.

2.4 LSTM for regression

The model is simple to implement, and it can easily be applied to any market. Both

techniques have shown to be an improvement in the accuracy of predictions, thereby

yielding better results with the LSTM model proving to be more efficient than

regression. The results are promising, and this has led to the conclusion that it is

possible to predict stock market with more accuracy and efficiency using machine

learning techniques.

2.5 Previous research on prediction of stock market using LSTM.

4
Recent years, with the extensive application of deep learning technology, many

domestic and foreign researchers began to use deep learning to conduct stock prediction

research. For example, Volodymyr Turchenko and others proposed to take the stock

price of Fiat company as the research object and used MLP neural network to make

short-term prediction of stock price. However, the number of parameters required to

use the MLP neural network is too large and the scalability is poor. Therefore, Avraam

Tsantekidis and others proposed a stock price forecast based on the CNN model. CNN

realizes the local connection and weight sharing of neurons, retains important

parameters

5
Chapter 3

Methodology

3.1 Data collection

NSE Data & Analytics Limited (formerly known as DotEx International Limited), a

separate professional set-up dedicated solely for this purpose, provides NSE's market

quotes and data for Capital Market Segment (CM), Futures and Options Segment

(F&O), Currency Derivative Market Segment (CDS), Wholesale Debt Market

Segment (WDM), Corporate Data, Corporate Bond Market data and Securities

Lending & Borrowing Market (SLBM).

3.2 Data Preprocessing

Data preprocessing is a data mining technique that involves transforming raw data

into an understandable format. Real-world data is often incomplete: lacking attribute

values, lacking certain attributes of interest, or containing only aggregate data.

Steps in data preprocessing:

Step 1: Import the libraries

Step 2: Import the dataset

Step 3: Check out the missing values

Step 4: Encode the Categorical data

6
Step 5: Splitting the dataset into Training and Test set

Step 6: Feature scaling

Importing
dataset
checking
missing data

Encoding
categorical data

Data Splitting dataset into


preprocessing test and training set
Feature
scaling

Fig 3.2.1 Data preprocessing steps

3.3 LSTM Model training

Long Short-Term Memory models can predict arbitrary values into the future. They do this

by using the 5 components of an LSTM module to model both long term and short-term data.

• Cell state (ct) - This represents the internal memory of the cell which stores both short
term memory and long-term memories
• Hidden state (ht) - This is output state information calculated w.r.t. current input,
previous hidden state and current cell input which you eventually use to predict the
future stock market prices. Additionally, the hidden state can decide to only retrieve
the short or long-term or both types of memory stored in the cell state to make the
next prediction.
• Input gate (it) - Decides how much information from current input flows to the cell
state
• Forget gate (ft) - Decides how much information from the current input and the
previous cell state flows into the current cell state

7
• Output gate (ot) - Decides how much information from the current cell state flows into
the hidden state, so that if needed LSTM can only pick the long-term memories or
short-term memories and long-term memories

Fig 3.3.1 LSTM Model

And the equations for calculating each of these entities are as follows.

• it = σ(WixXt + Wihht-1 + bi) (3.1)


• $\tilde{c}\_t = \sigma(W\_{cx}x\_t + W\_{ch}h_{t-1} + b_c)$(3.2)
• $f\_t = \sigma(W\_{fx}x\_t + W\_{fh}h_{t-1}+b_f)$ (3.3)
• $c_t = f\_t c\_{t-1} + i_t \tilde{c}_t$ (3.4)
• $o\_t = \sigma(W\_{ox}x\_t + W\_{oh}h_{t-1}+b_o)$(3.5)
• $h_t = o_t tanh(c_t)$ (3.6)

3.4 Data Visualization

8
We would do that using certain data analysis libraries provided by various

programming languages like panda in Python.

Fig 3.4.1 Data visualization using Pyplot

9
Chapter 4

Result and Discussion


4.1 Results of model evaluation

Let us use stock data of APPLE imported from an API.

The Apple data is up to 22-05-2020. Let’s take the close column for the stock

prediction. We can use the same strategy. If we have a bar chart, it will look like this:

Fig 4.1.1 Bar chart for AAPL prices.

We should reset the index.

df1=df.reset_index()['close']

We want to plot the closing value graph using pyplot, but we also want to know what

to do when the data comes in over time. The easiest thing to do is to create a function

and specify a signature of one argument in each function call.

10
Fig 4.1.2 Graph using pyplot for AAPL stock prices.

The LSTM control is sensitive to the scale of the data. Here, the scale of Close value is

in a kind of scale, so we should always try to transform the value. For example, if the

range from 0 to 1, we need to do something for it. Here, we will use min-max scalar to

transform the values from 0 to 1. We should reshape so that we can use fit transform

from [Link] import MinMaxScaler


scaler=MinMaxScaler(feature_range=(0,1))
df1=scaler.fit_transform([Link](df1).reshape(-1,1))

11
Predict both the X_train and the X_test, now let’s scaler inverse transform because I

want to see the root mean square performance.

train_predict=[Link](X_train)
test_predict=[Link](X_test)
train_predict=scaler.inverse_transform(train_predict)
test_predict=scaler.inverse_transform(test_predict)
import math
from [Link] import mean_squared_error
[Link](mean_squared_error(y_train,train_predict))

The time step is 100, in both train and test data. The difference between the values of

train predict and test predict is 0.9976. This means that (1<<2) - 1 is equal to 0.9976

Fig 4.1.3 Stock Prediction graph

• Green indicates the Predicted Data


• Blue indicates the Complete Data
• Orange indicates the Train Data

12
If I consider the last date in the test data as of 22-05-2020, I want to
predict the output of 23-05-2020. We need the previous 100 data for
that I am taking the data and reshaping it.

x_input=test_data[341:].reshape(1,-1)
x_input.shape

4.2 Limitations of this study

4.2.1 Selection bias:

The underlying asset within all stocks is a non-trivial quantity. Ignoring the

inputs, their architecture, and their technology stock selection is a highly

subjective process that depends upon factors such as economic catalysts,

fluctuations and other external factors; critical when making an investment

decision that impacts the lives of millions.

4.2.2 Portfolio construction

All too often investors focus on one asset each and fail to build a robust

portfolio. Giving weight to the most important investment decisions in the

overall portfolio and building a deliberate strategy that considers the risk profile

of all companies has been shown to increase returns, reduce risk and improve

investment performance.

4.2.3 Incorrect application of preprocessing.

Distribution of stock prices change from year to year, meaning that the mean and

standard deviations will also change. This property of financial time series is

called non-stationarity and it remains an open problem in financial prediction.

13
4.2.4 The project is unfinished!!

If a project does not result in a profit, it is not a successful project. The

determining factors of success are the quality of data and the strategy used to

make predictions on it. As far as we can determine, almost all fortune tellers

will only seek to make money by predicting the stock market using machine

learning tools. It is therefore vital to test predictions of these two factors so that

an investment manager can be confident that their returns are not being

manipulated by third parties.

14
Chapter 5

Conclusion and Future Work

5.1 Conclusion

In this article, we explored how LSTM or Long Short-Term Memory can be used to

predict stock prices. We then visualized the opening and closing price value after

using LSTM to see what kind of predictions we were able to make.

5.2 Future works

Many future machine learning applications will use social media, news trends, and

other data sources to predict financial activity. In these areas, there is little that the

human mind can do better than computers. The hope is that machine learning can

replicate human intuition in financial activity by discovering new trends.

Machines today are performing trades worth billions of dollars every day. The

mathematical algorithms used to make these decisions must detect the underlying

trend and determine whether it has changed. Each machine takes into consideration all

variables at once, making these complex projections a challenge for even the most

sophisticated software.

15
References

1. [International Journal of Engineering Applied Sciences and Technology, 2020 Vol. 5,


Issue 8, ISSN No. 2455-2143, Pages 258-262

2. Journal of International Technology and Information Management Volume 28,


Number 4

3. 2020 IJCRT | Volume 8, Issue 5 May 2020 | ISSN: 2320-2882

4.
5. Yulian Wen et al 2020 IOP Conf. Ser.: Mater. Sci. Eng. 790 012109
6.
7. Procedia Computer Science Volume 132, 2018, Pages 1351-1362

16

You might also like