Giter VIP home page Giter VIP logo

Comments (4)

anfederico avatar anfederico commented on August 22, 2024

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.

kirshanluhana avatar kirshanluhana commented on August 22, 2024

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.

anfederico avatar anfederico commented on August 22, 2024

You can restrict tweets to English only (should be somewhere in the Tweepy docs) however you can't grab past tweets.

from stocktalk.

LimeCitron avatar LimeCitron commented on August 22, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.