Using Generative Pre-Trained Transformers (GPT) for Electricity Price Trend Forecasting in the Spanish Market
Abstract
:1. Introduction
1.1. Research Gap Analysis
- Data Enrichment: GPT-based models can analyze and extract valuable insights from a vast corpus of specialized news articles and reports on the energy market. This data enrichment provides a broader context for energy price forecasting models.
- Event Detection: GPT models can detect and highlight significant events [30], such as geopolitical developments, supply disruptions, or regulatory changes, that may impact energy markets. These detected events can be used as input variables for forecasting models.
- Market News Summarization: GPT can generate concise summaries of complex news articles and reports [31] making it easier for analysts and traders to stay informed about market developments. These summaries can serve as valuable inputs for forecasting models.
- Identifying Influential Factors: GPT can identify and rank factors mentioned in the news and reports likely to influence energy prices. This information can guide feature selection and help prioritize variables in forecasting models.
- Customized Reports: In the case of OpenAI’s GPT, users can provide customized prompts to extract specific information or insights from news and reports. This allows for tailored analysis based on the unique requirements of the forecasting model.
1.2. Research Objectives
2. Materials and Methods
2.1. Paradigm 1: In-Context Learning
2.2. Paradigm 2: Fine-Tuning
2.3. Implementation Details
- Impact on Electricity Price (Scale 0–10): The first variable quantifies the perceived impact of each news article on the price of electricity within a scale ranging from 0 (no impact) to 10 (high impact). This quantification allows us to discern the potential influence of each piece of news on energy prices, a critical factor in sentiment analysis used for forecasting models.
- Direction of Impact (Up, Down, None): We evaluated whether the news articles indicated a potential price impact in the form of an increase (“up”), a decrease (“down”), or no discernible impact (“none”). Understanding the direction of influence is paramount for making informed predictions in the dynamic energy market.
- Impact Period (Past, Short-term, Mid-term, Long-term, None): The third variable delves into the temporal aspect of impact, categorizing it into various periods—past, short-term, mid-term, long-term, or none. This temporal classification aids in determining when the anticipated price effects are likely to materialize, further enhancing the precision of our models.
2.3.1. In-Context Implementation
2.3.2. Fine-Tuned Implementation
- Dataset preparation: Every instance within the dataset should represent a conversation structured in a manner consistent with OpenAI’s Chat Completions API. This structure entails organizing the conversation as a list of messages, where each message comprises a role, content, and the possibility of including a name.
- Validate data formatting and divide training and testing datasets.
- Upload dataset file and create the fine-tuning job using the OpenAI SDK.
- Use the new fine-tuned model with the rest of the news and articles to enrich the dataset with calculated variables.
3. Results
- Close Price: If the direction indicates that the price will go UP (Figure 6), the OPEN PRICE at the beginning of the first interval when the news is published (interval t) should be LOWER than at least 1 of the CLOSE PRICE values of the current or the following two intervals (t, t + 1, t + 2). The intervals will be weeks for short term and months for mid/long term.
- High/Low: If the direction indicates that the price will go UP (Figure 8), the OPEN PRICE at the beginning of the first interval when the news is published (interval t) should be LOWER than at least 1 of the HIGH PRICE values of the current or the following two intervals (t, t + 1, t + 2). The intervals will be weeks for short term and months for mid/long term.
3.1. Short-Term Analysis
3.2. Mid/Long-Term Analysis
4. Discussion
- the incorporation of GPT-calculated features into multivariate time series prediction models as input variables.
- influential event detection as early warning signals (natural disasters, geopolitical conflicts, regulatory changes).
- automatic generation of reports that describe the recent evolution of the electricity market price and the prediction of price trends.
5. Conclusions
Author Contributions
Funding
Data Availability Statement
Conflicts of Interest
References
- Pezzutto, S.; Grilli, G.; Zambotti, S.; Dunjic, S. Forecasting Electricity Market Price for End Users in EU28 until 2020—Main Factors of Influence. Energies 2018, 11, 1460. [Google Scholar] [CrossRef]
- OMI, Polo Español S.A. (OMIE). Market Results. 2018–2023 Retrieved from OMIE. Available online: https://www.omie.es/en (accessed on 1 February 2024).
- International Energy Agency. World Energy Outlook Annual Report. 2018–2023; International Energy Agency: Paris, France, 2024.
- Weron, R. Electricity price forecasting: A review of the state-of-the-art with a look into the future. Int. J. Forecast. 2014, 30, 1030–1081. [Google Scholar] [CrossRef]
- Nowotarski, J.; Weron, R. Recent advances in electricity price forecasting: A review of probabilistic forecasting. Renew. Sustain. Energy Rev. 2018, 81, 1548–1568. [Google Scholar] [CrossRef]
- Qin, Q.X. An effective and robust decomposition-ensemble energy price forecasting paradigm with local linear prediction. Energy Econ. 2019, 83, 402–414. [Google Scholar] [CrossRef]
- Bianco, V.; Manca, O.; Nardini, S. Electricity consumption forecasting in Italy using linear regression models. Energy 2009, 34, 1413–1421. [Google Scholar] [CrossRef]
- Kumar, U.; Jain, V.K. Time series models (Grey-Markov, Grey Model with rolling mechanism and singular spectrum analysis) to forecast energy consumption in India. Energy 2010, 35, 1709–1716. [Google Scholar] [CrossRef]
- Hyndman, R.J.; Fan, S. Density forecasting for long-term peak electricity demand. IEEE Trans. Power Syst. 2010, 25, 1142–1153. [Google Scholar] [CrossRef]
- Kamalov, F.; Sulieman, H.; Moussa, S.; Avante Reyes, J.; Safaraliev, M. Powering Electricity Forecasting with Transfer Learning. Energies 2024, 17, 626. [Google Scholar] [CrossRef]
- Kok, M.; Lootsma, F.A. Pairwise-comparison methods in multiple objective programming, with applications in a long-term energy-planning model. Eur. J. Oper. Res. 1985, 22, 44–55. [Google Scholar] [CrossRef]
- Gong, X.; Guan, K.; Chen, Q. The role of textual analysis in oil futures price forecasting based on machine learning approach. J. Future Mark 2022, 42, 1987–2017. [Google Scholar] [CrossRef]
- Li, X.; Shang, W.; Wang, S. Text-based crude oil price forecasting: A deep learning approach. Int. J. Forecast. 2019, 35, 1548–1560. [Google Scholar] [CrossRef]
- Jiang, Z.; Zhang, L.; Zhang, L.; Wen, B. Investor sentiment and machine learning: Predicting the price of China’s crude oil futures market. Energy 2022, 247, 123471. [Google Scholar] [CrossRef]
- Liu, B. Sentiment Analysis and Subjectivity. In Handbook of Natural Language Processing, 2nd ed.; Indurkhya, N., Damerau, F., Eds.; Chapman & Hall: Boca Raton, FL, USA, 2010. [Google Scholar]
- Zhao, L.T.; Zeng, G.R.; Wang, W.J.; Zhang, Z.G. Forecasting oil price using web-based sentiment analysis. Energies 2019, 12, 4291. [Google Scholar] [CrossRef]
- Hutto, C.J.; Gilbert, E. VADER: A Parsimonious Rule-based Model for Sentiment Analysis of Social Media Text. In Proceedings of the International AAAI Conference on Web and Social Media 2014, Ann Arbor, MI, USA, 1–4 June 2014. [Google Scholar]
- Nguyen, T.H.; Shirai, K.; Velcin, J. Sentiment analysis on social media for stock movement prediction. Expert Syst. Appl. 2015, 42, 9603–9611. [Google Scholar] [CrossRef]
- Socher, R.; Perelygin, A.; Wu, J.; Chuang, J.; Manning, C.D.; Ng, A.Y.; Potts, C. Recursive deep models for semantic compositionality over a sentiment treebank. In Proceedings of the 2013 Conference on Empirical Methods in Natural Language Processing, Seattle, WA, USA, 18–21 October 2013; pp. 1631–1642. [Google Scholar]
- Santos, M.V.; Morgado-Dias, F.; Silva, T.C. Oil Sector and Sentiment Analysis—A Review. Energies 2023, 16, 4824. [Google Scholar] [CrossRef]
- Xie, Q.; Han, W.; Lai, Y.; Peng, M.; Huang, J. The wall street neophyte: A zero-shot analysis of chatgpt over multimodal stock movement prediction challenges. arXiv preprint 2023, arXiv:2304.05351. [Google Scholar]
- Ko, H.; Lee, J. Can ChatGPT improve investment decisions? From a portfolio management perspective. Financ. Res. Lett. 2024, 64, 105433. [Google Scholar] [CrossRef]
- Lopez-Lira, A.; Tang, Y. Can chatgpt forecast stock price movements? return predictability and large language models. arXiv preprint 2023, arXiv:2304.07619. [Google Scholar] [CrossRef]
- Li, M.; Chen, L.; Zhao, J.; Li, Q. Sentiment analysis of Chinese stock reviews based on BERT model. Appl. Intell. 2021, 51, 5016–5024. [Google Scholar] [CrossRef]
- Li, M.; Li, W.; Wang, F.; Jia, X.; Rui, G. Applying BERT to analyze investor sentiment in stock market. Neural Comput. Appl. 2021, 33, 4663–4676. [Google Scholar] [CrossRef]
- Kheiri, K.; Karimi, H. Sentimentgpt: Exploiting GPT for advanced sentiment analysis and its departure from current machine learning. arXiv preprint 2023, arXiv:2307.10234. [Google Scholar]
- Breitung, C.; Kruthof, G.; Müller, S. Contextualized Sentiment Analysis using Large Language Models; SSRN: Rochester, NY, USA, 2023. [Google Scholar] [CrossRef]
- Lund, B.D.; Wang, T. Chatting about ChatGPT: How may AI and GPT impact academia and libraries? Libr. Hi Tech News 2023, 40, 26–29. [Google Scholar] [CrossRef]
- Kamnis, S. Generative pre-trained transformers (GPT) for surface engineering. Surf. Coat. Technol. 2023, 466, 129680. [Google Scholar] [CrossRef]
- Veyseh, A.P. Unleash GPT-2 power for event detection. In Proceedings of the 59th Annual Meeting of the Association for Computational Linguistics and the 11th International Joint Conference on Natural Language Processing, Bangkok, Thailand, 1–6 August 2021; Volume 1, pp. 6271–6282. [Google Scholar]
- Goyal, T.L. News summarization and evaluation in the era of gpt-3. arXiv preprint 2022, arXiv:2209.12356. [Google Scholar]
- Liu, J.S. What Makes Good In-Context Examples for GPT-3? arXiv 2021, arXiv:2101.06804. [Google Scholar]
- OpenAI. Fine-Tuning. Retrieved from OpenAI platform. 2023. Available online: https://platform.openai.com/docs/guides/fine-tuning (accessed on 1 November 2023).
- CincoDías-ElPaís. CincoDías Energía. Retrieved from CincoDías–ElPaís. 2018–2023. Available online: https://cincodias.elpais.com/noticias/energia/ (accessed on 1 December 2023).
- EnergyNews. EnergyNews Mercado Electrico. Retrieved from EnergyNews. 2018–2023—Todo Energía. Available online: https://www.energynews.es/mercadoelectrico/ (accessed on 1 December 2023).
- GrupoASE. Informe Mercado. 2018–2023. Retrieved from Grupo ASE. Available online: https://informesdemercado.grupoase.net/en/inicio-2/ (accessed on 1 December 2023).
- Exclusivas Energéticas. Informes Mindee. 2018–2023. Retrieved from Exclusivas Energéticas. Available online: https://exclusivas-energeticas.com/ (accessed on 1 December 2023).
- Engle, R.F. Measuring and testing the impact of news on volatility. J. Financ. 1993, 48, 1749–1778. [Google Scholar] [CrossRef]
- Lewis, P.; Perez, E.; Piktus, A.; Petroni, F.; Karpukhin, V.; Goyal, N.; Küttler, H.; Lewis, M.; Yih, W.T.; Rocktäschel, T.; et al. Retrieval-augmented generation for knowledge-intensive nlp tasks. Adv. Neural Inf. Process. Syst. 2020, 33, 9459–9474. [Google Scholar]
- Gao, Y.; Xiong, Y.; Gao, X.; Jia, K.; Pan, J.; Bi, Y.; Dai, Y.; Sun, J.; Wang, H. Retrieval-augmented generation for large language models: A survey. arXiv preprint 2023, arXiv:2312.10997. [Google Scholar]
Accuracy | In-Context | Fine-Tunned | VADER | BERT |
---|---|---|---|---|
Close Price | 0.67 | 0.71 | 0.68 | 0.70 |
High/Low | 0.76 | 0.81 | 0.77 | 0.79 |
Threshold 2% | 0.59 | 0.65 | 0.55 | 0.57 |
MCC | In-Context | Fine-Tunned | VADER | BERT |
---|---|---|---|---|
Close Price | 0.35 | 0.49 | 0.33 | NaN |
High/Low | 0.53 | 0.64 | 0.52 | NaN |
Threshold 2% | 0.20 | 0.32 | 0.07 | NaN |
Accuracy | In-Context | Fine-Tunned | VADER | BERT |
---|---|---|---|---|
Close Price | 0.69 | 0.81 | 0.71 | 0.69 |
High/Low | 0.90 | 0.93 | 0.95 | 0.94 |
Threshold 5% | 0.81 | 0.86 | 0.83 | 0.79 |
MCC | In-Context | Fine-Tunned | VADER | BERT |
---|---|---|---|---|
Close Price | 0.35 | 0.63 | 0.36 | NaN |
High/Low | 0.61 | 0.87 | 0.89 | NaN |
Threshold 5% | 0.47 | 0.74 | 0.64 | NaN |
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |
© 2024 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https://creativecommons.org/licenses/by/4.0/).
Share and Cite
Menéndez Medina, A.; Heredia Álvaro, J.A. Using Generative Pre-Trained Transformers (GPT) for Electricity Price Trend Forecasting in the Spanish Market. Energies 2024, 17, 2338. https://doi.org/10.3390/en17102338
Menéndez Medina A, Heredia Álvaro JA. Using Generative Pre-Trained Transformers (GPT) for Electricity Price Trend Forecasting in the Spanish Market. Energies. 2024; 17(10):2338. https://doi.org/10.3390/en17102338
Chicago/Turabian StyleMenéndez Medina, Alberto, and José Antonio Heredia Álvaro. 2024. "Using Generative Pre-Trained Transformers (GPT) for Electricity Price Trend Forecasting in the Spanish Market" Energies 17, no. 10: 2338. https://doi.org/10.3390/en17102338
APA StyleMenéndez Medina, A., & Heredia Álvaro, J. A. (2024). Using Generative Pre-Trained Transformers (GPT) for Electricity Price Trend Forecasting in the Spanish Market. Energies, 17(10), 2338. https://doi.org/10.3390/en17102338