[Paper Review] Trading the Twitter Sentiment with Reinforcement Learning
This paper proposes a reinforcement learning (Q-learning) framework that uses Twitter sentiment as a signal to generate optimal stock trading strategies, outperforming traditional machine learning-based trading models. It demonstrates that sentiment has stronger predictive power for growth-driven stocks like Tesla, especially during high-visibility events, and that Q-learning adapts better to market shifts than backtested strategies.
This paper is to explore the possibility to use alternative data and artificial intelligence techniques to trade stocks. The efficacy of the daily Twitter sentiment on predicting the stock return is examined using machine learning methods. Reinforcement learning(Q-learning) is applied to generate the optimal trading policy based on the sentiment signal. The predicting power of the sentiment signal is more significant if the stock price is driven by the expectation of the company growth and when the company has a major event that draws the public attention. The optimal trading strategy based on reinforcement learning outperforms the trading strategy based on the machine learning prediction.
Motivation & Objective
- To evaluate the predictive power of Twitter sentiment on stock returns, particularly in relation to market expectations and company-specific events.
- To develop a reinforcement learning-based trading strategy that uses sentiment features as part of the state space to optimize trading decisions.
- To compare the performance of Q-learning-based strategies against machine learning-based strategies and baseline models in real-world backtesting.
- To investigate whether sentiment signals are more effective for stocks driven by public expectations rather than fundamentals.
- To explore how reinforcement learning can adapt to changing market regimes without overfitting to historical data
Proposed method
- Collected daily Twitter data from January 2015 to June 2017 using web scraping, focusing on Tesla and Ford as case studies.
- Preprocessed tweets by removing URLs, hashtags, user mentions, emojis, and non-English content using Langdetect and custom filters.
- Assigned sentiment scores to tweets using Stanford CoreNLP, with sentence-level sentiment scores (0–4) averaged per tweet and normalized to [0,1].
- Constructed sentiment-based features (e.g., daily sentiment mean, volume, momentum) and combined them with technical indicators (e.g., price momentum) as input states for Q-learning.
- Applied Epsilon-greedy exploration in Q-learning to balance exploitation of learned policies and exploration of new actions.
- Trained the Q-learning agent to maximize cumulative reward (portfolio return) by learning state-action value functions Q(s,a) through temporal difference updates
Experimental results
Research questions
- RQ1Does Twitter sentiment have predictive power for stock returns, and is this power stronger for growth-oriented stocks like Tesla compared to fundamentals-driven stocks like Ford?
- RQ2How does the performance of a Q-learning-based trading strategy compare to a machine learning-based strategy that uses sentiment and technical indicators for binary price direction prediction?
- RQ3Does the inclusion of sentiment features improve trading performance over a baseline model that uses only technical indicators?
- RQ4How does the Q-learning agent handle market regime shifts and rare or outlier states during training?
- RQ5Can reinforcement learning generate more robust and adaptive trading policies than traditional backtesting methods?
Key findings
- Twitter sentiment has stronger predictive power for stocks driven by market expectations and public sentiment, such as Tesla, especially during periods of high Twitter volume.
- The Q-learning-based trading strategy outperformed both the machine learning-based strategy and the baseline model in cumulative returns over a one-year backtest.
- The Q-learning agent showed improved performance over time as it accumulated experience, but initial performance was unstable due to limited exploration in rare states.
- The machine learning strategy, which predicted binary price direction (+/-) based on sentiment and technical indicators, still outperformed the baseline model that used only technical indicators.
- The oracle model (with insider information) achieved a 6x return, indicating that the Q-learning strategy captured a significant portion of the available alpha, though not all.
- The Q-learning model demonstrated adaptability to market regime shifts and avoided overfitting, unlike traditional backtesting approaches
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.