Home Forum

Tool to Leverage Social Media in Fundamental Research Process  


Hassan El-Essawi
Posts: 7
(@haasssan-e)
Active Member
Joined: 6 months ago

I adapted a tool that relies on the Tweepy library to pull Twitter data, and the TextBlob library for simple NLP, to generate sentiment data for N number of tweets containing a given keyword. I believe this has a myriad of applications ranging from forecasting earnings reports with end-consumer data to predicting policy changes in government that will impact regulation in various industries.

 

I have attached the Python script to this post, as well as a link at the bottom to a research report I prepared on a US public equity using data the tool generated as a supporting set of evidence to support the investment thesis. I would love any feedback/improvements on the tool or the report, feel free to message here or contact me by email: hassanselessawi@gmail.com

Report


@author: hassanel-essawi
"""

import tweepy
from textblob import TextBlob

consumer_key = 'x'
consumer_key_secret = 'y'
access_token = 'z'
access_token_secret = 'a'


auth = tweepy.OAuthHandler(consumer_key, consumer_key_secret)
auth.set_access_token(access_token, access_token_secret)
api = tweepy.API(auth)

public_tweets = api.search('Trump')

for tweet in public_tweets:
print(tweet.text)
analysis = TextBlob(tweet.text)
print(analysis.sentiment)
if analysis.sentiment[0]>0:
print ('Positive')
elif analysis.sentiment[0]<0:
print ('Negative')
else:
print ('Neutral')  
2 Replies
David Munday
Posts: 1
(@davidglobalprime)
New Member
Joined: 1 month ago

This seems very interesting, I'd love to give it a try, I believe I can find the application for this in my business. 

Reply
1 Reply
Hassan El-Essawi
(@haasssan-e)
Joined: 6 months ago

Active Member
Posts: 7

@davidglobalprime

Hey David, I'm glad you found it interesting, I'd love to learn more about what you're using it for. 

Reply
Share:

Please Login or Register