Home Forum

Clear all

Tool to Leverage Social Media in Fundamental Research Process  

Hassan El-Essawi
Posts: 7
Active Member
Joined: 2 years 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: [email protected]


@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:
analysis = TextBlob(tweet.text)
if analysis.sentiment[0]>0:
print ('Positive')
elif analysis.sentiment[0]<0:
print ('Negative')
print ('Neutral')  
2 Replies
David Munday
Posts: 1
New Member
Joined: 1 year 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. 

1 Reply
Hassan El-Essawi
Joined: 2 years ago

Active Member
Posts: 7


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