Collabortation between Joyce Lu, Wan-Rong Leung, and Monica Dai.
This project aims to analyze the sentiment of news articles and YouTube videos related to Bitcoin and correlate it with its price (BTC-USD) over a period of time. The project uses sentiment analysis models and various APIs to gather data, process it, and visualize the results.
The project fetches and analyzes sentiment from news articles and YouTube videos related to Bitcoin. It then visualizes the sentiment trends alongside the Bitcoin closing prices.
- Fetch news articles and YouTube videos related to Bitcoin.
- Perform sentiment analysis on the fetched data.
- Visualize sentiment trends and correlate them with Bitcoin's closing prices.
- Summarize daily sentiment data for both news and YouTube content.
- Python 3.8 or higher
googleapiclient
youtube-transcript-api
transformers
beautifulsoup4
pandas
matplotlib
requests
python-dotenv
-
Clone the repository:
git clone https://github.com/yourusername/Stock-Market-Sentiment-Analysis.git cd Stock-Market-Sentiment-Analysis
-
Install the required Python packages:
pip install -r requirements.txt
-
Set up your environment variables:
- Create a .env file in the root directory.
- Create your API keys for the News API and YouTube Data API.
- Add your API keys to the .env file:
YOUTUBE_API_KEY=replace_with_your_youtube_api_key
NEWS_API_KEY=replace_with_your_news_api_key
- Place your Bitcoin CSV data file in the /data directory and ensure it is named BTC-USD.csv.
To run the project, execute the main script:
python main.py
The script will:
- Fetch news articles and YouTube videos from the past 10 days related to Bitcoin.
- Perform sentiment analysis on the fetched content.
- Visualize the sentiment trends and correlate them with Bitcoin's closing prices (from the past 10 days).
- Output a summary of the sentiment analysis.
- News Articles: Fetched using the News API.
- YouTube Videos: Fetched using the YouTube Data API.
- Sentiment Analysis Model: Using the ProsusAI FinBERT model.
- Stock Prices: Loaded from a CSV file (BTC-USD.csv).
main.py
: The main script that runs the project.news_sentiment.py
: Contains the NewsSentimentAnalyzer class to analyze news article sentiments.youtube_sentiment.py
: Contains functions for extracting and analyzing YouTube video transcripts.data/
: Directory to store the CSV file containing Bitcoin prices.transcripts/
: Directory to store fetched YouTube video transcripts..env
: Environment variables file (not included in the repository).requirements.txt
: List of Python packages required for the project.