Abstract
Stock price prediction is one of the most important aspects of business investment plans, and has been an attractive research topic for both researchers and financial analysts. Many previous studies indicated the effectiveness of social media sentiment in stock price predictions through time series modelling. However, the time series information hidden in consecutive trading days has not been fully explored. In this paper, we build a stock price prediction model based on attention-based Long Short Term Memory (ALSTM) network using price data, technical indicators and sentiment information from social media. We employed a novel method to feed the deep network with long time series data to learn the deep sequential information of stock price movement. A fine-tuned BERT sentiment classification model and a sentiment lexicon are proposed to extract deep sentiment tendency of social media posts. We conducted experiments on 28 stocks within three years’ transaction period, and the results show that: (1) evaluated by the indicators of the Mean Absolute Error (MAE), the Root Mean Square Error (RMSE) and the accuracy, our proposed method outperforms the baseline models in both validation and test data sets; (2) models incorporating stock prices, technical indicators and sentiment features perform better than models that only use partial data source; (3) the fine-tuned BERT model performs better in sentiment classification task, and the exploitation of the sentiment features computed with the use of BERT model also led to higher predicting accuracy compared with the features calculated using sentiment lexicon; and (4) setting the input window length to 5-day achieves the best performance in average prediction accuracy.
Similar content being viewed by others
Data availability
The datasets analysed during the current study are not publicly available due to data privacy policy but are available from the corresponding author on reasonable request.
References
Anjaria M, Guddeti RMR (2014) A novel sentiment analysis of social networks using supervised learning. Soc Netw Anal Min 4(1):181. https://doi.org/10.1007/s13278-014-0181-9
Antweiler W, Frank M (2004) Is all that talk just noise? The information content of internet stock message boards. J Financ 59:1259–1294. https://doi.org/10.2139/ssrn.282320
Baek Y, Kim HY (2018) ModAugNet: A new forecasting framework for stock market index value with an overfitting prevention LSTM module and a prediction LSTM module. Expert Syst Appl 113:457–480. https://doi.org/10.1016/j.eswa.2018.07.019
Baker M, Wurgler J (2006) Investor sentiment and the cross-section of stock returns. J Financ 61(4):1645–1680. https://doi.org/10.1111/j.1540-6261.2006.00885.x
Ballings M, Van den Poel D, Hespeels N, Gryp R (2015) Evaluating multiple classifiers for stock price direction prediction. Expert Syst Appl 42(20):7046–7056. https://doi.org/10.1016/j.eswa.2015.05.013
Bollen J, Mao H, Zeng X (2011) Twitter mood predicts the stock market. J Comput Sci 2(1):1–8. https://doi.org/10.1016/j.jocs.2010.12.007
Cambria E, Fu J, Bisio F, Poria S (2015) AffectiveSpace 2: enabling affective intuition for concept-level sentiment analysis. Proc AAAI 29:508–514
Cavalcante RC, Brasileiro RC, Souza VLF, Nobrega JP, Oliveira ALI (2016) Computational intelligence and financial markets: A survey and future directions. Expert Syst Appl 55:194–211. https://doi.org/10.1016/j.eswa.2016.02.006
Chandra R, Chand S (2016) Evaluation of co-evolutionary neural network architectures for time series prediction with mobile application in finance. Appl Soft Comput 49:462–473. https://doi.org/10.1016/j.asoc.2016.08.029
Checkley MS, Higón DA, Alles H (2017) The hasty wisdom of the mob: how market sentiment predicts stock market behavior. Expert Syst Appl 77:256–263. https://doi.org/10.1016/j.eswa.2017.01.029
Chen W, Yeo CK, Lau CT, Lee BS (2018) Leveraging social media news to predict stock index movement using RNN-boost. Data Knowl Eng 118:14–24. https://doi.org/10.1016/j.datak.2018.08.003
Chen M-Y, Liao C-H, Hsieh R-P (2019) Modeling public mood and emotion: stock market trend prediction with anticipatory computing approach. Comput Hum Behav 101:402–408. https://doi.org/10.1016/j.chb.2019.03.021
Chollet F (2016) Keras. https://github.com/keras-team/keras. Accessed 13 Feb 2023
Cortes C, Vapnik V (1995) Support vector network. Mach Learn 20:273–297. https://doi.org/10.1007/BF00994018
Oliveira FA, Zárate LE, de Azebedo Reis M, Nobre CN (2011) The use of artificial neural networks in the analysis and prediction of stock prices. 2011 IEEE international conference on systems, man, and cybernetics, pp 2151–215., https://doi.org/10.1109/ICSMC.2011.6083990
Devlin J, Chang M-W, Lee K, Toutanova K (2018) BERT: pre-training of deep bidirectional transformers for language understanding. https://doi.org/10.48550/arXiv.1810.04805
Eapen J, Bein D, Verma A (2019) Novel deep learning model with CNN and bi-directional LSTM for improved stock market index prediction. 2019 IEEE 9th annual computing and communication workshop and conference (CCWC), 0264-0270, https://doi.org/10.1109/CCWC.2019.8666592
Fama EF (1991) Efficient capital markets: II. J Financ 46(5):1575–1617. https://doi.org/10.1111/j.1540-6261.1991.tb04636.x
Faraji-Rad A, Pham M (2016) Uncertainty increases the reliance on affect in decisions. SSRN Electron J 44. https://doi.org/10.2139/ssrn.2715333
Fischer T, Krauss C (2018) Deep learning with long short-term memory networks for financial market predictions. Eur J Oper Res 270(2):654–669. https://doi.org/10.1016/j.ejor.2017.11.054
Gerlein EA, McGinnity M, Belatreche A, Coleman S (2016) Evaluating machine learning classification for financial trading: an empirical approach. Expert Syst Appl 54:193–207. https://doi.org/10.1016/j.eswa.2016.01.018
Giles C, Lawrence S (2001) Noisy time series prediction using recurrent neural networks and grammatical inference. Mach Learn 44:161–183. https://doi.org/10.1023/A:1010884214864
Gradojevic N, Lento C, Wright C (2007) Investment information content in Bollinger bands? Appl Financ Econ Lett 3:263–267. https://doi.org/10.1080/17446540701206576
Gunasekarage A, Power DM (2001) The profitability of moving average trading rules in south Asian stock markets. Emerg Mark Rev 2(1):17–33. https://doi.org/10.1016/S1566-0141(00)00017-0
Güreşen E, Kayakutlu G, Daim T (2011) Using artificial neural network models in stock market index prediction. Expert Syst Appl 38:10389–10397. https://doi.org/10.1016/j.eswa.2011.02.068
Harb JGD, Ebeling R, Becker K (2020) A framework to analyze the emotional reactions to mass violent events on twitter and influential factors. Inf Process Manag 57(6):102372. https://doi.org/10.1016/j.ipm.2020.102372
Henrique BM, Sobreiro VA, Kimura H (2018) Stock price prediction using support vector regression on daily and up to the minute prices. J Finance Data Sci 4(3):183–201. https://doi.org/10.1016/j.jfds.2018.04.003
Hiransha M, Gopalakrishnan EA, Menon VK, Soman KP (2018) NSE stock market prediction using deep-learning models. Procedia Comput Sci 132:1351–1362. https://doi.org/10.1016/j.procs.2018.05.050
Hochreiter S, Schmidhuber J (1997) Long short-term memory. Neural Comput 9:1735–1780. https://doi.org/10.1162/neco.1997.9.8.1735
Hung C (2017) Word of mouth quality classification based on contextual sentiment lexicons. Inf Process Manag 53(4):751–763. https://doi.org/10.1016/j.ipm.2017.02.007
Junqué de Fortuny E, De Smedt T, Martens D, Daelemans W (2014) Evaluating and understanding text-based stock price prediction models. Inf Process Manag 50(2):426–441. https://doi.org/10.1016/j.ipm.2013.12.002
Kempe D, Kleinberg J, Tardos É (2003) Maximizing the spread of influence through a social network. In: Proceedings of the ACM SIGKDD international conference on knowledge discovery and data mining, pp 137–146. https://doi.org/10.1145/956750.956769
Kim S-H, Kim D (2014) Investor sentiment from internet message postings and the predictability of stock returns. J Econ Behav Organ 107:708–729. https://doi.org/10.1016/j.jebo.2014.04.015
Kim T, Kim H (2019) Forecasting stock prices with a feature fusion LSTM-CNN model using different representations of the same data. PLoS One 14:e0212320. https://doi.org/10.1371/journal.pone.0212320
Kim HY, Won CH (2018) Forecasting the volatility of stock price index: A hybrid model integrating LSTM with multiple GARCH-type models. Expert Syst Appl 103:25–37. https://doi.org/10.1016/j.eswa.2018.03.002
Kingma D, Ba J (2014) Adam: A method for stochastic optimization. International Conference on Learning Representations
Klinker F (2011) Exponential moving average versus moving exponential average. Math Semesterber 58:97–107. https://doi.org/10.1007/s00591-010-0080-8
Kumar S, Kumar K (2018) IRSC: integrated automated review mining system using virtual Machines in Cloud environment. 2018 Conference on Information and Communication Technology (CICT), 1–6, https://doi.org/10.1109/INFOCOMTECH.2018.8722387
Kumar K, Kurhekar M (2017) Sentimentalizer: Docker container utility over cloud. 2017 ninth international conference on advances in pattern recognition (ICAPR), 1–6, https://doi.org/10.1109/ICAPR.2017.8593104
Kumar K, Bamrara R, Gupta P, Singh N (2020) M2P2: Movie’s trailer reviews based movie popularity prediction system. In: Soft Computing: Theories and Applications, pp 671–681. https://doi.org/10.1007/978-981-15-0751-9_62
Kumar A, Purohit K, Kumar K (2021) Stock Price prediction using recurrent neural network and Long short-term memory. Conference proceedings of ICDLAIR2019, 153-160
Lee C, Soo V (2017) Predict stock Price with financial news based on recurrent convolutional neural networks. 2017 Conference on Technologies and Applications of Artificial Intelligence (TAAI), 160–165, https://doi.org/10.1109/TAAI.2017.27
Lee C, Swaminathan B (1999) Price momentum and trading volume. J Financ 55. https://doi.org/10.2139/ssrn.92589
Lee S, Ha T, Lee D, Kim JH (2018) Understanding the majority opinion formation process in online environments: an exploratory approach to Facebook. Inf Process Manag 54(6):1115–1128. https://doi.org/10.1016/j.ipm.2018.08.002
Li X, Xie H, Chen L, Wang J, Deng X (2014) News impact on stock price return via sentiment analysis. Knowl-Based Syst 69:14–23. https://doi.org/10.1016/j.knosys.2014.04.022
Li B, Chan KCC, Ou C, Ruifeng S (2017) Discovering public sentiment in social media for predicting stock movement of publicly listed companies. Inf Syst 69:81–92. https://doi.org/10.1016/j.is.2016.10.001
Li X, Wu P, Wang W (2020) Incorporating stock prices and news sentiments for stock market prediction: A case of Hong Kong. Inf Process Manag 57(5):102212. https://doi.org/10.1016/j.ipm.2020.102212
Li Y, Bu H, Li J, Wu J (2020) The role of text-extracted investor sentiment in Chinese stock price prediction with the enhancement of deep learning. Int J Forecast 36(4):1541–1562. https://doi.org/10.1016/j.ijforecast.2020.05.001
Long J, Chen Z, He W, Wu T, Ren J (2020) An integrated framework of deep learning and knowledge graph for prediction of stock price trend: an application in Chinese stock exchange market. Appl Soft Comput 91:106205. https://doi.org/10.1016/j.asoc.2020.106205
Loughran TIM, McDonald B (2011) When is a liability not a liability? Textual analysis, dictionaries, and 10-Ks. J Financ 66(1):35–65. https://doi.org/10.1111/j.1540-6261.2010.01625.x
Mandic D, Chambers J (2001) Recurrent neural networks for Prediction: Learning Algorithms,Architectures and Stability. https://doi.org/10.1002/047084535X
Maqsood H, Mehmood I, Maqsood M, Yasir M, Afzal S, Aadil F, Selim MM, Muhammad K (2020) A local and global event sentiment based efficient stock exchange forecasting using deep learning. Int J Inf Manag 50:432–451. https://doi.org/10.1016/j.ijinfomgt.2019.07.011
Mourelatos M, Alexakos C, Amorgianiotis T, Likothanassis S (2018) Financial indices modelling and trading utilizing deep learning techniques: the ATHENS SE FTSE/ASE large cap use case. 2018 Innovations in Intelligent Systems and Applications (INISTA), 1–7, https://doi.org/10.1109/INISTA.2018.8466286
Nelson DMQ, Pereira ACM, Oliveira RAD (2017) Stock market's price movement prediction with LSTM neural networks. International Joint Conference on Neural Networks.
Nguyen TH, Shirai K, Velcin J (2015) Sentiment analysis on social media for stock movement prediction. Expert Syst Appl 42(24):9603–9611. https://doi.org/10.1016/j.eswa.2015.07.052
Oh C, Sheng O (2011) Investigating predictive Power of stock Micro blog sentiment in forecasting future stock Price directional movement. Proceedings of the international conference on information systems, ICIS 2011, Shanghai, China, December 4–7, 2011
Pang B, Lee L (2008) Opinion mining and sentiment analysis. Found Trends Inf Retr 2:1–135. https://doi.org/10.1561/1500000011
Pang X, Zhou Y, Wang P, Lin W, Chang V (2018) An innovative neural network approach for stock market prediction. J Supercomput 76:2098–2118. https://doi.org/10.1007/s11227-017-2228-y
Patel J, Shah S, Thakkar P, Kotecha K (2015) Predicting stock and stock price index movement using trend deterministic data preparation and machine learning techniques. Expert Syst Appl 42(1):259–268. https://doi.org/10.1016/j.eswa.2014.07.040
Peng Y, Jiang H (2015) Leverage financial news to predict stock Price movements using word Embeddings and deep neural networks
Picasso A, Merello S, Ma Y, Oneto L, Cambria E (2019) Technical analysis and sentiment embeddings for market trend prediction. Expert Syst Appl 135:60–70. https://doi.org/10.1016/j.eswa.2019.06.014
Qian B, Rasheed K (2007) Stock market prediction with multiple classifiers. Appl Intell 26:25–33. https://doi.org/10.1007/s10489-006-0001-7
Qian Y, Li Z, Yuan H (2020) On exploring the impact of users’ bullish-bearish tendencies in online community on the stock market. Inf Process Manag 57(5):102209. https://doi.org/10.1016/j.ipm.2020.102209
Qu H, Zhang Y (2016) A new kernel of support vector regression for forecasting high-frequency stock returns. Math Probl Eng 2016:1–9. https://doi.org/10.1155/2016/4907654
Ratto AP, Merello S, Oneto L, Ma Y, Cambria E (2018) Ensemble of Technical Analysis and Machine Learning for market trend prediction. 2018 IEEE symposium series on computational intelligence (SSCI)
Rezaei H, Faaljou H, Mansourfar G (2020) Stock price prediction using deep learning and frequency decomposition. Expert Syst Appl 114332:114332. https://doi.org/10.1016/j.eswa.2020.114332
Schumaker RP, Chen H (2009) A quantitative stock prediction system based on financial news. Inf Process Manag 45(5):571–583. https://doi.org/10.1016/j.ipm.2009.05.001
Schumaker RP, Chen H (2009) Textual analysis of stock market prediction using breaking financial news: the AZFin text system. ACM J Trans Inf Syst 27(2):12. https://doi.org/10.1145/1462198.1462204
Sehgal V, Song C (2007) SOPS: stock prediction using web sentiment. Seventh IEEE international conference on data mining workshops (ICDMW 2007), 21–26, https://doi.org/10.1109/ICDMW.2007.100
Sharma S, Kumar P, Kumar K (2017) LEXER: LEXicon based emotion AnalyzeR. Pattern recognition and machine intelligence, pp 373–379. https://doi.org/10.1007/978-3-319-69900-4_47
Sharpe M, Walczak S (2001) An empirical analysis of data requirements for financial forecasting with neural networks. J Manag Inf Syst 17
Shynkevich Y, McGinnity TM, Coleman S, Belatreche A, Li Y (2017) Forecasting Price movements using technical Indicators: Investigating the Impact of Varying Input Window Length. Neurocomputing 264:71–88. https://doi.org/10.1016/j.neucom.2016.11.095
Si J, Mukherjee A, Liu B, Li Q, Deng X (2013) Exploiting Topic based Twitter Sentiment for Stock Prediction. ACL 2013
Sun C, Qiu X, Xu Y, Huang X (2019) How to fine-tune BERT for text classification? China National Conference on Chinese Computational Linguistics
Taylor M, Allen H (1992) The use of technical analysis in the foreign exchange market. J Int Money Financ 11:304–314. https://doi.org/10.1016/0261-5606(92)90048-3
Tieleman T, Hinton GE, Srivastava N, Swersky K (2012) Lecture 6.5-rmsprop: divide the gradient by a running average of its recent magnitude. Neural Networks for Machine Learning, COURSERA
Tsibouris G, Zeidenberg M (1995) Testing the efficient market hypothesis with gradient descent algorithms. Neural Netw Capital Markets 8:127–136
Vaswani A, Shazeer N, Parmar N, Uszkoreit J, Jones L, Gomez AN, Kaiser Ł, Polosukhin I (2017) Attention is all you need. Proceedings of the 31st international conference on neural information processing systems, 6000–6010
Verma I, Dey L, Meisheri H (2017) Detecting, Quantifying and Accessing Impact of News Events on Indian Stock Indices. https://doi.org/10.1145/3106426.3106482
Vijayvergia A, Kumar K (2018) STAR: rating of reviewS by exploiting variation in emoTions using trAnsfer leaRning framework. 2018 Conference on Information and Communication Technology (CICT), 1–6, https://doi.org/10.1109/INFOCOMTECH.2018.8722356
Vijayvergia A, Kumar K (2021) Selective shallow models strength integration for emotion detection using GloVe and LSTM. Multimed Tools Appl 80(18):28349–28363. https://doi.org/10.1007/s11042-021-10997-8
Vu TIT, Chang S (2012) An experiment in integrating sentiment features for tech stock prediction in twitter. Workshop on Information Extraction & Entity Analytics on Social Media Data
Wang Q, Xu W, Zheng H (2018) Combining the wisdom of crowds and technical analysis for financial market prediction using deep random subspace ensembles. Neurocomputing 299:51–61. https://doi.org/10.1016/j.neucom.2018.02.095
Xing F, Cambria E, Welsch R (2018) Intelligent asset allocation via market sentiment views. IEEE Comput Intell Mag 13:25–34. https://doi.org/10.1109/MCI.2018.2866727
Yeh C-Y, Huang C-W, Lee S-J (2011) A multiple-kernel support vector regression approach for stock market price forecasting. Expert Syst Appl 38(3):2177–2186. https://doi.org/10.1016/j.eswa.2010.08.004
Yong BX, Abdul Rahim MR, Abdullah AS (2017) A stock market trading system using deep neural network. In: Modeling, Design and Simulation of Systems, pp 356–364. https://doi.org/10.1007/978-981-10-6463-0_31
Yu JH, Kang J, Park S (2019) Information availability and return volatility in the bitcoin market: analyzing differences of user opinion and interest. Inf Process Manag 56(3):721–732. https://doi.org/10.1016/j.ipm.2018.12.002
Zhang X, Tan Y (2018) Deep stock ranker: A LSTM neural network model for stock selection. In (pp. 614-623). https://doi.org/10.1007/978-3-319-93803-5_58
Zhang L, Aggarwal C, Qi G-J (2017) Stock Price prediction via discovering multi-frequency trading patterns. Proceedings of the 23rd ACM SIGKDD international conference on knowledge discovery and data mining, 2141–2149. https://doi.org/10.1145/3097983.3098117
Zhang X, Zhang Y, Wang S, Yao Y, Fang B, Yu PS (2018) Improving stock market prediction via heterogeneous information fusion. Knowl-Based Syst 143:236–247. https://doi.org/10.1016/j.knosys.2017.12.025
Zhang Y, Chu G, Shen D (2020) The role of investor attention in predicting stock prices: the long short-term memory networks perspective. Financ Res Lett 101484. https://doi.org/10.1016/j.frl.2020.101484
Zhang YA, Yan B, Aasma M (2020) A novel deep learning framework: prediction and analysis of financial time series using CEEMD and LSTM. Expert Syst Appl 159:113609. https://doi.org/10.1016/j.eswa.2020.113609
Zuo Y, Kita E (2012) Stock price forecast using Bayesian network. Expert Syst Appl 39(8):6729–6737. https://doi.org/10.1016/j.eswa.2011.12.035
Zuo Y, Kita E (2012) Up/down analysis of stock index by using Bayesian network. Eng Manag Res 1. https://doi.org/10.5539/emr.v1n2p46
Acknowledgements
This paper was supported by the National Natural Science Foundation of China (project numbers are 72274096, 72174087, 71774084 and 71874082 ), the National Social Science Fund of China (project number is 17ZDA291), program for Jiangsu Excellent Scientific and Technological Innovation Team (project number is [2020]10).
Author information
Authors and Affiliations
Contributions
Zhongtian Ji: Conceptualization, Methodology, Investigation, Writing - original draft. Peng Wu: Project administration, Supervision, Writing - review & editing, Funding acquisition. Chen Ling: Formal analysis, Writing - review & editing, Data curation. Peng Zhu: Writing - review & editing.
Corresponding author
Ethics declarations
Conflict of interest
The authors declare that they have no conflict of interest.
Additional information
Publisher’s note
Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.
Rights and permissions
Springer Nature or its licensor (e.g. a society or other partner) holds exclusive rights to this article under a publishing agreement with the author(s) or other rightsholder(s); author self-archiving of the accepted manuscript version of this article is solely governed by the terms of such publishing agreement and applicable law.
About this article
Cite this article
Ji, Z., Wu, P., Ling, C. et al. Exploring the impact of investor’s sentiment tendency in varying input window length for stock price prediction. Multimed Tools Appl 82, 27415–27449 (2023). https://doi.org/10.1007/s11042-023-14587-8
Received:
Revised:
Accepted:
Published:
Issue Date:
DOI: https://doi.org/10.1007/s11042-023-14587-8