

Twitter Sentiment Analysis and Influence on Stock Performance Using Transfer Entropy and EGARCH Methods.
Abstract
1. Introduction
2. Materials and Methods
- (a)
- There is a relationship between stock price movements and the polarity of the top comments mentioning the ticker of a company.
- (b)
- The positive movements in polarity are larger and have more “density” than negative movements.
- (1)
- Extraction: A JSON artificially intelligent (AI) robot that looked for the top tweets that mentioned the tickers of 24 companies (i.e., for Tesla, the ticker would be $TSLA in the English language for the period of 2009–2019) was created.
- (2)
- Processing: The tweets were processed using natural language processing to calculate the weighted and normalized polarity. The grading polarity ranged from [−1, +1], so 0 refers to a completely neutral comment and +1 refers to a 100% positive text.Sentiment Index: With the polarity already calculated, the tweets were classified as positive or negative and assigned to the corresponding index. I a tweet was graded as 0 (completely neutral), it was discarded.
- (3)
- Analysis: The index vectors were paired with the companies’ daily closing performance and standardized. For each vector, including company performance, we subtracted the average from the daily observation and divided that value by its standard deviation. Under this treatment, we worked with normal distributions for the final data frame.
| N | Company | Ticker | Country | Tag * |
|---|---|---|---|---|
| 1 | Amazon | $AMZN | USA | amazon |
| 2 | $FB | USA | face | |
| 3 | Microsoft | $MSFT | USA | microsoft |
| 4 | eBay | $EBAY | USA | ebay |
| 5 | AT&T | $ATT | USA | att |
| 6 | $GOOG | USA | ||
| 7 | JP Morgan | $JPM | USA | jpm |
| 8 | Tesla | $TSLA | USA | tesla |
| 9 | IBM | $IBM | USA | ibm |
| 10 | Intel | $INTEL | USA | intel |
| 11 | Berkshire Hathaway | $BRKA | USA | brka |
| 12 | Exxon | $XOM | USA | exxon |
| 13 | Visa | $V | USA | visa |
| 14 | Bank of America | $BOA | USA | boa |
| 15 | Wells Fargo | $WFF | USA | wf |
| 16 | Procter & Gamble | $PG | USA | pg |
| 17 | Cisco | $CSCO | USA | csco |
| 18 | Johnson & Johnson | $JNJ | USA | jnj |
| 19 | General Electric | $GE | USA | ge |
| 20 | Royal Dutch | $RDSA | Netherlands | rdsa |
| 21 | Ten Cent | $TCEHYN | China | tencent |
| 22 | Volkswagen | $VW | Germany | vw |
| 23 | SAP | $SAP | Germany | sap |
| 24 | $TW | USA | tw |
2.1. Step 1: Text Mining
- Date: The selected period comprised from 1 January 2009 to 1 December 2018, which covered most of a full global economic cycle, i.e., from the aftermath of the 2008 financial crisis to the last months before the economic slowdown of 2019.
- Language: The language selected for analyzing the information was English.
- Key words: The only word that needed to be mentioned in each tweet was the company ticker (abbreviation used for trading preceded with the $ symbol).
- Top tweets: The search engine was able to classify the results of top tweets from a sample of 1% of the most commented and shared tweets.
The criteria were applied for the 24 companies considered in the study, and each company was mined individually, meaning that tweets that mentioned 2 or more companies could co-exist; in that case, if Robot 1 detected the same opinion with 2 different tickers, this opinion was used in our study in both the EGARCH model and the transfer entropy measurement. In the final part, each unprocessed database was chronologically ordered. This allowed us to compare data sizes and mention frequency since some companies were founded and traded well after 2009 (Facebook IPO was in 2012).
2.2. Step 2.1: Sentiment Analysis
accessed on 21 March 2020). This library calculated sentiment by breaking each individually analyzed text into the words that composed it. Single letter words were ignored, and for the rest of the text, a numeric value for polarity and subjectivity was given to each word that was already assigned inside the library. When composed expressions were used (e.g., ‘very1 great2’), the library recognized the emphasizing word ‘very’ that preceded ‘great’, for which polarity was ignored, and multiplied the intensity for the following words’ polarity.
‘$Tesla starts brutal review of contractors, firing everyone that is not vouched for by an employee via @FredericLambert’
‘tesla starts brutal review of contractors firing everyone that is not vouched for by an employee via fredericlambert’
‘[Sentence (“tesla starts brutal review of contractors firing everyone that is not vouched for by an employee via fredericlambert”)]’
‘WordList ([’tesla’, ‘starts’, ‘brutal’, ‘review’, ‘of’, ‘contractors’, ‘firing’, ‘everyone’, ‘that’, ‘is’, ‘not’, ‘vouched’, ‘for’, ‘by’, ‘an’, ‘employee’, ’via’, ‘fredriclambert’])’
Sentiment (polarity = −0.875, subjectivity = 1.0)
Each tweet in our unprocessed data was processed with the help of our automated robot (Robot 2).
2.3. Step 2.2: Index Construction
Finally, each vector was standardized; in this manner, we ensured the measurement of the effect of sentiment on the performance of the companies.
2.3.1. Step 3.A: Transfer Entropy
The transfer entropy calculation in Equation (11) can be applied to discrete data. Since the methodology in this study was applied to financial continuous data, the data were discretized by partitioning them into quantiles. A time series y(t) was partitioned to obtain the symbolically encoded sequence S(t). This sequence replaced the value in the observed time series by discrete states {1, 2, …, n − 1, n}. Denoting the pre-selected number of bins by q1, q2, q3, …, qn, where q1 < q2 < q3, …, < qn, each value in the original time series was replaced by an integer. Equation (11) could be considered biased, mainly by finite sample effects in this case. In addition, higher signal transfer from time series with higher entropy was expected. To reduce bias, effective transfer entropy was proposed in [34]:
3. Results
| Y | |||||||
|---|---|---|---|---|---|---|---|
| Stocks | Negative Index | Positive Index | |||||
| X->Y | Y->X | X->Y | Y->X | X->Y | Y->X | ||
| X | Stocks | 151 | 149 | 75 | 104 | 65 | 92 |
| Negative Index | 104 | 75 | 101 | 96 | 120 | 129 | |
| Positive Index | 92 | 65 | 129 | 120 | 128 | 127 | |
| Y | |||||||
|---|---|---|---|---|---|---|---|
| Stocks | Negative Indexes | Positive Indexes | |||||
| X->Y | Y->X | X->Y | Y->X | X->Y | Y->X | ||
| X | Stocks | 145 | 151 | 75 | 97 | 67 | 89 |
| Negative Index | 97 | 75 | 94 | 95 | 111 | 121 | |
| Positive Index | 89 | 67 | 121 | 111 | 123 | 128 | |
To calculate the intensity of the information transfer between vectors, we calculated the intensity signal with the ETE:
4. Discussion
5. Conclusions
Supplementary Materials
Author Contributions
Funding
Institutional Review Board Statement
Informed Consent Statement
Data Availability Statement
Conflicts of Interest
References
- DeGennaro, R.P.; Shrieves, R.E. Public information releases, private information arrival and volatility in the foreign exchange market. J. Empir. Financ. 1997, 4, 295–315. [Google Scholar] [CrossRef]
- Atkins, A.; Niranjan, M.; Gerding, E. Financial news predicts stock market volatility better than close price. J. Financ. Data Sci. 2018, 4, 120–137. [Google Scholar] [CrossRef]
- Audrino, F.; Sigrist, F.; Ballinaria, D. The impact of sentiment and attention measures on stock market volatility. Int. J. Forecast. 2020, 36, 334–357. [Google Scholar] [CrossRef]
- Ren, Y.; Liao, F.; Gong, Y. Impact of News on the Trend of Stock Price Change: An Analysis based on the Deep Bidirectiona LSTM. Procedia Comput. Sci. 2020, 174, 128–140. [Google Scholar] [CrossRef]
- Li, X.; Chen, L.; Wang, J.; Deng, X. News impact on stock price return via sentiment analysis. Knowl. Based Syst. 2014, 69, 14–23. [Google Scholar] [CrossRef]
- Vega, C. Stock price reaction to public and private information. J. Financ. Econ. 2006, 82, 103–133. [Google Scholar] [CrossRef]
- Chan, W.S. Stock price reaction to news and no-news: Drift and reversal after headlines. J. Financ. Econ. 2003, 70, 223–260. [Google Scholar] [CrossRef]
- Derakhshan, A.; Beigy, H. Sentiment analysis on stock social media for stock price movement prediction. Eng. Appl. Artif. Intell. 2019, 85, 569–578. [Google Scholar] [CrossRef]
- Antweiler, W.; Frank, M.Z. Is all that talk just noise? the information content of internet stock message boards. J. Financ. 2004, 59, 1259–1294. [Google Scholar] [CrossRef]
- Tumarkin, R.; Whitelaw, R.F. News or Noise? Internet Postings and Stock Prices. Financ. Anal. J. 2001, 57, 41–51. [Google Scholar] [CrossRef] [Green Version]
- Steinert, L.; Herff, C. Predicting altcoin returns using social media. PLoS ONE 2018, 13, e0208119. [Google Scholar] [CrossRef] [PubMed]
- Fischer, B. Studies of stock price volatility changes. In Proceedings of the American Statistical Association Business and Economic Statistics Section; American Statistical Association: Washington, DC, USA, 1976; pp. 177–181. [Google Scholar]
- Schwert, G.W. The Adjustment of Stock Prices to Information About Inflation. J. Financ. 1981, 36, 15–29. [Google Scholar] [CrossRef]
- Pearce, D.K.; Roley, V.V. Stock Prices and Economic News. J. Bus. 1985, 58, 49–67. [Google Scholar] [CrossRef] [Green Version]
- Cutler, D.M.; Poterba, J.M.; Summers, L.H. What moves stock prices? J. Portf. Manag. 1989, 15, 4–12. [Google Scholar] [CrossRef]
- McQueen, G.; Roley, V. Stock Prices, News and Business Conditions. Rev. Financ. Stud. 1993, 6, 683–708. [Google Scholar] [CrossRef]
- Kahneman, D.; Tversky, A. Prospect Theory: An Analysis of Decision Under Risk. Econometrica 1979, 47, 263–291. [Google Scholar] [CrossRef] [Green Version]
- Al Nasseri, A.; Ali, F.M.; Tucker, A. Good news and bad news: Do online investor sentiments reaction to return news asymmetric? MIDAS 2016, 1774, 55–66. [Google Scholar]
- Ruan, Y.; Durresi, A.; Alfantoukh, L. Using Twitter trust network for stock market analysis. Knowl. Based Syst. 2018, 145, 207–218. [Google Scholar] [CrossRef] [Green Version]
- Sun, W.; Cui, K. Linking corporate social responsibility to firm default risk. Eur. Manag. J. 2014, 32, 275–287. [Google Scholar] [CrossRef]
- Zhang, X.; Fuehres, H.; Gloor, P.A. Predicting Stock Market Indicators Through Twitter ‘I hope it is not as bad as I fear’. Procedia Soc. Behav. Sci. 2011, 26, 55–62. [Google Scholar] [CrossRef] [Green Version]
- Yang, S.Y.; Mo, S.Y.K.; Liu, A. Twitter financial community sentiment and its predictive relationship to stock market movement. Quant. Financ. 2015, 15, 1637–1656. [Google Scholar] [CrossRef] [Green Version]
- Nisar, T.M.; Yeung, M. Twitter as a tool for forecasting stock market movements: A short-window event study. J. Financ. Data Sci. 2018, 4, 101–119. [Google Scholar] [CrossRef]
- Pagol, V.S.; Challa, K.N.R.; Panda, G. Sentiment Analysis of Twitter Data for Predicting Stock Market Movements. Int. Conf. Signal Process. Commun. Power Embed. Syst. 2016. Available online: https://arxiv.org/pdf/1610.09225.pdf (accessed on 25 February 2021).
- García-Medina, A.; Junior, L.S.; Bañuelos, E.U.; Martínez-Argüello, A.M. Correlations and flow of information between the New York Times and stock markets. Phys. Stat. Mech. Its Appl. 2018, 502, 403–415. [Google Scholar] [CrossRef] [Green Version]
- Daradkeh, M.K. A Hybrid Data Analytics Framework with Sentiment Convergence and Multi-Feature Fusion for Stock Trend Prediction. Electronics 2022, 11, 250. [Google Scholar] [CrossRef]
- Koukaras, P.; Nousi, C.; Tjortjis, C. Stock Market Prediction Using Microblogging Sentiment Analysis and Machine Learning. Telecom 2022, 3, 358–378. [Google Scholar] [CrossRef]
- Maqsood, H.; Maqsood, M.; Yasmin, S.; Mehmood, I.; Moon, J.; Rho, S. Analyzing the Stock Exchange Markets of EU Nations: A Case Study of Brexit Social Media Sentiment. Systems 2022, 10, 24. [Google Scholar] [CrossRef]
- Yang, H.; Ryu, D. Investor Sentiment and Price Discrepancies between Common and Preferred Stocks in Korea. Sustainability 2021, 13, 5539. [Google Scholar] [CrossRef]
- Guijarro, F.; Moya-Clemente, I.; Saleemi, J. Liquidity Risk and Investors’ Mood: Linking the Financial Market Liquidity to Sentiment Analysis through Twitter in the S&P500 Index. Sustainability 2019, 11, 7048. [Google Scholar] [CrossRef] [Green Version]
- López-Cabarcos, M.Á.; Pérez-Pico, A.M.; López-Pérez, M.L. Does Social Network Sentiment Influence S&P 500 Environmental & Socially Responsible Index? Sustainability 2019, 11, 320. [Google Scholar] [CrossRef] [Green Version]
- Dogra, V.; Singh, A.; Verma, S.; Alharbi, A.; Alosaimi, W. Event Study: Advanced Machine Learning and Statistical Technique for Analyzing Sustainability in Banking Stocks. Mathematics 2021, 9, 3319. [Google Scholar] [CrossRef]
- Siev, S. The Rich Get Richer and the Poor Get Poorer: Social Media and the Post-IPO Behavior of Investors in Biotechnology Firms: The Relationship with Twitter Volume. J. Risk Financ. Manag. 2021, 14, 456. [Google Scholar] [CrossRef]
- Thomas, D.; Julia, P.F. Using transfer entropy to measure information flows between financial markets. Stud. Nonlinear Dyn. Econom. 2013, 17, 85–102. [Google Scholar]
- Fama, E. Efficient capital market: A review of theory and empirical work. J. Financ. 1970, 25, 383–417. [Google Scholar] [CrossRef]
- Scaramozzino, R.; Cerchiello, P.; Aste, T. Information Theoretic Causality Detection between Financial and Sentiment Data. Entropy 2021, 23, 621. [Google Scholar] [CrossRef]
- Olbryś, J.; Ostrowski, K. An Entropy-Based Approach to Measurement of Stock Market Depth. Entropy 2021, 23, 568. [Google Scholar] [CrossRef]
- Zhang, W.-G.; Liu, Y.-J.; Xu, W.-J. A possibilistic mean-semivariance-entropy model for multi-period portfolio selection with transaction costs. Eur. J. Oper. Res. 2012, 222, 341–349. [Google Scholar] [CrossRef]
- Usta, I.; Kantar, Y.M. Mean-variance-skewness-entropy measures: A multi-objective approach for portfolio selection. Entropy 2011, 13, 117–133. [Google Scholar] [CrossRef]
- Xu, Y.; Wu, Z.; Jiang, L.; Song, X. A maximum entropy method for a robust portfolio problem. Entropy 2014, 16, 3401–3415. [Google Scholar] [CrossRef] [Green Version]
- Yue, P.; Fan, Y.; Batten, J.A.; Zhou, W.-X. Information Transfer between Stock Market Sectors: A Comparison between the USA and China. Entropy 2020, 22, 194. [Google Scholar] [CrossRef] [Green Version]
- Balasudarsun, N.L.; Ghosh, B.; Mahendran, S. Impact of Negative Tweets on Diverse Assets during Stressful Events: An Investigation through Time-Varying Connectedness. J. Risk Financ. Manag. 2022, 15, 260. [Google Scholar] [CrossRef]
- Mendoza Urdiales, R.A.; García-Medina, A.; Nuñez Mora, J.A. Measuring information flux between social media and stock prices with Transfer Entropy. PLoS ONE 2021, 16, e0257686. [Google Scholar] [CrossRef] [PubMed]
