Abstract:
This research presents a hybrid framework for stock market forecasting and trading that combines Long Short-Term Memory (LSTM) networks with sentiment-driven Deep Q-Network (DQN) reinforcement learning. The framework is evaluated on five years of Apple Inc. (AAPL) daily market data and sentiment from financial news and social media. The objective of the study was to enhance stock price prediction accuracy and optimize trading strategies by integrating market data with investor sentiment signals extracted from financial news and social media. The methodology comprises three key components: (1) data preprocessing to integrate technical indicators such as moving averages and trading volume with sentiment scores derived through natural language processing, (2) an LSTM model to predict next-day stock prices based on historical and sentiment-enhanced inputs, and (3) the design of a DQN agent that used LSTM predictions and sentiment data as its state representation to learn optimal buy, hold, or sell strategies. The LSTM model demonstrated improved forecasting accuracy compared to baseline models such as ARIMA, with lower root mean squared error (RMSE) and a higher Coefficient of Determination (R²). Furthermore, simulation results showed that the reinforcement learning agent achieved higher profitability and stronger risk-adjusted returns (e.g., Sharpe ratio) than rule-based strategies, while accounting for transaction costs. The findings highlight the importance of incorporating sentiment into predictive models and demonstrate that reinforcement learning can transform forecasts into adaptive, profitable trading actions. The sentiment-augmented LSTM outperforms ARIMA baselines, and the integrated DQN trading agent exceeds rule-based and random strategies in return and Sharpe ratio. This work contributes to financial machine learning by integrating predictive modeling with decision-making optimization.