$$\rightleftharpoonup{xx}$$
$$\longleftharp{xx}$$,
$$\longrightharp{xx}$$,
Gold is one of the most significant commodities in the financial markets, a critical economic resource and a price-controlling tool. Gold constitutes a substantial portion of central bank reserves in many countries1. Recently, gold has become more well-known as an inflation hedge2. It is a key hedging asset and its volatility forecasting improves using Generalized Autoregressive Conditional Heteroskedasticity - Mixed Data Sampling (GARCH-MIDAS) models that account for asymmetry, extremes, and jumps3. India and China are the largest importers and consumers of gold accounting for approximately 60% of global demand. The continuous rise in gold prices driven by market dynamics and commodity relations has positioned gold as a preferred investment for future returns4. In India the magnitude of physical gold holdings is substantial with households often treating gold as both a cultural asset and a financial safeguard. Its demand for physical gold directly impacts market trends emphasizing the need to consider its relevance in gold price forecasting5,6. Investors are constantly seeking investment opportunities that offer the highest returns with the lowest risk. In this regard gold serves as a safe-haven asset providing financial security during economic uncertainties. Among the top investment alternatives in India are stocks, banks, deposits, insurance, gold postal savings, other savings and investment options7. Given its stability gold is widely regarded as the best alternative investment option among various investment options and a valuable asset that protects against inflation and financial risks1,8. Gold price determination is influenced by factors like gold demand, supply, inflation, and exchange rates. A surprising finding indicates that dollar appreciation correlates with increased gold prices potentially due to speculative investment9. It is difficult to predict the gold price because of its volatile, unpredictable, nonlinear and uncontrollable price movement10. Therefore, accurate gold price prediction is crucial for investors, portfolio managers, and policymakers as improved forecasting can lead to significant profit opportunities11. The current price trend of gold which is four times higher than two decades ago and the desire to keep gold attract investors to invest in related assets12. Therefore, before investing in gold every investor must understand the key factors influencing its price13. In the financial industry the capacity to forecast the direction of gold prices is essential even minor advancements in performance prediction can result in profits money is essential to lead a life and sound financial forecasting will support economic expansion14.
Figure 1 explores the gold price trends in India over a period of time spanning from 2014 to 2024 and how gold prices are increasingly based on global factors like the dollar index, federal funds rate, the consumer price index (CPI), exchange rate, oil prices and the S&P50015. Other factors include business cycles, nominal interest rates, commodity prices, exchange rates and stock prices16. It highlights the significant price changes, volatility in the market and a period of sustained expansion in gold prices particularly in recent years. Prices showed little volatility between 2014 and 2018 however, in 2019 a robust increasing trend with more price swings was observed. Gold's position as a safe-haven asset was strengthened by a substantial increase in 2020, most likely brought on by concerns about inflation and economic upheaval. The close price closely tracks the open price but greater volatility particularly after 2020 is shown by broader gaps between high and low prices. Prices have been rising steadily during the 2023-2024 timeframe hitting all-time highs. The chart shows how gold has appreciated throughout time, making it a useful asset for analysts and investors.
Accurate gold price prediction is vital for informed decision-making but it is challenging due to complex factors like economic and geopolitical conditions17. Traditional models like Autoregressive Integrated Moving Average (ARIMA) often struggle to capture these complexities limiting their predictive accuracy18,19. In a quest to overcome these limitations the recent advancements in machine learning and deep learning have significantly improved financial forecasting accuracy. Experiments demonstrated that deep learning models like Long Short-Term Memory (LSTM) networks perform significantly better than traditional statistical models by capturing sequential relationships and trends in gold prices20. Hybrid forecasting models are a key consideration in forecasting gold prices in big data computation and economics21. Nevertheless, regardless of their performance recurrent models like Long Short-Term Memory (LSTM) and Gated Recurrent Unit (GRU) have natural limitations like disappearing gradient problems, high computational complexity and inability to capture long-range relationships which may impact their efficiency in handling large-scale finance time series data.
In order to bridge these deficits and further enhance the accuracy of prediction transformer models are now an attractive choice in time-series forecasting, compared to LSTM networks transformers leverage self-attention mechanisms, hence making them effectively detect long-term patterns and short-term oscillations in financial data and parallel processing to improve scalability. Transformers have considerable potential to improve gold price prediction accuracy given their effectiveness in financial market forecasting. The present study aims to develop a transformer model for gold price forecasting using past gold prices and major economic data providing a more robust approach for gold prediction.
Earlier studies had predicted the gold price using several techniques like neural networks, algorithms, machine learning, deep learning and artificial intelligence. Some of the studies related to gold price prediction are as follows:
Gaussian process regression (GPR) has emerged as a robust tool for metal price forecasting with applications in steel, copper and precious metals highlighting its effectiveness in handling high-dimensional financial data and optimizing models through Bayesian methods to predict the gold price more accurately RMSE of 0.8722. The study presents a novel hybrid model that combines a Random Convolutional Kernels-based Neural Network (RCK) with Generalized Autoregressive Conditional Heteroskedasticity (GARCH) to predict the volatility of gold, silver and platinum. The accuracy of the suggested method is 53% higher than that of the GARCH-LSTM model23. The study used ARIMA and Holt-Winters models to forecast the future gold prices and inflation rates in India and the United States by considering the Consumer Price Index (CPI). Gold is a good hedge against inflation for both Indian and United States Investors24. The study compares deep learning and machine learning models to analyse Bitcoin's relationship with global factors such as gold, oil, US Dollar Index (DXY) and interest rates. Temporal Fusion Transformer (TFT) outperforms others highlighting gold and DXY as key influencers amid global events and regulations25. Moreover, the study systematically reviews the factors affecting gold futures prices like inflation rate, interest rate, crude oil price and US dollar index with three main forecasting methods: traditional time series models (ARIMA GARCH, ARDL), hybrid models (MS-MIDAS-CJ, VMD-ICSS-BiGRU) and deep learning methods (SGRU-AM) DBN)26. Transformer architectures have strong potential in long-term time series forecasting by effectively capturing long-range dependencies and outperforming traditional Recurring Neural Network (RNN) based models27. The study explored the relationship between gold prices and key determinants like stock markets, crude oil, exchange rates, inflation and interest rates. It utilizes machine learning algorithms finding gradient boosting regression is more accurate than random forest regression in predicting gold prices14. The study used Autoregressive Distribution Lag (ARDL) model to forecast the annual gold prices using treasury bill rates, gold demand and lagged gold prices as covariates28. The proposed Convolutional Neural Network-Long Short-Term Memory (CNN-LSTM) model for gold price forecasting demonstrates superior performance compared to traditional methods with lower MAE and RMSE values. Incorporating convolutional layers into the LSTM architecture further enhances its ability to capture both short-term patterns and long-term dependencies in the data29.
Future gold prices are predicted from four commodities: historical data of gold prices, silver prices, crude oil prices and the Standard and Poor's 500 stock index (S&P500) index and foreign exchange rate by using the Extreme Learning Machine (ELM) model with an accuracy of 91.67%4. A Multilayer Perceptron (MLP) neural network model was employed to predict stock price fluctuations and gold prices based on data from the Tehran Stock Exchange (TSE). The result indicated that the artificial neural network outperformed traditional forecasting models in terms of prediction accuracy30. The study compared LSTM with Linear Regression models and discovered that Linear Regression achieved a marginally higher accuracy rate of 53.02% in forecasting the daily fluctuations of gold prices. This suggests that even simpler models can be effective in predicting gold price movements highlighting the importance of understanding the relationships between gold prices and broader economic factors31. Wavelet Neural Network (WNN) modelling for gold price forecasting study experimental results demonstrated that the enhanced Artificial Bee Colony (ABC) algorithm outperforms the traditional ABC approach in gold price forecasting utilizing wavelet neural networks32.
Several advanced predictive models have been proposed for gold and financial market forecasting. One of the studies developed a gold price prediction model using an Adaptive Neuro-Fuzzy Inference System (ANFIS) with past gold prices as inputs. The model accurately predicted next-day gold prices outperforming ARIMA and CNN models in terms of RMSE. It also exceeded the performance of both Buy and Hold strategies by delivering significantly higher returns on investment demonstrating strong potential for gold price forecasting33. Another study integrated an ELM with a Fuzzy Inference System (FIS) and used the Chaotic Quantum Crisscross Search Algorithm (CQCSA) optimization technique. This hybrid model exhibits superior performance in predicting the gold and oil prices34. A research employed various machine learning models on financial market prediction during the COVID-19 period where Vanilla Stacked LSTMs surpassed other approaches in time-series forecasting. The findings emphasized the importance of incorporating non-economic variables alongside historical financial data for short-term market predictions35. The study explored ensemble models for predicting the gold and silver stock price movements. These approaches achieved notable accuracy rates of 85% for gold and 79% for silver indicating their capability to capture complex market dynamics36. In another study focusing on deep learning architectures for gold price prediction the Bidirectional Long Short-Term Memory (BiLSTM) model outperformed standard LSTMs by achieving higher R2, lower MAE, and RMSE values. By effectively capturing temporal patterns from normalized historical data BiLSTM demonstrated its potential to enhance the accuracy of financial forecasts37.
Accurate prediction of gold prices has long posed a significant challenge for investors, analysts, and policymakers due to the volatile, nonlinear, and multifactorial nature of financial markets10. Traditional statistical models such as ARIMA and regression-based approaches have shown limitations in capturing the complex and dynamic relationships inherent in gold price movements particularly under the influence of macroeconomic indicators, geopolitical tensions, and global financial shifts19. While ARIMA and similar models are useful for short-term linear forecasting, they lack the ability to capture nonlinearity, structural breaks, and long-term dependencies18,38. Although deep learning models like LSTM and GRU have improved prediction performance by learning sequential patterns20. These models still suffer from intrinsic limitations such as vanishing gradients and difficulties in modelling long-term dependencies in time-series data29. Furthermore, while hybrid and ensemble models have been explored, they often struggle with scalability and computational efficiency in large-scale financial datasets23. Gold, increasingly used as a hedge against inflation and economic uncertainty, especially in countries like India, where it holds substantial cultural and financial significance, the demand for robust, high-accuracy predictive models has become paramount2. Recent innovations in deep learning, particularly the transformer architecture known for its self-attention mechanism, have shown promising results in time-series forecasting tasks across financial domains17. However, existing literature lacks a comprehensive investigation of transformer models specifically for gold price prediction using long-term historical datasets enriched with diverse economic indicators. Most previous studies have either focused on short-term prediction or used limited data inputs, neglecting the full potential of transformer models in capturing both short-term and long-term market trends31.
Therefore, the present study addresses the critical research gap by proposing and evaluating a transformer deep learning model trained on a decade's worth of historical gold price data (2014-2024) collected through an automated and reproducible web scraping method using UiPath. The model aims to enhance prediction accuracy outperform existing models like LSTM, CNN-LSTM, and regression. It provides a reliable tool for investors and policymakers in making informed decisions under market uncertainty22.
The unstoppable increase in gold prices has heightened the need for forecasting which is more important than ever for investors, financial analysts and policymakers. Gold is widely valued as a safe-haven asset and plays a key role in investment strategies particularly in countries like India where it holds economic and cultural importance. In an increasingly volatile market and global uncertainty environment reliable predictions are crucial for maximizing returns, managing risks, and making sound financial decisions. The study is designed to develop an accurate and effective gold price forecasting model that aligns with the complexities of today's financial markets.