Predicting Stock price of a company has been a challenge for analysts due to the fluctuations and its changing nature with respect to time. This paper attempts to predict the stock prices using Time series technique that proposes to observe various changes in a given variable with respect to time and is appropriate for making predictions in financial sector [1] as the stock prices are time variant.
Introduction
I. INTRODUCTION
Any Investor, individual or firm expects a good or reasonable number of returns on their investments. Investing in Stocks is one of the better options to get a good ROI (Return on investment). This requires investors to have a good understanding of various stocks and their current prices. To maximize the profits and minimize the losses requires a good prediction of the price when to buy a stock and when to sell the same. Some of the Forecasting principles are discussed in Efficient Market Hypothesis and Eliot Wave Theory [6]. In general, the stock prices are mainly determined by the actions of the institutional investors, we call them big buyers and big sellers. The Price Auction will be high for that day if the buyers are more and less when sellers are more. Finally, the price will be at the point of control that is mean price or most of the price at which most of the time of the price holds. Most of the time the price is normally distributed. So based on the price of the auction the entry point and exit point should be identified to get maximum profit and the stop loss point to be predicted properly to have efficient risk analysis. For achieving the same popular statistical techniques like Auto Regression and Moving Averages are being used extensively.
Modern computing technics like machine learning facilitates prediction with more accuracy with Hybrid models like Auto-Regressive Integrative Moving, Exponential Smoothing, ARIMA (Auto Regressive Integrated Moving Average') [7], Naïve Forecasting, Seasonal Naïve Forecasting or Neural Networks. Our current proposed model will use all the modern techniques and predict the stock price at a given point and ranks each of the models to facilitate the user to make a decision when to buy or sell a particular stock, doing a short-term trade or long term to maximize their profits. This model uses all the modern techniques and is different from the traditional approaches having a high probability of accurate prediction.
II. METHEDOLOGY
The proposed steps for achieving the objective are as follows, Initially, the data needs to be fed to the system that is extracted from Yahoo! Finance on monthly basis and the data imported is cleaned by making sure that outliers are removed and a filter is applied to reject the null values in the data. Then data is converted into time series objects and the ADF test is applied to make sure the data is stationary. Then the time series object is decomposed as the results depend on many factors to achieve accurate results the time series object must be decomposed to observe various seasonality factors and trends. Then the time series objects are fed to various algorithms like ARIMA, Exponential Smoothing, Naïve Forecasting, Seasonal Naïve Forecasting, Neural Networks etc. figure 2.1 demonstrates the workflow.
III. ALGORITHMS USED
A. ARIMA
Arima model, which is introduced by George Box and Gwilym Jenkins, is also referred as Box-Jenkins model [2]. The Combination of the models Auto regression and moving average results in a Hybrid model called Auto Regressive Integrated Moving Average which has the following equation.
Where y′t is dependent variable and differenced (Can be differentiated more than once), on the other side we have predictors carrying lagged values of y(t) and lagged errors.
This model is known as ARIMA (p, d, and q) model.
Where p and q are the orders of Auto regression and Moving Average parts and d is the degree of differentiation involved [3].
B. Exponential Smoothing
This forecast technique in which the past data is assigned with some weights in such a way that, they are exponentially decaying with respect to time. The latest weights are at the top and as time factor is increased, they start decaying.
C. Naïve Forecasting
The forecast is set to previous data without applying any predictions and is achieved through following equation.
y′ (T + h) |T= y (T). (1)
Where, (T + h) refers to the forecast related to past data
(T), refers to the forecast related to current data
D. Seasonal Naïve Forecasting
This forecasting technique is similar to naïve forecasting but the forecast is set to past data from same season, we can achieve seasonal naïve forecasting through following equation.
y′ (T + h)|T = y(T + h) − m(k + 1) (1)
Where, m is the seasonal period
T + h refers to forecast related to past data
E. Neural Networks
This type of forecasting is used in nonlinear and complex forecasting scenarios and denoted as NNAR (p, x) where p is number of lagged inputs and x is number of hidden layers. The architecture of Neural Networks is shown in the figure 3.1 [5].
IV. EXECUTION AND RESULTS
A. Gathering Data and Performing Various Analysis on It
Importing and Reading the Data: We use quant mod library to pull the stock data from Yahoo and return the dataset as time-series objects. We have generalized the logic to pull the data from a given stock symbol for a period (from and to dates). We will use stock monthly data of Apple (Switching to other company can be done by just changing the stock symbol), Downloaded from Yahoo Finance
Plotting the Apple Stock Prices Time Series: Plotting the time series object for apple stock prices, the data received from yahoo finance in fig 4.1.2
5) Applying Augmented Dickey Fuller Test (ADF):ADF test is applied to check whether the time series is stationary, the results of ADF can be viewed in figure 4.1.5 The ACF and PACF plots are used to compare current data with past data including their residuals [4].
6) Splitting Data into Train and Test Datasets:Generally, before building a model we need to spit the data into train and test sets, with the help of training set, model needs to be built and with the help of test set the model needs to be tested for its performance.
B. Results from Various Algorithms
Initializing the algorithm and feeding them with apple stock prices then return the predictions made by respective algorithm.
1) ARIMA
Forecast values, predicted by ARIMA model can be observed in figure 4.2.1.1
2. Exponential Smoothing
Forecast Values predicted by ETS can be observed in the figure 4.2.2.1
3. Naïve Forecasting
Forecast values predicted by Naïve model can be observed in the figure 4.2.3.1
4. Seasonal Naïve Forecasting
Forecast values predicted by Seasonal Naïve can be observed in the figure 4.2.4.1
5. Neural Networks
Forecast values predicted by Neural Networks can be observed in the figure 4.2.5.1
Conclusion
Stock price has been predicted, in this case Exponential smoothing outperformed other models but depending on situation and data the performance might vary, when we receive data, it’s recommended to feed the data to all the models, compare the results and consider the accurate result depending upon the ranks.