Stocks have become one of the largest and most intricate financial markets globally due to their high popularity, making them very challenging to predict as they can process millions of transactions rapidly. The objective of this study is to enhance the field by creating a dependable and accurate model for predicting the stock price of Amazon. This will be achieved via the use of advanced algorithms such as Long Short-Term Memory (LSTM) and Gated Recurrent Unit (GRU). This research utilised historical data on Amazon's stock price from the past five years, which was acquired from Yahoo Finance. The data was partitioned using a hold-out validation technique, allocating 80% for training and 20% for testing. The model underwent training using different optimizers (Adam, SGD, RMSprop), batch sizes (8, 16, 32), and learning rates (0.001, 0.0001). The evaluation criteria comprised of mean squared error (MSE), root mean squared error (RMSE), mean absolute error (MAE), and mean absolute percentage error (MAPE). The results suggest that the GRU model, when trained with the RMSprop optimizer using a batch size of 16 and a learning rate of 0.0001, as well as with the SGD optimizer using a batch size of either 16 or 32 and a learning rate of either 0.001 or 0.0001, produced the lowest error metrics, indicating superior performance. This study enables more precise forecasts of stock prices and more efficient investment techniques.