Getting data from Quandl
Quandl is sometimes a useful data source. Quandl is essentially an centralised market place of data from various sources. An advantage of this is that you can access data by simply getting familiar with Quandl’s API, as opposed to having to tinker around with the APIs of multiple data providers.
There is a mix of free and paid data on the platform, as well as free samples of paid datasets.
As Quandl’s value proposition is really in facilitating access to data, it’s no surprise that they have a number of APIs — R, Python, web access.
I’ve outlined two ways of getting data from Quandl in this notebook.
The first would be to use the Python API. Two lines will get you what you want.
import quandl
data = quandl.get("BOE/XUDLGPD") #effective Fed Fund ratesAccess via a REST API, or rather via a direct web API call is sometimes more useful, and not hard either. You just need the requests library, and some manipulation of strings. Here’s a simple function for this.
def download_data_from_quandl(ticker):
# Construct the API call from the contract and auth_token
api_call = "http://www.quandl.com/api/v1/datasets/"
api_call += "%s.csv" % ticker
# You can download data without a token, but just less.
# insert token below to increase your quota
params = "?sort_order=asc"
#params = "?auth_token=MY_AUTH_TOKEN&sort_order=asc"
full_url = "%s%s" % (api_call, params)
# Download the data from Quandl
data = requests.get(full_url).text
ticker_str = ticker.replace('/','_')
filename = "%s.csv" % ticker_str
with open(filename, 'w') as f:
for line in data:
f.write(line)The notebook with the full code is available here.
playgrd.com || facebook.com/playgrdstar || instagram.com/playgrdstar/

