Python project for sentiment analysis for r/WallStreetBets and Yahoo Finance, creating a stock chart with volume, and parsing for relevant news and posts
This Python application uses yfinance, Python Reddit API Wrapper (PRAW), Plotly, and Pandas to parse and utilize data from Yahoo Finance as well as r/WallStreetBets.
User is prompted for a stock ticker, which is then validated. The valid ticker is then used to parse through r/WallStreetBets relevant posts as well as Yahoo Finance's data to determine sentiment of a stock based on a scale from 1.0-5.0 (as seen below). Keywords are used to indicate attitude towards user-input stock.
PRAW and yfinance libraries are used to find and select relevant posts on r/WallStreetBets as well as news from Yahoo Finance. Lastly, yfinance and plotly libraries are used to visualize stock opening, closing, high, low, as well as volume on a candlestick chart (which opens on localhost).
- Python Reddit API Wrapper (PRAW) version: 7.6.0
- yfinance version: 0.1.74
- Pandas version: 1.4.4
- Plotly version: 5.9.0
To run this project, install these packages:
$ pip install praw
$ pip install yfinance
$ pip install pandas
$ pip install plotly
A Reddit username and password are required to run this program. Login or create an account here. Make sure the account is a standalone account that is not obtained via logging in through Google, Apple, etc.
A client ID and client secret is also required to use the Reddit API. You can register and obtain the required credentials by following the steps here.
Make sure to update the code at the top of the program to include your credentials.
I hope to implement this Python program into a web app, possibly through Django or Flask.
Here are some resources I used to create this project.
- https://pypi.org/project/yfinance/
- https://praw.readthedocs.io/en/latest/getting_started/quick_start.html
- https://praw.readthedocs.io/en/stable/code_overview/models/subreddit.html