Examining Algorithms that drive the Stock Market through visualizations
Sentiments can often drive the direction of the stock markets. Traders, analysts and other participants in the financial market seek to gauge the sentiment expressed in news reports/tweets/blog posts.
Recently, it has become more common for these participants to build automatic trading systems which extract the sentiment from natural language.
The language used by people in their daily online activity help generate the demand or supply of items in the markey when these automated trading systems take long/short positions in the markets based on the indication of the algorithm.
Here we explore the phenomenon using the 'Bag of words' algorithm
We shall see the manner in which words in a given document is used to get the strength and sentiment of each phrase -
In this data visualization we explore the algorithm's workings in the three broadly classified steps:-
1. Collecting popular words or trends (here shown in .txt file)
2. Extracting the sentiment from natural language based on count and connotation
3. Taking long/short positions on the trading signals
Type a word to see it's Score! Score is based on (weighted) sum of positive words and negative words, divided by total number of words.
There have been several instances of wherein this algorithm and approach have been used to sway the market.
See the resulting line graph here
Investors buy stocks while they are bullish according to the popularity of the things spoken by people on the internet and then have the power to move and sway the market to make it bearish in just a few days time.
Shown below is a plot of NIFTY vs NIFTY Pharma for the months of October-November 2016. It highlights some of the press releases on which the sentiment analysis model was run.
The impact of the uncertainty regarding the US Presidential election results, and the negative news for the Indian Pharma sector emanating from the US is clearly visible on NIFTY Pharma as it fell substantially from the highs made in late October’2016. One could say that our attempt to gauge the direction of the Pharma Index follows a trend of the actual market very closely.
Methodology and credit:
Bag of words sentiment analysis example data inspired by https://www.quantinsti.com/blog/sentiment-analysis-in-trading/