Ijraset Journal For Research in Applied Science and Engineering Technology
Authors: Drashi Dave, Sanjana Prajapati, Udity Solanki
DOI Link: https://doi.org/10.22214/ijraset.2022.46610
Certificate: View Certificate
Stock is a curve with a lot of unknowns. The stock market has a lot of intricacy and turbulence, which makes it difficult to predict what will happen. The primary goal of the topic\'s argument is to forecast future market stock stability. Many researchers have looked at the future market\'s evolution. Data is a vital source of efficiency because stock is made up of shifting data. The efficiency of the forecast has an impact on the same probability. Machine learning has been incorporated into the picture for the deployment and prediction of training sets and data models in the latest trend of Stock Market Prediction Technologies. Machine Learning uses a variety of predictive models and algorithms to forecast and automate tasks. The focus of the paper is on the application of regression and LSTM to forecast stock prices.
I. INTRODUCTION
A. Stock Price Prediction
The act of attempting to anticipate the future value of a business stock or other financial instrument traded on an exchange is known as stock market prediction. A successful forecast of a stock's future price could result in a large profit. As the degree of trading and investment increased, people looked for strategies and tools that would improve their profits while reducing risk. India has two main stock exchanges - the National Stock Exchange (NSE) and the older Bombay Stock Exchange (BSE). The Indian Stock Exchange is open for business. The two most important Indian stock indices are the Sensex and the Nifty for BSE and NSE respectively, which benchmark index values for measuring the overall performance of the stock market. Stock market prediction is difficult due to the dynamic nature of stock market values. Some forecasting models for this type of event have been created over the last few years. They'd been used to anticipate the money market for a while.
There are two traditional approaches for stock price prediction which are stated below:
B. Objectives
Predicting stock returns and a company's financial situation in advance will provide greater benefits for investors in the current competitive market, allowing them to invest with confidence. Stock forecasting can be done with the help of current and historical market data.
The proposed research aims to investigate and develop supervised learning systems for stock price prediction. It must calculate the stock's projected price using past data. It should also be able to visualize the market index in real time.
The goal of stock market prediction is to predict the future movement of a financial exchange's stock value. Investors will be able to make more money if they can accurately predict share price movement.
II. LITERATURE REVIEW
A. Survey Of Related Work
This research looked at studies that used a generic SMP framework. It mostly focused on studies from the previous decade (2011–2021). The research was compared and examined based on the types of data used as input, data pre-processing techniques, and machine learning algorithms used to make predictions. In addition, as reported it examined the various assessment criteria utilized by different studies for performance measurement. Furthermore, an exhaustive comparison analysis was conducted, with the conclusion that SVM is the most widely utilized technique for SMP. Techniques like ANN and DNN, on the other hand, are commonly used because they produce more accurate and faster predictions. In addition, using both market data and textual data from web sources improves prediction accuracy [1].
The machine learning models LSTM and GRU, which are modern versions of Recurrent neural networks, were used to implement this project.
The LSTM and GRU models were trained by feeding them historical information and statistics from which they learned and adapted to the pattern and forecast the future stock price value, which was close to the original value [2].
In this paper studies, the use of LSTM based Machine learning to forecast stock prices. Factors measured are open, close, low, high and volume. This research was an attempt to determine the future prices of the stocks of a company with improved accuracy and reliability using machine learning techniques. The LSTM algorithm resulted in a positive outcome with more accuracy in predicting stock prices [3].
This paper is based on the approach of predicting the share price using Long Short Term Memory (LSTM) and Recurrent Neural Networks (RNN) to forecast the stock value. Visualization resulted in the predictions made closely matched the actual stock prices. The performance of their proposed stock prediction system, which uses an LSTM model, was compared with a simple Artificial Neural Network (ANN) model on five different stocks of varying sizes of data. The results of comparison between Long Short Term Memory (LSTM) and Artificial Neural Network (ANN) show that LSTM has a better prediction accuracy than ANN [4].
Various machine learning algorithms like Multiple Linear Regression, Polynomial Regression, etc. are used here. Detailed comparison of all models is stated. The financial data contains factors like Date, Volume, Open, High, Low Close, and Adj Close prices. The models are evaluated using standard strategic indicators RMSE and R2 score. Lower values of these two indicators mean higher efficiency of the trained models. It states that adding more data helps the algorithm to learn better [5].
This paper summarizes research on machine learning approaches and algorithms used to increase stock price forecast accuracy. It examined and contrasted the state-of-the-art in machine learning algorithms and methodologies used in finance, particularly in stock price prediction. A variety of machine learning algorithms and methodologies have been examined in terms of input kinds, purposes, benefits, and drawbacks. Some machine learning algorithms and methodologies have been frequently chosen for stock price prediction due to their attributes, accuracy, and error acquired [6].
The goal of this work was to conduct a literature assessment on financial time series forecasting utilizing Deep Learning and technical analysis.
It was feasible to pick 34 publications for this investigation using a research approach. Predictor methodologies, trading strategies, profitability indicators, and risk management were used to base the study and discussions. Because of its memory storage capacity and ability to tackle the vanishing gradient problem, the recurrent neural network LSTM has been widely used. Some hybrid models combined LSTM with additional strategies to cope with news, resulting in more robust results and potential future research [7].
The Artificial Neural Network and Random Forest approaches were used in this study to forecast the next day closing price for five businesses from various industries. The financial data is used to create additional variables that are used as inputs to the model, such as the stock's Open, High, Low, and Close values. Standard strategic metrics such as RMSE and MAPE are used to assess the models. These two indicators have low values, indicating that the models are good at predicting stock closing prices [8].
Tittle |
Technique/Method |
Accuracy |
Stock Market Prediction Using Machine Learning Techniques: A Decade Survey on Methodologies, Recent Developments, and Future Directions. |
Support Vector Machine(SVM) |
80% |
Stock Market Prediction and Analysis using Machine Learning. |
Long Short Term Memory(LSTM) |
80% |
LSTM base Stock Price Prediction. |
Long Short Term Memory(LSTM) |
85% |
Stock Price Prediction Using Long Short Term Memory |
Long Short Term Memory (LSTM) |
75% |
A Survey on Machine Learning for Stock Price Prediction: Algorithms and Techniques |
Long Short Term Memory (LSTM) |
N/A |
Stock Market Forecasting Using Deep Learning and Technical Analysis: A Systematic Review |
Long Short Term Memory (LSTM) |
N/A |
Stock Closing Price Prediction using Machine Learning Techniques |
Artificial Neural Network(ANN) Random Forest (RF) |
N/A |
B. Existing Techniques And Its Drawback
As it is mentioned in the introduction, traditional approaches to stock market prediction and analysis includes Fundamental and technical analysis.
Fundamental analysis dwells into stock’s past performance, company’s credibility, and other factors like news, economy. It uses two fundamental research indicators: P/E ratio and P/B ratio for long-term price fluctuations. Whereas technical analysis dives into investigating trends and employs price charts and formulae to anticipate future stock values.
Fundamental analysis can become tedious and time consuming. It has drawbacks of extrapolation, time delay, need for long term investment, and has no reliable trade signals.Fundamental analysis' drawback is that it can bring you on board a good stock at the wrong time, requiring you to hold on to the stock for a prolonged time.
Technical analysis has limitations like any other method. It's possible to misread the graph. It's possible that the formation is based on low volume. The moving average periods employed may be too long or too short for the type of transaction you're attempting to make. For the same stock, one technical analyst's view may differ from that of another. The technical approaches employed by analysts to examine equities can differ from one to the next.
C. Machine Learning Approach
Our requirement is to overcome the drawbacks of fundamental and technical analysis. The evident progression in modeling techniques has prompted a number of researchers to investigate new stock price prediction approaches.
In stock price prediction, machine learning is used to find patterns in data. Stock markets create a huge volume of structured and unstructured heterogeneous data in general. It is possible to swiftly evaluate more complicated heterogeneous data and provide more accurate findings using machine learning algorithms. For Stock Price Prediction, a variety of machine learning algorithms have been used.
Unsupervised and supervised techniques are the two primary categories in Machine Learning. The learning algorithms are given identified input data and the desired output in the supervised learning approach. Meanwhile, in the unsupervised learning approach, the learning algorithm is given unlabeled input data, and the programme recognises patterns and generates output accordingly.
Furthermore, different algorithmic approaches have been used, such as the Artificial Neural Network (ANN), Recurrent Neural Network (RNN) as stock prediction approaches.
2. Recurrent Neural Network: RNN in comparison to ANN is a bit more complex. Here the data travels in cycles through different layers. To put it another way, data travels through a Recurrent Neural Network in the form of directed cycles of routes between nodes. When compared to ordinary Neural Networks, this provides RNN a distinct advantage. The capacity to learn dynamically and store what has been learned to anticipate is critical when dealing with sequential input.
Simple Neural Networks also learn and retain what they've learned, which is how they predict classes or values for fresh datasets. However, unlike conventional Neural Networks, RNNs rely on information from prior output to predict forthcoming data/input. When dealing with sequential data, this capability comes in handy. LSTM is the most commonly used RNN model.
Therefore, for stock prediction RNN is used over ANN.
D. Proposed System
In order to predict the future of the stock market, a precise approach must be followed, as shown in this diagram.
III. LONG SHORT TERM MEMORY
A. LSTM Architecture
2. Input Gate
3. Output Gate
B. Advantages Of LSTM
IV. METHODOLOGY
A. Importing Libraries
Let's begin by importing some library numpy, pandas from, pandas data reader, and min max color from sklearn preprocessing.
Next, we'll import sequential from keras models, and Dense, LSTM from keras layers. Finally, we'll import matplotlib.
B. Plot Close Price Movement
We're going to plot a figure here. We'll pay more attention to the close price because that's the price we'll predict.
F. Data Normalization
Here we have Normalized and transformed the training data. Normalization is the process of rescaling data from its original range so that all values fall between 0 and 1.
With the help of MinMaxScaler we normalized our data.
It is imported from sklearn.preprocessing module which includes scaling, centering, normalization, binarization methods.
G. Scaling Train Data
We'll make a training data set with values ranging from zero to data size, which will account for 70% of our training dataset.
Next, we'll divide the training data into two groups: x train and y train.
The independent training variable is the x train, while the dependent or target variable is the y train.
We need 60 observations of our training data, so we'll make a loop for e that's in the range of 60 to the size or total size of the training data.We'll append the plus 60 values to the x train data, making the x train data start at position i-60 and the y train data contain the value in the 61st position. As a result, x will have 60 values ranging from 0 to 59, while y will have 61 values and the 60th position. This is the value we want to predict with our model.
H. Train Data Reshaping
First of all, the x_train and y_train were converted into numpy arrays which were used to tutor the LSTM.
Because the LSTM layer is a recurrent layer, it anticipates a three-dimensional input.
For that purpose we reshaped the data in 3D as (1670, 60, 1).
1670 = Number of Samples
60 = Number of steps
1 = Number of Features
I. Building LSTM Model
Process of building LSTM starts with calling sequential() which is imported from keras model. Further on, we have inserted one LSTM layer including 50 neurons and two Dense layers with 25 and 1 neurons respectively. The input_shape contains a number of steps and features.
For compiling this model we used an 'adam' optimizer.
An optimizer adjusts the neural network's properties like weights and learning rate. As a result, it aids in the reduction of total loss and the improvement of accuracy.
LSTM models are trained by calling the fit() function.
We have used train data to fit the LSTM model with 1 epochs and used a batch size of 1.
The number of epochs is the number of complete passes through the training dataset.
Batch size refers to the number of training examples utilized in one iteration
J. Testing Data
Test data is used to test the model here. We have the remaining 30% data which is test data. An array that contains 30% normalized data is created. 60 observations of testing data are created here which will be handy for prediction.
y_test is the actual data here and x_test will be the predicted data.
So, actual data and predicted data will be compared later on.
K. Converting Test Data
Then we turned the test data to an array and used the reshape tool to reshape the data to three dimensions so that we could use it in a prediction model. Now, we've used the model to build a prediction from our testing data and then we've used the scaler that inverse transforms to get the prediction's value.
V. RESULTS
A. Root Mean Square Error
To evaluate the model, the root mean square error will be calculated, which will tell us how accurate the model is. The rmse is 0.8 , which is a good figure because it indicates that the model is accurate and that the forecast is extremely near to the actual value.
C. Values
We can see that the close price and prediction are really near, with the exception of a few dates where they deviate somewhat, but in general they are both very close.
This project establishes the groundwork in order to make machine learning technologies more accessible to the retail investors.We used LSTM for stock price prediction which provided us with a fair prediction on closing price. Similar trend is seen between the actual and predicted price. Prediction with LSTM deals only with numbers. And there are limitations to just number crunching and analysis. Stock market analysis does not only rely on the closing price. It is a matter of fact that the stock market reacts to many other factors. National factors like Government Policies, Interest Rate and Inflation, Politics, Natural Disasters, Economic Numbers, Gold Prices and Bonds have a significant effect on stock prices. International Macroeconomic Factors that Affect Indian Stock Market are Exchange Rates (Dollar Index), Crude oil, International Politics. Therefore, just by predicting the closing price of a stock will not suffice. We need a hybrid and an intelligent model for prediction that could consider all influential factors. We would like to extend our work in an attempt to build a model that could check the impact of news on stock prices. It might be news feed analysis from social media platforms like Twitter and other sources, where emotions are evaluated from the articles. This sentiment analysis can be combined with the LSTM to increase weight training and accuracy.
[1] Rouf, N., Malik, M. B., Arif, T., Sharma, S., Singh, S., Aich, S., & Kim, H. C. (2021). Stock Market Prediction Using Machine Learning Techniques: A Decade Survey on Methodologies, Recent Developments, and Future Directions. Electronics, 10(21), 2717. [2] Rajan Kelaskar, , Manojkumar Sahu, Rahul Kamble, & Sumedh Kapse. (2018). Stock Market Prediction And Analysis Using Machine Learning. International Journal Of Advance Research And Innovative Ideas In Education, 4(2), 3806-3810. [3] Prof. Ahir, P., Lad, H., Parekh, S., Kabrawala, S. (2021). LSTM based Stock Price Prediction. International Journal for Creative Research Thoughts, 9(2), 5118-5122. [4] Nandakumar, R., Uttamraj, K. R., Vishal, R., & Lokeswari, Y. V. (2018). Stock price prediction using long short term memory. International Research Journal of Engineering and Technology, 5(03). [5] Pawaskar, S. Stock Price Prediction using Machine Learning Algorithms. International Journal For Research in Applied Science and Engineering Technology, 10(1), 667-673. [6] Obthong, M., Tantisantiwong, N., Jeamwatthanachai, W., & Wills, G. B. (2020, May). A Survey on Machine Learning for Stock Price Prediction: Algorithms and Techniques. In FEMIB (pp. 63-71). [7] Li, A. W., & Bastos, G. S. (2020). Stock market forecasting using deep learning and technical analysis: a systematic review. IEEE access, 8, 185232-185242. [8] Vijh, M., Chandola, D., Tikkiwal, V. A., & Kumar, A. (2020). Stock closing price prediction using machine learning techniques. Procedia computer science, 167, 599-606. [9] https://www.researchgate.net/publication/321985773/figure/fig3/AS:574184990023686@1513907777315/Artificial-Neural-Networks-ANN-architecture.png [10] https://www.researchgate.net/figure/Basic-Architecture-of-Recurrent-Neural-Network-22-23_fig2_325668211 [11] P.Srivastava. Essentials of Deep Learning: Introduction to Long Short Memory. Analytics Vidhya, 2017.
Copyright © 2022 Drashi Dave, Sanjana Prajapati, Udity Solanki. This is an open access article distributed under the Creative Commons Attribution License, which permits unrestricted use, distribution, and reproduction in any medium, provided the original work is properly cited.
Paper Id : IJRASET46610
Publish Date : 2022-09-04
ISSN : 2321-9653
Publisher Name : IJRASET
DOI Link : Click Here