Sentiment Analysis of Stock Market in Python (Part 2)- Estimating Sentiment Scores with NLTK

Bee Guan Teo
The Handbook of Coding in Finance
5 min readOct 7, 2021

--

Photo by Obi Onyeador on Unsplash

This article is the second part of my earlier article about sentiment analysis of the stock market in Python. If you haven’t gone through the first part of my article, you are welcome to visit the previous article to gain the overall picture of the topic:

Sentiment Analysis of Stock Market in Python (Part 1)- Web Scraping Financial News

In this Part 2 article, we are going to proceed with the pre-processed news data from Part 1 and use the Python NLTK package to calculate the sentiment score.

Disclaimer: The writing of this article is only aimed at demonstrating the steps to perform stock market sentiment analysis in Python. It doesn’t serve any purpose of promoting any stock or giving any specific investment advice.

Github

The original full source codes presented in this article are available on my Github Repo. Feel free to download it (SentimentAnalysis_part2.py) if you wish to use it to follow my article.

Estimating Sentiment Score with NLTK

From Part 1, we have already acquired news data from Financial Modeling Prep (FMP), process it and store it in a dataframe.

--

--