MCPcopy
hub / github.com/owocki/pytrader / handle

Method handle

history/management/commands/pull_twitter.py:14–36  ·  view source on GitHub ↗
(self, *args, **options)

Source from the content-addressed store, hash-verified

12 help = 'pulls twitter mentions and stores them in a DB'
13
14 def handle(self, *args, **options):
15
16 api = twitter.Api(consumer_key=settings.TWITTER_CONSUMER_KEY,
17 consumer_secret=settings.TWITTER_CONSUMER_SECRET,
18 access_token_key=settings.TWITTER_ACCESS_TOKEN_KEY,
19 access_token_secret=settings.TWITTER_ACCESS_TOKEN_SECRET)
20
21 for currency_symbol in settings.SOCIAL_NETWORK_SENTIMENT_CONFIG['twitter']:
22 print(currency_symbol)
23 results = api.GetSearch("$" + currency_symbol, count=200)
24 for tweet in results:
25
26 if SocialNetworkMention.objects.filter(network_name='twitter', network_id=tweet.id).count() == 0:
27 snm = SocialNetworkMention.objects.create(
28 network_name='twitter',
29 network_id=tweet.id,
30 network_username=tweet.user.screen_name,
31 network_created_on=datetime.datetime.fromtimestamp(tweet.GetCreatedAtInSeconds()),
32 text=tweet.text,
33 symbol=currency_symbol,
34 )
35 snm.set_sentiment()
36 snm.save()

Callers

nothing calls this directly

Calls 2

set_sentimentMethod · 0.80
saveMethod · 0.45

Tested by

no test coverage detected