# This tutorial is a comprehensive guide to using the Quandl APIs.
# Every single dataset on Quandl is available via APIs. To learn more more on APIs, please visit http://www.quandl.com/help/api
# Let us first start with installing Quandl on your system for R
# There are two ways how you can install Quandl for R. One of them is to download it from CRAN:
# Sometimes, CRAN packages are updated much later than actual updats of the package, so my suggestion is that you download Quandl package from Github using “devtool” package:
# Once you have installed Quandl on your system, register at Quandl.com website and obtain “Authentication Token” from them.
# This is mendatory otherwise APIs will have very limited or no access at all to any data sources that quandl.com has.
# After obtaining “Your Authentication Token” (which should look something as Gzy5B-zxmGYYsqvuVAEh), you have to first run the follwing:
Quandl.auth(“your authentication token”)
# This will grant you full access to APIs and extend your usage at Quandl.com
# You can check, whether your access and everything else is working fine, by typing:
# Now, I will explain how to search for something on Quandl from within the R. The search function is:
Quandl.search(query = “Search Term”, page = n, source = “Specific source to search”, silent = TRUE|FALSE)
# Query: Required; Your search term, as a string
# Page: Optional; page number of search you wish returned, default is page number 1 but if you set it to 2, the search will return page two and so forth.
# Source: Optional; Name of a specific source you wish to search, as a string e.g. NSE (National Stock Exchange, India)
# Silent: Optional; specifies whether you wish the first three results printed to the console, default is set to True, which means first three results will be shown.
Quandl.search(“Steel”, source = “NSE”)
# Will pring the follwing results on console
JSW ISPAT Steel Limited Code: NSE/JSWISPAT Desc: Historical prices for JSW ISPAT Steel Limited (JSWISPAT), (ISIN: INE136A01022), National Stock Exchange of India. Freq: daily Cols: Date|Open|High|Low|Last|Close|Total Trade Quantity|Turnover (Lacs) Lloyds Steel Industries Limited Code: NSE/LLOYDSTEEL Desc: Historical prices for Lloyds Steel Industries Limited (LLOYDSTEEL), (ISIN: INE292A01015), National Stock Exchange of India. Freq: daily Cols: Date|Open|High|Low|Last|Close|Total Trade Quantity|Turnover (Lacs) AML Steel Limited Code: NSE/AMLSTEEL Desc: Historical prices for AML Steel Limited (AMLSTEEL), (ISIN: INE577F01018), National Stock Exchange of India. Freq: daily Cols: Date|Open|High|Low|Last|Close|Total Trade Quantity|Turnover (Lacs)
In this example we will first fetch USD (US Dollar) to INR (Indian Rupees) Exchange Rate from January 01, 2013 to July 31, 2014. This data is fetched from Quandl and stored in a variable, say, Exchange.
# Load the Quandl package if not already loaded
# Assign to the variable Exchange
Exchange = Quandl(“QUANDL/USDINR”, start_date=”2013-01-01″, end_date=”2014-07-31″)
# Please note, the data are stored as the most recent one in the first row and so forth (chronological order). If we plot this series, it will give us reverse interpretation.
# We, therefore, first arrange the order of series using:
Exchange1 = Exchange[order(-1:-413), ]
# which becomes as:
# And now we can plot
plot(Exchange1$Rate, type=”l”, main=”1 USD = Rupees, Exchange Rate”, xlab=”Exchange Days\’ Data”, ylab=”Rupees”)
That’s all folks for now…
Will revert soon with more tutorials on using Quandl with R…