Skip to content

iqrabismii/Stock-Sentiment-from-News-Headlines

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

🗞️ 📰 Extracting Stock Sentiment from News Headlines

Matplotlib

Introduction

This case study is from DataCamp. In this notebook, I have use sentiment analysis on financial news headlines from FINVIZ.com to gain investing insights. By understanding the emotions behind the headlines, we can predict the market's sentiment towards a stock and make educated guesses on its performance, allowing for informed trading decisions. The use of data science in processing this vast amount of information allows for quick analysis, unlike the traditional method of spreading news via radio, newspapers and word of mouth which used to take days.

Importing the HTML Files

To import the HTML files for Facebook and Tesla, we will use the os library to locate the files on our local system and read them into memory. This will allow us to access the data in the files and perform sentiment analysis on the headlines to generate investing insight and make educated guesses about stock performance.Datasets are available here.

Vader Sentiment Analysis

Vader Sentiment Analysis is a pre-trained model that uses natural language processing (NLP) to determine the sentiment of a given text. It is specifically designed to analyze social media text, which typically includes a lot of slang, emoticons, and other non-standard forms of language. The model uses a combination of lexical heuristics, such as word-level sentiment scores, and grammatical heuristics, such as the use of negation and punctuation, to determine the overall sentiment of the text. The output of the model is a sentiment score on a scale of -1 to 1, where -1 represents a negative sentiment, 0 represents a neutral sentiment, and 1 represents a positive sentiment.

Extracting the Headlines

Let's extract the news headlines from the HTML files we imported into memory. We can see that the relevant information is located within the text inside the and tags of each table row (). We will use this information to create a structured data set for further analysis. More details can be found here.

Implementing the Vader Function

Using VADER "as is" for sentiment analysis on financial news headlines may not be sufficient for producing profitable results. A more effective approach would involve creating a specialized lexicon specific to financial news and potentially developing a custom model. I used the vader sentiment analysis method to classify the headlines in the financial news dataset as negative, neutral, or positive. I then integrated the results of this analysis into the original dataset for further visualization and analysis.

Insights

It was observed that Tesla had more negative score as compared to FB. Also, Stock for FB was observed for one particular and most of the headlines were neutral.

About

Extracting Stock Sentiment from News Headlines using NLP

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published