Data collection toolkit for social media analytics
Python JavaScript HTML
Switch branches/tags
Nothing to show
Clone or download
Latest commit 1c2c585 Jan 12, 2018
Failed to load latest commit information.
docs Demo of visualization Jan 11, 2018
media Delete Demo.gif Jan 11, 2018
stocktalk Update Jan 11, 2018
LICENSE.txt Update LICENSE.txt Jan 11, 2018 Update Jan 12, 2018
requirements.txt Add files via upload Jan 11, 2018

                                                Python Dependencies GitHub Issues License


Stocktalk is a visualization tool that tracks tweet volume and sentiment on Twitter, given a series of queries.

It does this by opening a local websocket with Twitter and pulling tweets that contain user-specified keywords. For example, I can tell Stocktalk to grab all tweets that mention Ethereum and periodically tally volume and measure average sentiment every 15 minutes.

It will then record this data continuously and update an online database that can be used to visualize the timeseries data via an interactive Flask-based web application.



Stocktalk requires API credentials with Twitter and Mlab

Twitter Steps (Creating an application)

  1. Sign into Twitter at
  2. Create a new application and fill out details
  3. Generate an access token
  4. Save the following information
    • Consumer Key
    • Consumer Secret
    • Access Token
    • Access Token Secret

Mlab Steps (Setting up an online database)

  1. Make an account at
  2. Create a new deployment in sandbox mode
  3. Add a database user to your deployment
  4. Save the following information
    • Mongo deployment server
    • Mongo deployment id
    • Mongo deployment client
    • Deployment user
    • Deployment pass


# Clone repository and install dependencies
$ git clone
$ pip install -r Stocktalk/requirements.txt

# Install natural language toolkit sentiment corpus
$ python -m nltk.downloader vader_lexicon

Edit Settings

└── /scripts
# Mongo
mongo_server = ''
mongo_id     =  54236
mongo_client = 'stocktalk'
mongo_user   = 'username'
mongo_pass   = 'password'

# Twitter
api_key             = ''
api_secret          = ''
access_token        = ''
access_token_secret = ''
credentials = [api_key, api_secret, access_token, access_token_secret]

Code Examples

Twitter Streaming

This file opens the websocket and writes to the online databse until manually interrupted


$ python
from scripts import settings

# Each key or category corresponds to an array of keywords used to pull tweets
queries = {'ETH': ['ETH', 'Ethereum'],
           'LTC': ['LTC', 'Litecoin'],
           'BTC': ['BTC', 'Bitcoin'],
           'XRP': ['XRP', 'Ripple'],
           'XLM': ['XLM', 'Stellar']}

# Aggregate volume and sentiment every 15 minutes
refresh = 15*60


Realtime Visualization

This file initiates a local web-application which pulls data from the online database


$ python

Underlying Features

Text Processing
t1 = "@TeslaMotors shares jump as shipments more than double! #winning"

t2 = "Tesla announces its best sales quarter: $TSLA" 

t3 = "Tesla $TSLA reports deliveries of 24500, above most views."
shares jump as shipments more than double winning
tesla announces its best sales quarter
tesla reports deliveries of number above most views
Sentiment Analysis
t1 = "shares jump as shipments more than double winning"

t2 = "tesla reports deliveries of number above most views"

t3 = "not looking good for tesla competition on the rise"