quandl.py 1.0 KB

123456789101112131415161718192021222324252627282930
  1. '''Module containing a handful of methods for
  2. aggregating data from markets throughout the world'''
  3. import requests
  4. import 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. req = requests.get(apiurl, params=parameters)
  10. data = json.loads(req.content)
  11. return data
  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. req = requests.get(apiurl, params=parameters)
  17. data = json.loads(req.content)
  18. return data
  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/NASDAQOMX/COMP.json?'
  23. req = requests.get(apiurl, params=parameters)
  24. data = json.loads(req.content)
  25. return data