You are on page 1of 34

Stock Price

Prediction
By:
Aarushi Sunderrajan (S0
Paridhi Deval (S0
Pranjal Gupta (S059)
Overview

Contents Introduction
About the Subject
Methodology
Objectives
Types of patterns with time
What is ARIMA?
Time series forecasting with ARIMA
What is SARIMA?
Result
Conclusions
Short Comings
Future scope
Bibliography
Acknowledgement
Overview

• Stock price prediction using machine learning helps you discover


the future value of a company stock and other financial assets traded
on an exchange.
• The entire idea of predicting stock prices is to gain significant
profits.
• Predicting how the stock market will perform is a hard to do.
• All investors come across the question:
Introduction “What will be the price of this stock in future?”
• This question has given birth to many studies, theories, beliefs and what
not! Many have created millions of models which aims to predict prices
based on some reasonable logic. All efforts have led to a conclusion that
there is no one size fits all model. However, it will be incorrect to
assume that prices cannot be predicted at all.
• Prices tend to have some patterns and can be predicted to some
degree. A general understanding of the price behavior should be
sufficient to make money in this market. Understanding ‘the direction of
wind’ presents sufficient opportunities for one to take advantage of the
scenario. You will make money as and when the scenario plays out in
your favor and the rest could be managed by risk management
techniques.
• Prices tend to follow patterns as time passes because certain factors play
Introduction out again and again over time which impact the price of an asset. Price of
an asset depend of many factors like economic scenarios, government
actions and consumption patterns. These factors follow a cycle (in which
they expand, contact and again expand) over time which as a result make
the prices of assets follow a cyclical pattern.
• Let me share an exciting data to explain this:

YEAR EVENT
In 1981-82 Iranian Revolution
In 1990’s Oil price shock
In 2000 Dot-com bubble
In 2008 Sub-prime crisis
In 2020 COVID crisis
About the Subject

Time Series Forecasting means analyzing and modeling time-series


data to make future decisions. Some of the applications of Time
Series Forecasting are weather forecasting, sales forecasting,
business forecasting, stock price forecasting, etc. The ARIMA
model is a popular statistical technique used for Time Series
Forecasting. If you want to learn Time Series Forecasting with
ARIMA, this article is for you.
Methodology
• We will be using the ARIMA model to forecast the prices of Tata
Motors Ltd. To do the forecast we will be using Python tool. The
process is broken into multiple steps where we will see the relevant
code and what it does. The Python file that we created is also attached
at the end of this presentation for reference.

• Tata Motors Limited is an Indian multinational automotive


manufacturing company, headquartered in Mumbai, India, which is
part of the Tata Group. The company produces passenger cars, trucks,
vans, coaches, buses. One of the reason for selecting this stock is that
this stock has one of the highest market cap in the Indian stock
markets and hence offers good liquidity to trade in it.
Objectives
To predict an outcome based on time series data, we can use a
time series model which is called Auto Regressive Integrated
Moving Average (ARIMA) is used as the machine learning
technique to analyze and predict future stock prices based on
historical prices.

Key Points
• Trends - Price of assets follow a general direction over a long period of
Types of Patterns in time, irrespective of the short term behavior. There are only three
directions in which prices can go – upwards (uptrend), downwards
(downtrend) and sideways trend.
price with time
• Seasonality and cyclicality – Repeating price action over periods of
Types of Patterns in months is referred to as seasonality and that in years is referred to
as cyclicality.

price with time


• Noise - This is ‘white noise’ and cannot be modelled. Random price
Types of Patterns in movements are referred to noise. As discussed initially, this part should
not be of interest as this does not help in increasing the general
understanding of price movements.
price with time
What is ARIMA?

• ARIMA stands for Auto Regressive Integrated Moving Average


(ARIMA) model. To a first time reader this term itself might seem
intriguing, but the approach that we use here explains the process in
a easy manner.
• First, we break the name into smaller pieces to understand the
meaning of each piece:
What is ARIMA?
• ARIMA models have three parameters like ARIMA(p, d, q). Here
p, d, and q are defined as:
1. p is the number of lagged values that need to be added or
subtracted from the values (label column). It captures the
autoregressive part of ARIMA.
2. d represents the number of times the data needs to differentiate
to produce a stationary signal. If it’s stationary data, the value
of d should be 0, and if it’s seasonal data, the value of d should
be 1. d captures the integrated part of ARIMA.
3. q is the number of lagged values for the error term added or
subtracted from the values (label column). It captures the
moving average part of ARIMA.
• I hope you have now understood the ARIMA model. In the section
below, I will take you through the task of Time Series Forecasting
of stock prices with ARIMA using the Python programming
language.
Time Series • In this project, we will be using the ARIMA model to forecast the
prices of Tata Motors Ltd. To do the forecast we will be using Python
tool.
Forecasting using • Tata Motors Ltd. is a listed Indian company. Established in 1945, Tata
Motors Limited is a leading global automotive manufacturer with a

ARIMA
portfolio that covers a wide range of cars, SUVs, buses, trucks, pickups
and defense vehicles.
• Now let’s start with the task of Time Series Forecasting with ARIMA.
We first collected the Tata Motors stock price data using the Yahoo
Finance API.
Time Series • Importing the required packages

Forecasting using
ARIMA
Time Series We only need the date and close prices columns for the rest
of the task, so let’s select both the columns and move
Forecasting using further:

ARIMA
Time Series Visualizing the close prices of TATA MOTORS before
moving forward
Forecasting using The plot:

ARIMA
Using ARIMA for • Before using the ARIMA model, we have to figure out
whether our data is stationary or seasonal. The data
Time Series visualization graph about the closing stock prices
above shows that our dataset is not stationary. To
check whether our dataset is stationary or seasonal
Forecasting properly, we can use the seasonal decomposition
method that splits the time series data into trend,
seasonal, and residuals for a better understanding of
the time series data:
Using ARIMA for
Time Series
Forecasting
Using ARIMA for • So our data is not stationary it is seasonal. We need to
use the Seasonal ARIMA (SARIMA) model for Time
Time Series Series Forecasting on this data. But before using the
SARIMA model, we will use the ARIMA model. It
will help you learn using both models.
Forecasting • To use ARIMA or SARIMA, we need to find the p, d,
and q values. We can find the value of p by plotting
the autocorrelation of the Close column and the value
of q by plotting the partial autocorrelation plot. The
value of d is either 0 or 1. If the data is stationary, we
should use 0, and if the data is seasonal, we should
use 1. As our data is seasonal, we should use 1 as the
d value.
What is SARIMA? • SARIMA stands for Seasonal-ARIMA and it includes
seasonality contribution to the forecast. The
importance of seasonality is quite evident and ARIMA
fails to encapsulate that information implicitly.
• The Autoregressive (AR), Integrated (I), and Moving
Average (MA) parts of the model remain as that of
ARIMA. The addition of Seasonality adds robustness
to the SARIMA model.
• Similar to ARIMA, the P,D,Q values for seasonal
parts of the model can be deduced from the ACF and
PACF plots of the data.
To find the value In the autocorrelation plot, the curve is moving
down after the 4th line of the first boundary. That
of p: is how we decide the p-value.
Hence the value of p is 4
To find the value In the partial autocorrelation plot, we can see that
only two points are far away from all the points.
of q: That is how to decide the q value.
Hence the value of q is 2.
Now let’s build an The predicted values are wrong because the data
is seasonal.
ARIMA model ARIMA model will never perform well on seaso
nal time series data
Building a
SARIMA model
Prediction: Now let’s predict the future stock prices
using the SARIMA model for the next 10
days:
Plotting the prediction:

The red line indicates the predicted value for price of the stock.
Result

•A
Conclusion

•ARIMA models is one of statistical technique could be used to


forecast time series data.
•Time series data have trend, seasonality/cyclicality and noise
components.
•In ARIMA models, one has to decide on the order in such a way
that error is reduced.
Short Comings

•Difficult to predict turning points


•The risk of large forecasting errors increases the more longer
term the forecasts
•Determining the model parameters is a subjective process
•Holt Winters and exponential smoothing are easier to explain
Future Scope
•Weather conditions in specific regions
•Electricity consumption in an household
•Heart rate monitoring
•Total sales in a store
Bibliography
Wikipedia
Yahoo Finance
LinkedIn
Link to the codes click here
Acknowledgement

First and foremost, we would like to thank our Mentor Dr. Suresh
Pathare who guided us in doing this project. He provided us with
valuable advice and helped us. His motivation and help
contributed tremendously to the successful completion of the
project. Besides, we would like to thank all the teachers who
helped us by giving us advice and providing the equipment which
we needed.
THANK YOU

Aarushi Sunderrajan Paridhi Deval Pranjal Gupta

You might also like