quandl.py 1.1 KB

123456789101112131415161718192021222324252627282930
  1. '''Module containing a handful of methods for
  2. aggregating data from markets throughout the world'''
  3. import requests
  4. import simplejson as json
  5. def dowjonesIndustrialAvg(apikey):
  6. '''Returns JSON data of the Dow Jones Average.'''
  7. parameters = {'rows' : 1, 'auth_token' : apikey}
  8. apiurl = 'https://www.quandl.com/api/v1/datasets/BCB/UDJIAD1.json?'
  9. reap = requests.get(apiurl, params=parameters)
  10. desu = json.loads(reap.content)
  11. return desu
  12. def snp500IndexPull(apikey):
  13. '''Returns JSON data of the S&P 500 Index.'''
  14. parameters = {'rows' : 1, 'auth_token' : apikey}
  15. apiurl = 'https://www.quandl.com/api/v1/datasets/YAHOO/INDEX_GSPC.json?'
  16. reap = requests.get(apiurl, params=parameters)
  17. desu = json.loads(reap.content)
  18. return desu
  19. def nasdaqPull(apikey):
  20. '''Returns JSON data of the Nasdaq Index.'''
  21. parameters = {'rows' : 1, 'auth_token' : apikey}
  22. apiurl = 'https://www.quandl.com/api/v1/datasets/GOOG/NASDAQ_SWTX.json?'
  23. reap = requests.get(apiurl, params=parameters)
  24. desu = json.loads(reap.content)
  25. return desu