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

Stock Prediction Using Machine Learning

This document discusses using machine learning algorithms like LSTM to predict stock prices. It describes analyzing stock price movement using both fundamental factors like company financials and technical indicators applied to historical price and volume data. The goal is to build a model trained on past stock data to predict future prices. Seasonal and non-seasonal stock cycles are also discussed, along with typical strong and weak months for stock performance.

Uploaded by

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

Stock Prediction Using Machine Learning

This document discusses using machine learning algorithms like LSTM to predict stock prices. It describes analyzing stock price movement using both fundamental factors like company financials and technical indicators applied to historical price and volume data. The goal is to build a model trained on past stock data to predict future prices. Seasonal and non-seasonal stock cycles are also discussed, along with typical strong and weak months for stock performance.

Uploaded by

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

Stock Price Prediction Using Machine Learning

Jagdeesh Patil S Snv Charan Sai


Information Science and Engineering Department Information Science and Engineering Department
Nitte Meenakshi Institute of Technology Nitte Meenakshi Institute of Technology
Bangalore, India Bangalore, India
[email protected] [email protected]

Sachin Kumar Shivam Kumar


Information Science and Engineering Department Information Science and Engineering Department
Nitte Meenakshi Institute of Technology Nitte Meenakshi Institute of Technology
Bangalore, India Bangalore, India
[email protected] [email protected]

978-1-6654-9790-9/22/$31.00 ©2022 IEEE


Abstract— Recently there has been a rapidly growing monetary elements. Crucial examiners concentrate on
interest in stock market. Predicting the stock market is tough whatever can influence the security’s worth, from
task in the field of computation. For the growth of shareholder macroeconomic factors, for example, the condition of the
in the company stock, stock price prediction has a great economy and industry conditions to micro economic
consideration to increase the interest. There are many factors elements like the adequacy of the organization’s
related to prediction, physical factor vs physiological, seasonal administration. The ultimate objective is to show up at a
vs non-seasonal, market etc. All this aspect combines to make number that a financial backer can contrast and a security’s
stock cost volatile and extremely tough to predict with high ongoing cost to see whether the security is underestimated or
accuracy. So, with respect to training the past data by using exaggerated. For stocks, principal investigation utilizes
machine learning or deep learning building a model and then incomes, income, future development, return on value, net
passing the past data as input that is as training data to the
revenues, and different information to decide an
model based on training data to the result. we propose the
LSTM model to examine the future price of a stock. This
organization’s fundamental worth and potential for future
report is the predict stock market price to make move acquaint development. The different basic elements can be assembled
and precision investment decision. This paper discusses about into two classifications: quantitative and subjective. The
the analysis of the stock price prediction we have done. By monetary importance of these terms isn’t entirely different
applying machine learning algorithms, like the LSTM to from their standard definitions
predict the stock price. Also, this paper discusses about the
Technical Analysis is an exchanging discipline utilized to
indicators used and the UI deployed
assess speculations and recognize exchanging open doors by
Keywords— Phishing attack, phisher, hackers, legitimate, investigating measurable patterns accumulated from
sensitive data.
exchanging action, like value development and volume.
Unlike Fundamental Analysis, which endeavours’ to assess a
I. INTRODUCTION security’s worth in view of business results, for example,
deals and profit, Technical Analysis canters around the
The above objectives can be achieved by creating a investigation of cost and volume.
model using machine learning algorithms, Where the Dataset
is collected stock is a security that address the obligation Technical Analysis is a method of evaluating the stock
regarding part of an organization. It is moreover had some performance using the past trend analysis whereby, the
significant awareness of significant worth. This entitles the analysis is done by using some indicators which are
owner of the stock to a degree of the association’s assets and deployed in the charts of the stocks. Rather than fundamental
advantages comparable to how much stock they own. analysis which focus only on history and fundamental of
stocks, the technical analysis focus broadly on the technical
Units of stock are assigned” shares.” Stock worth part of it.
assumption is one of the device and techniques made by
generally various monetary sponsor furthermore, traders that Stock Style
assist them with accomplishing benefit in the exorbitantly The Stock Cycle consists of seasonal and non-seasonal
lengthy utilizing these methodologies. Monetary business stock cycle.:
regions are one of the central enhancements inside
continuous memory. They incredibly impact business, ● Seasonal Stock
mentoring, work, progression and similarly the economy in ● Non-Seasonal Stock
different areas. Financial exchange surveying has
dependably drawn in scientists and reviewers.
Seasonal stocks are the type of stocks which do not have
LSTM is the comprehensively preferred designing. The a particular season for the movement of the stock. There are
research anticipate equity using LSTM. The main aim is to strong months for seasonal stocks. While the strong months
transform the weakness related with adventure confirmation. can vary from time to time, but typical strong months for
Various practices in money related business areas are seasonal trends are July, January, December. July month is
routinely tended to and separated as an exceptional kind of the well advance month in the calendar of months. This is the
time series. month of Holiday’s where there is time for people to spend
some time in the stock market. Many people in December
The main LSTM was made to loosen up the
month usually invest in stocks so that they can have tax
RECURRENT NEURAL NETWORK memory state to
saving and as December is the closing of the year, people
engage it to oversee longer data game plans. Another kind
tend to save taxes and invest in stocks, before the year closes
of RECURRENT NEURAL NETWORK is Bidirectional
where the past and succeeding data progressions to satisfy Non-Seasonal Stock are the stocks that does not have any
best developing experience execution. effect on the season of the stocks. Weak month for stock
market are the usually weak month for investing according to
II. PROPOSED METHOD the past trend analysis with respect to Dow jones, SP indices.
Stock Price rediction June is the month where majority of the stock events take
place and people would like to get rid of this month, as
The In the case of stock price prediction there are two events like Fed meeting, Bond treasure result will happen
analysis methods during this month. September is considered as the horrible
● Fundamental Analysis month for the stock market. Usually Both Nasdaq, Dow
jones saw decline in this month as many companies would
● Technical Analysis
post their results in this month
Fundamental Analysis is a technique or estimating a
security’s inherent worth by looking at related monetary and
III. MOTIVATION AND OBJECTIVES systems, the display of an association, concerning its stock
Stock worth assumption is a thing of beauty and huge expense improvement, is anticipated by inside
issue. With a viable model for stock assumption, we can gain correspondence plans. In these structures, accuracy is
understanding about market lead for a really long time, problematic while choosing different levels of stock turns of
spotting designs that would some way or another not have events. For instance, utilizing the” decision tree as a
been observed. With the obviously computational power of classifier, the typical presumption accuracy was 63.7%,
the PC, AI will be a useful procedure to deal with this issue. 31.92% and 12% for” two levels”,” three levels” and” five
In any case, the public stock dataset is exorbitantly limited levels””, independently. For each datum, it does tantamount
for some AI estimations to work with, while mentioning occupation with its result of the ongoing status of
more components could cost colossal number of dollars information relying on the past evaluations from this it shows
common. That is the very thing the animated idea is, RNN (RECURRENT NEURAL NETWORK) has repeating
expecting we know all information about today’s stock properties. There exists a disappearing propensity and
trading (of each and every specific seller), the expense is detonating slant issue. This outcome plainly shows that stock
obvious. With the development of the Internet, interpersonal costs are not clear utilizing these techniques.
organizations, and online social associations, getting day to In most of the prediction techniques, some algorithms
day client expectations is practical job1.Subsequently, our like the sliding window algorithm are used which does not
inspiration is to plan a public help integrating verifiable provide good results, the accuracy is low compared to the
information and clients’ expectations to make a more well-known algorithms like the SVM, ANN. The main
grounded model that will help everybody. problem with the sliding window algorithm is that it cannot
The point is to create the example from huge handle linear data, as there is lot of unwanted data that
arrangement of information and foresee the future worth of cannot be cleaned with this type of algorithm. We have used
the monetary loads of a stock or portions of organization. AI LSTM, in our proposed algorithm for good results, due to the
itself utilizes various models to make expectation more unwanted data there is lot of apace and memory wastage
straightforward and legitimate. A protections trade figure is which leads to slow processing and lagging data.
depicted as a movement of trying to portray the future worth
of the association stock or other financial endeavour traded
on the stock exchange.
IV. FRAMEWORK AND DESIGN

Many systems are used to expect stock expenses, for


instance, direct backslide, k-nearest, auto, prophet, etc. To

Fig 1. Sliding algorithm used in existing model

In the above figure, it is shown how sliding algorithm is


used in some of the existing models for prediction where a
model called Radial Basis Function (RBF) is used where it is
measured by calculating the distance between the input and
some fixed point

Fig 2. Proposed model

evaluate the monetary trade, “two-way back-propositional”


cerebrum associations, auto-in reverse moving ordinary
models as well as multi-layer perceptron used. In existing
A. Collection of data set and Pre-processing
First of all, we want to import the csv file into our
python console for which we take the csv file from directly
given 65% as the data size for the training set and remaining
available in the yahoo finance ticker website which gathers
35% for the testing set, with this there won’t be any
the stock data for all the stocks. We have taken the data
ambiguity in plotting the results.
from a particular URL called yahoo.com. The csv file which
we took for the preprocessing of the dataset is the
APPLE.CSV file which is available from online ticker
website, where we can extract data for any stock, for any
month we want. So, we have taken around 1269 days data to D. RMSE Calculation
show the prediction. Before this, we want to do the data Work out (RMSE) and that gathers, with pleasant
preprocessing, where in we first clean the file which has perfection of the final tested model. An assessment show’s,
unwanted junk data that is not useful for work. sort of data expected costs coordinating the true expenses.
educational set unequivocally. It diminished the figure the
staggering the model will perform. Regardless, if all else
fails, it is able to use comparative assessments furthermore
B. Feature Selection to genuinely find the data and check the performance.
Also known as Feature selection algorithm, is a method
to select the type of features which are used to promote the
model and make the model better. Features have
dependence on each other. When the data is huge it is better
to do the feature selection, so that we can only select the
data that is required using latest features. Doing this, it can
make the model simpler, and easily understandable. The
main purpose is to reduce the space and time and reduce the
memory consumption. We use, Min max scalar, which is
inbuilt library available to scale the data, and gives the result
in the range between 0 and 1.

C. Training and Testion Dataset Fig 3. RMSE Calculation

Train Set: Data used to fit the model is known as the” V. METHODOLOGY
train set,” sometimes known as the” training dataset” the
dataset used to train the model. The model observes and E. Working with LSTM
absorbs this data. LSTM is a sort of repetitive brain organization. In
RECURRENT NEURAL Network yield from the last step
is taken care of as contribution inside the current step. It
handled the question of long-haul conditions of
Test Set: An accurate assessment of a final model fit is RECURRENT NEURAL Network inside which the
provided by the test dataset, which is a subset of the dataset. RECURRENT NEURAL Network won’t foresee the word
Prepare an information and outline it such that it has only hang on inside the drawn-out memory anyway can offer
end cost and convert it to a social occasion. Now, express a extra exact estimates from the new data. Since the hole
value to get-together an assessment of readiness length will expand RECURRENT NEURAL Network
enlightening data chosen. We truly acknowledge the status doesn’t offer a prudent execution. LSTM will as a matter of
edifying grouping should contain a degree for such course hold the information for an extensive stretch of time.
information. Prepare an orchestrating edifying collection of It is utilized for handling, anticipating and characterizing
data which combines the beyond 60-day chat close based on time-series information. Design of LSTM: “LSTM
appreciation, so we truly need to expect the 61 - day close has a chain association that contains four brain organizations
worth of the stock. an essential piece in the ’x-train’ and different memory blocks called cells”. LSTM have
illuminating variety will wrap variables from the another “design called a memory cell”. The memory cell
enlightening social affair from list (0-59) (sixty settles on the conclusions about when to permit perusing
characteristics complete) furthermore, the going with part and what data to store, composing and neglecting. A
will contain values from the instructive from report 1 to memory contains three principal doors:
record (60 credits) and business as usual. The ’y-train’
instructive blend will contain the sixty-first worth created at
annual sixty for its the basic district and the sixty-second
worth worked with at record 61 of the enlightening social ● INPUT entryway another worth streams into the
gathering for its following worth and 16 it shows up along “memory cell”.
these lines. Basically, what we have done is that we have
● FORGET entryway a worth remaining parts in the
“memory cell”.
● OUTPUT door esteem in “memory cell” is utilized
to register the result.

FORGET GATE is the 1st step in the LSTM


architecture, in this architecture it shows which data is
useful, given that there is both hidden state and new input
data. Both hidden state and the new input is given to this
gate and the output is portraits so that value is close to 0 and
input value is close to 1. Later it decides which information Fig 4. Pre-processing data
should be forgotten and which to proceed further.
G. Dataset collection
In the data set collection, we import standard machine
learning libraries like the pandas and the NumPy and give a
INPUT GATE is used when new information gets added particular key for them. For Whatever stock we want to do
and the value is stored in the current state. First, current the prediction, we collect the data from a ticker website,
status and previous hidden are passed to the sigmoid which provide the stock data using API. This process is
function, where the values are transformed in between [0,1]. possible with the help of data frame applied on the stock
The tanh () function will squash the data between [-1,1]. The APPLE which we took as an example
output values generated form the activation functions are
ready for point-by-point multiplication.

In training and testing the data, we divide the sample


size as 65% for the training set and 35% for the testing set.
OUTPUT GATE is used to move the final step, the By assigning more size for the training set, we can evaluate
output gate, deciding the new hidden state. To decide this, the model as best fit, and more robust performance.
we will use three things; the newly updated cell state, the
previous hidden state and the new input data.

H. LSTM model
In the LSTM implementation model, we use the stack
In the final step now, coming to the output gate, we have LSTM model because it offers more layers, we have used
to decide the new hidden state. To get the hidden state, we three layers to optimize the data. Using stacked LSTM, the
use the previously newly updated cell and the previous process works better and faster compared to normal LSTM
hidden state and the new input data. The main thing in this approach, which work comparatively slower. Increasing the
is that a filter is used so that only that information should be number of layers/hidden units in a neural network doesn’t
given output. necessarily result in over-fitting. Too few will result in low
training and test accuracy’s; too many will result in high
training accuracy but low-test accuracy (over-fitting).”
Adam” is an optimizer.

F. System Design
The Flow of Pre-processing of data. After collection of
data and then divide the data if you want and the scale the
data in between -1 to +1 and then we split the data for
training and testing.

Basically, what we do in this process is that we first


collect the required data that we need to pre-process it and
then using the techniques we clean the data and use min
max scalar so that the unwanted data can be removed and
only the data we need is kept for further process. Later, after Fig 5. LSTM model
this process is done, we train and test the data set.
I. Prediction
Prediction of future 30 days stock price based on
previous 100 days of data and plot the predicted price with
information and the one in green is the prepared
the actual data, it shows a smooth graph of next 30 days
information, the blue line addresses the real upsides of the
expected closing price of any stock apple, google, Tesla or
stock.
whichever data is available

Misfortune and Accuracy: The model was determined


Fig 6. Output of next 30 days

J. Indicators
Relative Strength Index (RSI) is a momentum oscillator
that measure the magnitude of change in the recent price. It
tells the traders whether the price is in oversold region or
overbought region

RS=average gain/average loss


RSI=100-100/(1+RS)

K. Website UI Implementation
Used Streamlit for website to show the details about
company and their stocks. brief about company stock name, utilizing the RMSE recipe, which is 1%, which is perfect for
what does company do their previous opening and closing a train and test model, the image is connected beneath. The
price of stock and previous opening price also the investors stock cost and anticipated costs have been planned on a
of that company along with institutional investors and then diagram with its comparing dates. They aren’t precise yet it
the real time graph of closing price of that company stock tackles the reason for everyday expectation.
and total stock volume traded.

Prediction for next 30 days: based on previous 100 days


data we predict the future 30 days approx. stock closing
price here we can predict closing price of any no. of days for
any stocks like GOOGLE, APPLE, TESLA, NSE etc.

The Apple closing price vs no. of days graph. Here we


have total 1259 days data and we are plotting the closing
price of that stock. Prediction on the training and testing
data which is 65% and 35% respectively. Yellow color gives
the prediction on training data and green color gives us the
prediction on the testing data.

Fig 7. UI Implementation

VI. RESULT

Predication of Test Data: stock cost versus date plot has


been plotted and similar test and prepare information have
been superimposed, the line plot in orange is the test
Fig 12. Closing Price graph

Fig 8. Dataset collection

Fig 9. Train set prediction

The Prediction of future 30 days as shown in below


graph. The yellow part of the graph. Here we are plotting
the previous 100 days data from data-set as blue graph and
then future prediction based on it

Above graph represent the closing price of stock”


AAPL”. It is a live graph of closing price of the company
Apple Here we can check the closing price of different years
Fig 10. Future Prediction

This Pi-chart represent the major holders in the company


including the institutional holders.

Fig 11. Major Holders


Fig 13. Volume Traded
VII. CONCLUSION AND FUTURE SCOPE prediction. In 2018 9th international conference on information and
communication systems (ICICS), pages 151–156. IEEE, 2018.

[2]. Wei Bao, Jun Yue, and Yulei Rao. A deep learning framework for
financial time series using stacked autoencoders and long-short term
In this report, “we are predicting closing stock price of memory. PloS one, 12(7):e0180944, 2017.
any given organization, we developed a web application for
predicting close stock price using LMS and LSTM [3]. Lokesh Chouhan, Navanshu Agarwal, P Ishita, and S Saxena. Stock
algorithms for prediction”. We have applied datasets market prediction using machine learning. In First international
belonging to Google, Apple, NSE, and many more Stocks. conference on secure cyber puttinging and communications, National
Institute of Technology, JALANDHAR, 2018.

[4]. Atharva Gondkar, Jeevan Thukrul, Raghav Bang, Siddhika Rakshe,


and Sambhaji Sarode. Stock market prediction and portfolio
LSTM has capacity to refresh, decimate and recall data optimization. In 2021 2nd Global Conference for Advancement in
is more successful. In this work, one of the most reliable Technology (GCAT), pages 1–10. IEEE, 2021.
accuracies estimating methods is utilized that helps financial
backers, experts and people enthusiastically to contribute by [5]. Sepp Hochreiter and J¨urgen Schmidhuber. Long short-term memory.
allowing great information for the future condition of trade Neural computation, 9(8):1735– 1780, 1997.
in the financial exchange trades. In this report proposed a
profound inclining based financial exchange cost forecast. [6]. Archit Kapoor, Varun Rastogi, and Nirbhay Kashyap. Forecasting
Here, Long Short-Term Memory (LSTM) network is daily close prices of stock indices using lstm. In 2020 2nd
International Conference on Advances in Computing, Communication
proposed and looked at the exhibition of the calculation with Control and Networking (ICACCCN), pages 10–14. IEEE, 2020.
AI models. These models are tried on the seat mark data-set
taken from NSE Website, Yahoo, Pandas-data-reader and. [7]. J Kavinnilaa, E Hemalatha, Minu Susan Jacob, and R Dhanalakshmi.
We tried the proposed strategy on load of apple, google, Stock price prediction based on lstm deep learning model. In 2021
Tesla. The proposed technique has shown great execution, International Conference on System, Computation, Automation and
furthermore, which help to acquire the hopeful outcomes. Networking (ICSCAN), pages 1–4. IEEE, 2021.

[8]. J Kavinnilaa, E Hemalatha, Minu Susan Jacob, and R Dhanalakshmi.


Stock price prediction based on lstm deep learning model. In 2021
International Conference on System, Computation, Automation and
Future scope: Examining the relationship between Networking (ICSCAN), pages 1–4. IEEE, 2021.
various digital forms of money and how might that
influence the exhibition of our model. adding highlights [9]. Kiril Andreev Koparanov, Krasin Krasimirov Georgiev, and Vasil
utilizing specialized investigation to actually take a look at Aleksandrov Shterev. Lookback period, epochs and hidden states
the model exhibition. adding highlights from principal effect on time series prediction using a lstm based neural network. In
2020 28th National Conference with International Participation
investigation to really look at what those mean for the mode. (TELECOM), pages 61–64. IEEE, 2020.
adding opinion examination from informal communication
for example twitter and new report to actually take a look at
[10]. ChangWei Liu and Hao Wang. Stock recommendation based on depth
model execution. GRU organization can likewise be brnn and bi-lstm. In 2019 4th international conference on mechanical,
attempted with various actuation for example ’softsign” to control and computer engineering (ICMCCE), pages 751–7514.
really look at the presentation. Multivariate examination of IEEE, 2019.
this nature requires a lot of exertion and time on highlight
designing, information investigation, model preparation and [11]. Jigar Patel, Sahil Shah, Priyank Thakkar, and Ketan Kotecha.
so on. Predicting stock and stock price index movement using trend
deterministic data preparation and machine learning techniques.
Expert systems with applications, 42(1):259–268, 2015.

VIII. REFERENCES
[1]. Khaled A Althelaya, El-Sayed M El-Alfy, and Salahadin Mohammed.
Evaluation of bidirectional lstm for short-and long-term stock market

You might also like