Forecasting stock price movements, especially for prominent companies like Amazon, remains a significant challenge and a key focus in both academic research and financial analysis. The stock market is known for its high volatility and unpredictability, making accurate prediction complex.
This study explores the application of machine learning techniques to enhance the reliability of stock price forecasting. Specifically, it focuses on deep learning models such as Long Short-Term Memory (LSTM) and Gated Recurrent Unit (GRU), which are designed to capture sequential patterns in historical data. For comparative analysis, a traditional Linear Regression model is also implemented.
The experiments were conducted using real historical stock data from Amazon, employing two different feature sets: one containing fundamental price features (High, Low, Close, Volume), and another enhanced with technical indicators including the Relative Strength Index (RSI), Exponential Moving Average (EMA), and Moving Average Convergence Divergence (MACD). The effectiveness of each model was evaluated using standard performance metrics such as Mean Absolute Error (MAE), Root Mean Squared Error (RMSE), and Mean Absolute Percentage Error (MAPE).
Introduction
The project focuses on predicting Amazon stock prices using deep learning models—LSTM and GRU—which are well-suited for sequential data. Traditional prediction methods struggle with market volatility and non-linear trends, so this project uses advanced models along with technical indicators like RSI, EMA, and MACD to improve forecasting accuracy.
Literature Survey
Previous studies have explored various models:
XGBoost & LightGBM outperform traditional models (Rana & Kulkarni, 2023).
Polynomial regression captures volatility better than linear models (Mishra & Jain, 2022).
Random Forest, ARIMA + Linear Regression, Naive Bayes, and SVM have all been used effectively depending on the dataset and problem nature.
Objective
To develop and evaluate models (Linear Regression, LSTM, GRU) that predict the next day’s High and Low stock prices using Amazon’s historical data. The models are assessed using:
MSE, RMSE, MAE, and MAPE.
The ultimate aim is to assist in smarter investment decisions by tracking real market trends.
Methodology
Data Collection & Preprocessing: Data from Yahoo Finance is cleaned, scaled, and missing values are handled.
Feature Engineering: Technical indicators (RSI, EMA, MACD) are added.
Model Development: Linear Regression, LSTM, and GRU models are built and trained on sequences of 60/90 days of past stock data.
Evaluation: Models are evaluated on how accurately they predict future prices.
Algorithms
Linear Regression: Models the relationship between input features and prices with a linear equation. It's simple but limited in handling non-linearity.
LSTM (Long Short-Term Memory):
Remembers long-term dependencies using gates (Forget, Input, Output).
Input: Sequences of 60/90 days of stock data.
Architecture: Two LSTM layers (64, 32 units), with Dropout layers to prevent overfitting.
GRU (Gated Recurrent Unit):
A simpler, faster version of LSTM.
Uses Update and Reset gates to manage memory.
Architecture: Two GRU layers (64, 32 units), Dropout layers, and a Dense output layer for predicting High and Low prices.
Conclusion
The evaluation showed that Linear Regression gave the most accurate results in terms of error values (MSE, MAE, RMSE, MAPE) over a short 5-day prediction period. However, it was not very good at capturing the actual upward or downward movement of stock prices. Among the deep learning models, GRU performed slightly better than LSTM in terms of prediction accuracy. Linear Regression also had very low percentage errors, with MAPE close to 1.2%. On the other hand, LSTM and GRU models were better at following the correct trend of the stock, accurately predicting the direction in 9 out of 14 cases, while Linear Regression did so in only 7 out of 14. This shows that while simple models like Linear Regression are more precise, deep learning models are more effective in understanding market behaviour and trends.