Stock exchange analysis is regarded as a stochastic and demanding real-world setting in which fluctuations in stock prices are influenced by a wide range of aspects and events. In recent years, there has been a great deal of interest in social media-based data analytics for analyzing stock exchange markets. This is due to the fact that the sentiments around major global events like Brexit or COVID-19 significantly affect business decisions and investor perceptions, as well as transactional trading statistics and index values. Hence, in this research, we examined a case study from the Brexit event to assess the influence that feelings on the subject have had on the stock markets of European Union (EU) nations. Brexit has implications for Britain and other countries under the umbrella of the European Union (EU). However, a common point of debate is the EU’s contribution preferences and benefit imbalance. For this reason, the Brexit event and its impact on stock markets for major contributors and countries with minimum donations need to be evaluated accurately. As a result, to achieve accurate analysis of the stock exchanges of different EU nations from two different viewpoints, i.e., the major contributors and countries contributing least, in response to the Brexit event, we suggest an optimal deep learning and machine learning model that incorporates social media sentiment analysis regarding Brexit to perform stock market prediction. More precisely, the machine learning-based models include support vector machines (SVM) and linear regression (LR), while convolutional neural networks (CNNs) are used as a deep learning model. In addition, this method incorporates around 1.82 million tweets regarding the major contributors and countries contributing least to the EU budget. The findings show that sentiment analysis of Brexit events using a deep learning model delivers better results in comparison with machine learning models, in terms of root mean square values (RMSE). The outcomes of stock exchange analysis for the least contributing nations in relation to the Brexit event can aid them in making stock market judgments that will eventually benefit their country and improve their poor economies. Likewise, the results of stock exchange analysis for major contributing nations can assist in lowering the possibility of loss in relation to investments, as well as helping them to make effective decisions.