Message Boards Message Boards

Financial data from Quandl in Wolfram Language using QuandlLink

GROUPS:

QuandlFinancialData in QuandlLink package allows us to get financial data in Mathematica from Quandl. Please visit https://www.quandl.com to find out more about all open/free data as well as premium data that can be downloaded from them. The website also contains the limitation on how much data you can download.

It is recommended to sign up for a free Quandl API key to download data from Quandl.

Please go to following link to download QuandlLink package and for the installation instructions:

https://github.com/bajracha71/Quandl-Mathematica-QuandlLink

Some of the Free Data source include:

  1. US Federal Reserve Data Releases
  2. US Treasury
  3. Chicago Mercantile Exchange Futures Data
  4. EUREX Futures Data
  5. Google Finance
  6. Yahoo Finance

Please go to following link to find for complete list of databases available in Quandl:

Examples:

Needs["QuandlLink`"]
In[3]:= dowJones = "YAHOO/INDEX_DJI";
dowJonesData = 
 QuandlFinancialData[dowJones, startDate -> "2015-05-01", 
  endDate -> "2015-06-01"]

Out[3]= {{{Date}, {Open, High, Low, Close, Volume, 
   Adjusted Close}}, {{2015, 5, 1}, {17859.3, 18028.9, 17859.3, 
   18024.1, 9.17*10^7, 18024.1}}, {{2015, 5, 4}, {18026., 18133.8, 
   18026., 18070.4, 8.601*10^7, 18070.4}}, {{2015, 5, 5}, {18062.5, 
   18086., 17905.7, 17928.2, 9.534*10^7, 17928.2}}, {{2015, 5, 
   6}, {17934.8, 18019.8, 17733.1, 17842., 1.0043*10^8, 
   17842.}}, {{2015, 5, 7}, {17840.3, 17973.1, 17796.9, 17924.1, 
   8.092*10^7, 17924.1}}, {{2015, 5, 8}, {17933.6, 18205.2, 17933.6, 
   18191.1, 9.496*10^7, 18191.1}}, {{2015, 5, 11}, {18187.8, 18200., 
   18089.1, 18191.1, 8.605*10^7, 18191.1}}, {{2015, 5, 12}, {18096.2, 
   18119.2, 17924.8, 18068.2, 8.927*10^7, 18068.2}}, {{2015, 5, 
   13}, {18070.4, 18132.8, 18039.2, 18060.5, 8.518*10^7, 
   18060.5}}, {{2015, 5, 14}, {18062.5, 18299.3, 18116.5, 18252.2, 
   9.158*10^7, 18252.2}}, {{2015, 5, 15}, {18252., 18272.7, 18215.1, 
   18272.6, 1.0822*10^8, 18272.6}}, {{2015, 5, 18}, {18267.3, 18325.5,
    18244.3, 18298.9, 7.908*10^7, 18298.9}}, {{2015, 5, 19}, {18300.5,
    18351.4, 18261.4, 18312.4, 8.72*10^7, 18312.4}}, {{2015, 5, 
   20}, {18315.1, 18350.1, 18272.6, 18285.4, 8.019*10^7, 
   18285.4}}, {{2015, 5, 21}, {18285.9, 18314.9, 18249.9, 18285.7, 
   8.427*10^7, 18285.7}}, {{2015, 5, 22}, {18286.9, 18286.9, 18217.1, 
   18232., 7.889*10^7, 18232.}}, {{2015, 5, 26}, {18229.8, 18229.8, 
   17990., 18041.5, 1.0944*10^8, 18041.5}}, {{2015, 5, 27}, {18045.1, 
   18190.4, 18045.1, 18163., 9.64*10^7, 18163.}}, {{2015, 5, 
   28}, {18154.1, 18154.1, 18066.4, 18126.1, 6.751*10^7, 
   18126.1}}, {{2015, 5, 29}, {18128.1, 18128.1, 17967.7, 18010.7, 
   1.3981*10^8, 18010.7}}, {{2015, 6, 1}, {18017.8, 18105.8, 17982.1, 
   18040.4, 8.564*10^7, 18040.4}}}

Documentation on how to use QuandlFinancialData can be found in the package.

<<QuandlLink`
?QuandlFinancialData
POSTED BY: Anmol Bajracharya
Answer
2 years ago

Using TradingChart and DateListPlot:

In[1]:= Needs["QuandlLink`"]

In[4]:= dowJonesOHLCV = 
  QuandlFinancialData[ 
   "YAHOO/INDEX_DJI", 
   startDate -> "2015-01-01", 
   column -> 1 ;; 6];

In[6]:= dowJonesOHLCV[[1 ;; 10]]

Out[6]= {{{Date}, {Open, High, Low, Close, Volume}}, {{2015, 1, 
   2}, {17823.1, 17951.8, 17731.3, 17833., 7.627*10^7}}, {{2015, 1, 
   5}, {17821.3, 17821.3, 17475.9, 17501.7, 1.1616*10^8}}, {{2015, 1, 
   6}, {17504.2, 17581.1, 17262.4, 17371.6, 1.0187*10^8}}, {{2015, 1, 
   7}, {17374.8, 17597.1, 17374.8, 17584.5, 9.103*10^7}}, {{2015, 1, 
   8}, {17592., 17916., 17592., 17907.9, 1.1489*10^8}}, {{2015, 1, 
   9}, {17911., 17915.3, 17686.1, 17737.4, 9.339*10^7}}, {{2015, 1, 
   12}, {17742.1, 17793.9, 17571.6, 17640.8, 9.25*10^7}}, {{2015, 1, 
   13}, {17645., 17923., 17498.2, 17613.7, 9.936*10^7}}, {{2015, 1, 
   14}, {17609.1, 17609.1, 17264.9, 17427.1, 1.0918*10^8}}}

TradingChart[Rest@dowJonesOHLCV, PlotLabel -> "OHLCV"]

Visualizing OHLCV using TradingChart

In[11]:= dowJonesClose = QuandlFinancialData[ 
   "YAHOO/INDEX_DJI", 
   startDate -> "2015-01-01", 
   column -> 5];

In[12]:= dowJonesClose[[1 ;; 5]]

Out[12]= {{{Date}, {Close}}, {{2015, 1, 2}, {17833.}}, {{2015, 1, 
   5}, {17501.7}}, {{2015, 1, 6}, {17371.6}}, {{2015, 1, 
   7}, {17584.5}}}

In[16]:= DateListPlot[Rest@dowJonesClose, GridLines -> True,  PlotTheme -> "Business", Filling -> Bottom]

enter image description here

POSTED BY: Anmol Bajracharya
Answer
2 years ago

Dear Anmol, thanks a lot for this great contribution! May I suggest that to maximize the possibility of people finding out about this package you also submit your post to library.wolfram.com and let Quandl know as well? Regards, Ruben

Answer
2 years ago

Hello Ruben, Thank you for your suggestion. I have already contacted Quandl regarding this package and I will also upload it to library.wolfram.com soon. Best, Anmol

POSTED BY: Anmol Bajracharya
Answer
2 years ago

Nice Anmol!

For those still on v9, one tweak will make this package backwards-compatible. (v9 doesn't have the DateValue function.)

In QuandlLink.m, you can change this line:

From: DateValue[Yesterday, {"Year", "Month", "Day"}]

To: DatePlus[Take[DateList[],3],-1]

Note, also in v9 when making a DateListPlot, v9 doesn't like it when for single values each one is a one-element list.

For example, data formatted like {{2015, 5, 1}, {18024.1}} won't plot (at least for me), but after some list manipulation, that's easy to fix.

POSTED BY: kenhersey
Answer
2 years ago

@Anmol Bajracharya, is it possible to get Exchange Rates with this package? Something asked for in this question.

POSTED BY: Vitaliy Kaurov
Answer
2 years ago

I think I figured it out:

<< QuandlLink`

AUDvsUSDrates = QuandlFinancialData["CURRFX/AUDUSD",
    startDate -> "1995-1-1", endDate -> "2015-5-1"];

DateListPlot[Transpose[{#[[All, 1]], #[[All, 2, 1]]} &@Rest[AUDvsUSDrates]], 
 PlotTheme -> "Detailed"]

enter image description here

POSTED BY: Vitaliy Kaurov
Answer
2 years ago

With Quandl API 3, the command for FOREX has slightly changed:

AUDvsUSDRates = QuandlFinancialData["datasets/CURRFX/AUDUSD",
   startDate -> "1995-01-01", endDate -> "2015-02-01"];
Answer
7 months ago

Hello Anmol, thanks for giving me much information. I would like to know how to set my own API key. If you know the procedure, please let me know

POSTED BY: Emah Hiro
Answer
1 year ago

@Hiro: Do you mean your API function that could be accessed through your Wolfram Cloud account? Not sure what do you mean by your own API key.

POSTED BY: Anmol Bajracharya
Answer
1 year ago

Sorry to give you vague expression. I mean Mthematica 10.4 environment on premise, not clout. For example , when I execute Mr Vitally's example which is shown above on Mathematica. I can only 50times to execute because of annonymous access to Quandl. In Excel API of Quandl, there is the form to put API key in. like this

enter image description here

I want to know how to tell my API key to Quandl web site through Mathematica.

POSTED BY: Emah Hiro
Answer
1 year ago

@Hiro: Please try following: QuandlFinancialData["id", authCode -> "Authentiation Code"]

Also, you can check out the documentation of QuandlLink package by evaluating:

<< QuandlLink`

?QuandlFinancialData

POSTED BY: Anmol Bajracharya
Answer
1 year ago

Sorry to say, I couldn't execute the command that you advised me. I attach screenshot below.

enter image description here

Before appear {{{$Failed},{}}} Authentication window(show below) was appear, and of course I entered right id and password.

enter image description here

I confirmed my id and password through Quandl website. Please give me your advise.

Kind regards,

Hiro

POSTED BY: Emah Hiro
Answer
1 year ago

@hiro: I was unable to reproduce the error message. I was able to connect to Quandl using my API key. Please see the screen shot. enter image description here

In my package I used quandl api version 1 and QuandL have already released version 3. I have not had time to update my package with the most recent version of Quandl api. Following piece of code uses Quandl API 3. Can you evaluate and see if it works?

URLFetch["https://www.quandl.com/api/v3/datasets/OPEC/ORB.csv?api_key= " <> myAPIKey]

Insert "your api key" in myAPIKey.

If your api key is correct above evaluation should work. Also feel free to modify QuandlLink.m file if you want to use version 3 of Quandl api and any feature you would like to add to the package. Thanks.

POSTED BY: Anmol Bajracharya
Answer
1 year ago

QunadlLink has been updated and now uses Quandl API 3.

POSTED BY: Anmol Bajracharya
Answer
1 year ago

Group Abstract Group Abstract