Skip to content

Evaluates stock news sentiment using text analysis and reports whether the coverage is generally positive or negative.

Notifications You must be signed in to change notification settings

pdj555/stock-sentiment-analysis

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Stock Sentiment Analysis Tool

Description

This Python tool automates the process of sentiment analysis for news articles related to a given stock symbol. It utilizes the Natural Language Toolkit (NLTK) to preprocess the text, removing stopwords, and then applies the TextBlob library's NaiveBayesAnalyzer to determine the sentiment of the text. The tool calculates the average sentiment score from multiple news articles to provide an overview of the current sentiment towards a stock.

Installation

To run this tool, you will need Python and several dependencies. Install them using the following commands:

pip install nltk textblob requests
python -m textblob.download_corpora

Make sure you have an API key from NewsAPI, which you will insert into a .env file within your directory. The .env file should contain:

NEWSAPI_KEY=your_api_key

Usage

To analyze the sentiment for a particular stock, run the get_stock_sentiment function with the stock ticker as a string argument. For example:

get_stock_sentiment('TSLA')  # Replace 'TSLA' with your target stock ticker

The function will output the average sentiment score for the specified stock based on the fetched news articles.

About

Evaluates stock news sentiment using text analysis and reports whether the coverage is generally positive or negative.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages