online gambling singapore online gambling singapore online slot malaysia online slot malaysia mega888 malaysia slot gacor live casino malaysia online betting malaysia mega888 mega888 mega888 mega888 mega888 mega888 mega888 mega888 mega888 Classifying News Sentiments using python

摘要: Sentiment Analysis on Stock Market Data



▲圖片來源:Adeolu Eletu on Unsplash

Using python code to prioritize news articles to read based on how good or bad the news is with respect to various companies or assets in a portfolio.

I will show you how I am able to analyze news headlines across many asset in my stock portfolio using web scrapping techniques and natural language processing (NLP) .

What is a Stock Portfolio?

Stock portfolio is a collection of stocks that you invest in with the hope of making a profit. By putting together a diverse portfolio that spans various sectors you’re able to become a more resilient investor. That’s because if one sector takes a hit, the investments you hold in other sectors aren’t necessarily affected.

What is Web Scraping?

Web scraping refers to the extraction of data from a website. This information is collected and then exported into a format that is more useful for the user. Be it a spreadsheet or an API.

What is Natural Language Processing?

Natural language processing (NLP) is a branch of artificial intelligence that helps computers understand, interpret and manipulate human language. NLP draws from many disciplines, including computer science and computational linguistics, in its pursuit to fill the gap between human communication and computer understanding.


Next, we want to extract news articles for the different assets in our portfolio from a news source, here we use Then we store it in a python dictionary.


Extract features we want from the webpage we copied from finviz


Here we apply Natural Language Processing with the help of the Sentiment Intensity Analyzer from the NLP toolkit. A positive value means it is a good news and the value shows how strong the good news is and vice versa



Finally, let’s make a plot to visualize the sentiments for our companies over a defined period.




With the help of a few lines of code, we have been able to visualize sentiments extracted from news headlines.

This helps us make informed decisions about buying or selling an asset from our portfolio.

It also saves us time from having to read through every news headline

● ● ●

Sentiment analysis (or opinion mining) is a natural language processing technique used to determine whether data is positive, negative or neutral. Its application ranges from various domains, Sentiment analysis is often performed on textual data to help businesses monitor brand and product sentiment in customer feedback, and understand customer needs.


若喜歡本文,請關注我們的臉書 Please Like our Facebook Page:    Big Data In Finance




  • 找不到回應