This is a Streamlit app that provides an overview of the stock market sentiment based on recent Google News articles. The app analyzes the sentiment of stock market-related news articles, and displays a bar chart to visualize the sentiment ratings for each stock, as well as a table with reasons behind each sentiment.
The app requires the following Python packages:
- pandas
- streamlit
- python-dotenv
- google_news_python
- openai
Install the dependencies with the following command:
pip install -r requirements.txt
The app requires a .env
file in the project root directory with the following key:
OPENAI_KEY
: Your OpenAI API key for using the ChatGPT language model.
To run the Streamlit app, navigate to the project directory and execute the following command:
streamlit run main.py
The app performs the following tasks:
- Imports necessary modules and packages.
- Loads the API keys from the
.env
file. - Retrieves stock market-related news articles using the
GoogleNewsAPI
class. - Performs sentiment analysis on the collected news articles using the
StockSentimentAnalyzer
class. - Displays the Google News Data in a table.
- Displays a bar chart of sentiment ratings for each stock.
- Displays a table with reasons behind each sentiment.
To analyze a different set of news articles or change the search query, update the argument passed to the get_data()
method in the GoogleNewsAPI
class instantiation:
google_news_data = google_news_api.get_data("<your-search-query>")