Comments (4)
Hey so the first file can be called streaming.py
from stocktalk import streaming
# Credentials to access Twitter API
API_KEY = 'XXXXXXXXXX'
API_SECRET = 'XXXXXXXXXX'
ACCESS_TOKEN = 'XXXXXXXXXX'
ACCESS_TOKEN_SECRET = 'XXXXXXXXXX'
credentials = [API_KEY, API_SECRET, ACCESS_TOKEN, ACCESS_TOKEN_SECRET]
# First element must be ticker/name, proceeding elements are extra queries
TSLA = ['TSLA', 'Tesla']
SNAP = ['SNAP', 'Snapchat']
AAPL = ['AAPL', 'Apple']
AMZN = ['AMZN', 'Amazon']
# Variables
tickers = [TSLA,SNAP,AAPL,AMZN] # Used for identification purposes
queries = TSLA+SNAP+AAPL+AMZN # Filters tweets containing one or more query
refresh = 30 # Process and log data every 30 seconds
# Create a folder to collect logs and temporary files
path = "/Users/Anthony/Desktop/Data/"
streaming(credentials, tickers, queries, refresh, path, \
realtime=True, logTracker=True, logTweets=True, logSentiment=True, debug=True)
The second file can be called visualize.py
from stocktalk import visualize
# Make sure these variables are consistent with streaming.py
tickers = ['TSLA','SNAP','AAPL','AMZN']
refresh = 30
path = "/Users/Anthony/Desktop/Data/"
visualize(tickers, refresh, path)
The second file needs the first file to be running, so run streaming.py
While it's running, go into your terminal and cd to the directory containing visualize.py
Once you're there, type: python -m bokeh serve --show visualize.py
from stocktalk.
Great, thanks for guide, it works perfect.
Just one more question, I am getting tweets in different languages, can I restrict to English only ?
Can I get tweets from from a starting date, let say tweets from 2015 onward ?
from stocktalk.
You can restrict tweets to English only (should be somewhere in the Tweepy docs) however you can't grab past tweets.
from stocktalk.
In my case, I changed the 'streaming.py' partial code from
from stocktalk import streaming
to
#-- coding: utf-8 --
from stocktalk import streaming
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
I was able to search for Unicode characters this way.
I tested it in Korean and tweets were searched without any problems. But I think that the sentiment in other languages can't be measured by this method.
from stocktalk.
Related Issues (10)
- Import error HOT 8
- streaming.py HOT 1
- Crawl Tweets in the past HOT 3
- Error after running example HOT 10
- Visualation Problem HOT 4
- setup problem HOT 2
- Error after specific example
- a blank page when opening bokeh HOT 4
- no output HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from stocktalk.