twitter – Twitter feed reference

Feed

class pyalgotrade.twitter.feed.TwitterFeed(consumerKey, consumerSecret, accessToken, accessTokenSecret, track=[], follow=[], languages=[])

Bases: pyalgotrade.observer.Subject

Class responsible for connecting to Twitter’s public stream API and dispatching events. Check https://dev.twitter.com/docs/streaming-apis/streams/public for more information.

Parameters:
  • consumerKey (string.) – Consumer key.
  • consumerSecret (string.) – Consumer secret.
  • accessToken (string.) – Access token.
  • accessTokenSecret (string.) – Access token secret.
  • track (list.) – A list of phrases which will be used to determine what Tweets will be delivered on the stream. A phrase may be one or more terms separated by spaces, and a phrase will match if all of the terms in the phrase are present in the Tweet, regardless of order and ignoring case.
  • follow (list.) – A list of user IDs, indicating the users whose Tweets should be delivered on the stream. Following protected users is not supported.
  • languages (list.) – A list of language IDs a defined in http://tools.ietf.org/html/bcp47.

Note

  • Go to http://dev.twitter.com and create an app. The consumer key and secret will be generated for you after that.
  • Create an access token under the “Your access token” section.
  • At least track or follow have to be set.
subscribe(callback)

Subscribe to Twitter events. The event handler will receive a dictionary with the data as defined in: https://dev.twitter.com/docs/streaming-apis/messages#Public_stream_messages.

Table Of Contents

Previous topic

Twitter support

Next topic

Twitter Example

This Page