Skip to main content
QUICK REVIEW

[Paper Review] Stock price prediction using BERT and GAN

Priyank Sonkiya, Vikas Bajpai|arXiv (Cornell University)|Jul 18, 2021
Stock Market Forecasting MethodsDecision Sciences34 references5 citations
TL;DR

This paper proposes S-GAN, an ensemble model that combines finBERT for sentiment analysis of financial news with a GAN using GRU as generator and 1D-CNN as discriminator to predict Apple Inc. stock prices. By using sentiment scores as latent noise, the model achieves 35% lower RMSE than vanilla GAN and outperforms LSTM, GRU, and ARIMA across 5-, 15-, and 30-day horizons.

ABSTRACT

The stock market has been a popular topic of interest in the recent past. The growth in the inflation rate has compelled people to invest in the stock and commodity markets and other areas rather than saving. Further, the ability of Deep Learning models to make predictions on the time series data has been proven time and again. Technical analysis on the stock market with the help of technical indicators has been the most common practice among traders and investors. One more aspect is the sentiment analysis - the emotion of the investors that shows the willingness to invest. A variety of techniques have been used by people around the globe involving basic Machine Learning and Neural Networks. Ranging from the basic linear regression to the advanced neural networks people have experimented with all possible techniques to predict the stock market. It's evident from recent events how news and headlines affect the stock markets and cryptocurrencies. This paper proposes an ensemble of state-of-the-art methods for predicting stock prices. Firstly sentiment analysis of the news and the headlines for the company Apple Inc, listed on the NASDAQ is performed using a version of BERT, which is a pre-trained transformer model by Google for Natural Language Processing (NLP). Afterward, a Generative Adversarial Network (GAN) predicts the stock price for Apple Inc using the technical indicators, stock indexes of various countries, some commodities, and historical prices along with the sentiment scores. Comparison is done with baseline models like - Long Short Term Memory (LSTM), Gated Recurrent Units (GRU), vanilla GAN, and Auto-Regressive Integrated Moving Average (ARIMA) model.

Motivation & Objective

  • To improve stock price prediction by integrating sentiment analysis from financial news with deep learning models.
  • To address the limitations of traditional time series models like ARIMA and RNNs in capturing complex market dynamics.
  • To explore the impact of sentiment as a latent vector in GAN-based stock price forecasting for improved convergence and accuracy.
  • To develop a practical, short-term prediction model applicable for intraday trading decisions.
  • To demonstrate the superiority of sentiment-informed GANs over conventional models in multi-horizon stock price forecasting.

Proposed method

  • Fine-tuned BERT (finBERT) is used to extract sentiment scores from news headlines and articles related to Apple Inc.
  • Technical indicators (e.g., 7-DMA, 21-DMA, RSI, MACD, Bollinger Bands, EMA, log momentum) and global market indexes are used as input features.
  • A GAN architecture is employed with a GRU-based generator and a 1D-CNN-based discriminator to generate future stock prices.
  • The generator uses sentiment scores as the latent noise vector instead of random Gaussian noise, enabling faster convergence and better performance.
  • The model is trained using Adam optimizer with a learning rate of 0.00016, batch size 128, and 165 epochs, minimizing mean squared error (MSE).
  • Performance is evaluated using RMSE on test data across 5-, 15-, and 30-day prediction horizons, compared against LSTM, GRU, vanilla GAN, and ARIMA.

Experimental results

Research questions

  • RQ1Can sentiment scores derived from financial news improve the performance of GAN-based stock price prediction models?
  • RQ2How does using sentiment as a latent vector in a GAN generator compare to using random noise in terms of convergence speed and prediction accuracy?
  • RQ3To what extent does the integration of technical indicators and sentiment analysis enhance multi-horizon stock price forecasting compared to traditional models?
  • RQ4Does the proposed S-GAN model outperform established models like LSTM, GRU, and ARIMA in predicting Apple Inc. stock prices over short-term horizons?
  • RQ5Can the model be effectively applied for real-time or intraday trading decisions based on daily closing data and sentiment?

Key findings

  • The S-GAN model achieved a testing RMSE of 1.827, representing a 35% reduction compared to the vanilla GAN’s RMSE of 2.369.
  • On the 5-day horizon, S-GAN achieved an RMSE of 0.0122, outperforming ARIMA (0.121), LSTM (0.0196), GRU (0.01975), and vanilla GAN (0.0158).
  • On the 15-day horizon, S-GAN recorded an RMSE of 0.0366, significantly lower than ARIMA (0.3658), LSTM (0.0585), GRU (0.05925), and GAN (0.0474).
  • On the 30-day horizon, S-GAN achieved an RMSE of 0.0732, which is 50% lower than the RMSE reported by Zhang et al. (2019) for a similar model without sentiment.
  • The model demonstrated early convergence due to the inclusion of sentiment scores as latent input, indicating that sentiment provides meaningful prior information about market direction.
  • The S-GAN model successfully captured market trends and generated realistic price sequences, as confirmed by the discriminator’s ability to distinguish real from generated data in the adversarial training process.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.