-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
60 lines (39 loc) · 1.44 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
"""
IOTA Twitter Sentiment Analyzer:
It gets all IOTA tweets of the day and outputs the overall sentiment.
Author: eep
based on the twitter senitment challenge by Siraj Parval
https://github.com/llSourcell/twitter_sentiment_challengey
"""
import tweepy
import numpy
from textblob import TextBlob
# Twitter Authentication
consumer_key= 'CKey_HERE'
consumer_secret= 'CSecretKey_HERE'
access_token= 'AT_HERE'
access_token_secret= 'ATS_HERE
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
api = tweepy.API(auth)
# Search IOTA tweets
query = 'IOTA'
max_tweets = 300
# Using cursors to fill in parameters and adjust size fo tweets
# https://github.com/tweepy/tweepy/blob/master/docs/cursor_tutorial.rst
tweets = [status for status in tweepy.Cursor(api.search, q=query).items(max_tweets)]
# avg_polarity list declartion
avg_polarity = []
# Feed tweets to TextBlob and filter needed tweets
for tweet in tweets:
analysis = TextBlob(tweet.text)
# Eliminate use only objective tweets to prevent bias
if (analysis.sentiment.subjectivity < 0.5):
avg_polarity.append(analysis.sentiment.polarity)
# Get average of polarity of sentiments
avg_polarity = numpy.average(avg_polarity)
# Output decision
if (avg_polarity > 0):
print "IOTA is looking pretty good. Check your technical analysis for points of entry."
else:
print "You might want to check other cryptos."