Created
January 30, 2013 14:51
-
-
Save jgilmour/4673785 to your computer and use it in GitHub Desktop.
Pulls stock quotes from tradeking's api into json format
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# Python script to pull a stock symbol using TradeKings API | |
# The 'stock' variable can be multiple stocks ie: "AAPL,CRM,CARB" | |
# The response output's in json, but can be other formats as well depending | |
# upon the apiurl request | |
import oauth2 as oauth | |
apiurl = "https://api.tradeking.com/v1/market/ext/quotes.json?symbols=" | |
stock = "AAPL" | |
oAuthConsumer = oauth.Consumer( | |
key="<oauthConsumerKey>", | |
secret="<oauthConsumerSecret>") | |
oAuthToken = oauth.Token( | |
key="<oAuthTokenKey>", | |
secret="<oauthTokenSecret>") | |
oAuthRequest = oauth.Client(oAuthConsumer, oAuthToken) | |
response, content = oAuthRequest.request(apiurl+stock) | |
print "Response: ", response | |
print "Content: ", content |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment