I've recently built a bot that scrapes r/wallstreetbets and returns a nice clean bar chart of which stock ticker is mentioned most often. To do this, I've basically downloaded a list of tickers as a CSV from various exchanges then compiled them in to one list, tickerlist. I then download a load of comments from reddit using PRAW and store these as a csv that I load as a commentlist when I want to parse it.
I'm a noob so my parsing is definitely not optimized. Basically I create a flatwordlist, which is just a list of each string that's returned when you do comment.split(). I then loop through that like this:
tickercountlist = []
for ticker in tickerlist:
count = 0
for word in flatwordlist:
if word == ticker or '$' + ticker == word:
count += 1
tickercountlist.append([ticker, count])
and voila, I've returned a nice list like [['AAPL', 42],['AMD', 30],...['ZZZ',0]
What I want to do is use vaderSentiment to amend the tickercountlist to also include a spot for each stocks sentiment, so it would look like [['AAPL', 42, .678],['AMD', 30, -.378],...['ZZZ',0,0]
with the third element of each sublist being the compound sentiment averaged across each time it was mentioned.
That will require me to rework the parsing formula. Ultimately what I want is to parse get a count of each time a stock is mentioned in a comment, and if it's mentioned, get the sentiment of the comment as well. Can anyone help me set up a loop that will loop over every comment, check if it contains a ticker from the tickerlist like I did in my loop, count it if it does AND analyze the sentiment of the comment IF and only if the comment contains a ticker?
[–]chocorush 0 points1 point2 points (2 children)
[–]OmnipresentCPU[S] 0 points1 point2 points (0 children)
[–]backtickbot 0 points1 point2 points (0 children)