Retrieving data from Quandl with Python -


how can latest prices quandl dataset python api (https://www.quandl.com/help/python)? on https://www.quandl.com/help/api, says "you can use rows=n first n rows of dataset. use rows=1 latest observation dataset." if use rows=1 first observation instead of latest.

besides, need exchange rates usd https://www.quandl.com/resources/api-for-currency-data seems need retrieve exchange rates each currency instead of having dataset recent exchange rates each currency versus usd. isn't possible?

import quandl 

you first need sort dataset in descending order recent value:

quandl.get("fred/dexuseu", rows=1, sort_order='desc')              value date               2015-05-15  1.1428 

you need request exchange rate separately each currency:

fred_rates = pd.dataframe({'currency': {'dexbzus': 'brazilian real (brl)',                                         'dexcaus': 'canadaian dollar (cad)',                                         'dexchus': 'chinese yuan (cny))',                                         'dexdnus': 'denish krone (dkk)',                                         'dexhkus': 'hong kong dollar (hkd)',                                         'dexinus': 'indian rupee (inr)',                                         'dexjpus': 'japanese yen (jpy)',                                         'dexkous': 'south korean won (krw)',                                         'dexmaus': 'malaysian ringgit (myr)',                                         'dexmxus': 'mexican peso (mxn)',                                         'dexnous': 'norwegian krone(nok)',                                         'dexsdus': 'swedish krona (sek)',                                         'dexsfus': 'south african rand(zar)',                                         'dexsius': 'singapore dollar (sgd)',                                         'dexslus': 'sri lankan rupee(lkr)',                                         'dexszus': 'swiss franc (chf)',                                         'dextaus': 'new taiwan dollar (twd)',                                         'dexthus': 'thai baht (thb)',                                         'dexusal': 'australian dollar (aud)',                                         'dexuseu': 'euro (eur)',                                         'dexusnz': 'new zealand dollar (nzd)',                                         'dexusuk': 'british pound (gbp)',                                         'dexvzus': 'venezuelan bolivar (vef)'}}) fred_rates['symbol'] = frates.currency.map(lambda x: x[-4:-1])  rates = [quandl.get("fred/{0}".format(fx)) fx in fred_rates.index] fx_rates = pd.concat(rates, axis=1) fx_rates.columns = [fx fx in fred_rates.symbol]  >>> fx_rates.info() <class 'pandas.core.frame.dataframe'> datetimeindex: 11168 entries, 1971-01-04 2015-05-15 data columns (total 23 columns): aud    11130 non-null float64 brl    5120 non-null float64 gbp    11137 non-null float64 cad    11143 non-null float64 ny)    8577 non-null float64 dkk    11145 non-null float64 eur    4116 non-null float64 hkd    8637 non-null float64 inr    10629 non-null float64 jpy    11131 non-null float64 myr    11115 non-null float64 mxn    5405 non-null float64 twd    7650 non-null float64 nzd    11121 non-null float64 nok    11136 non-null float64 sgd    8636 non-null float64 zar    11110 non-null float64 krw    8523 non-null float64 lkr    10277 non-null float64 sek    11136 non-null float64 chf    11137 non-null float64 thb    8556 non-null float64 vef    5114 non-null float64 dtypes: float64(23) memory usage: 2.0 mb  >>> fx_rates.tail()                aud     brl     gbp     cad     ny)  dkk     eur     hkd  date                                                                       2015-05-11  0.7899  3.0385  1.5593  1.2107  6.2086  nan  1.1142  7.7535    2015-05-12  0.7989  3.0223  1.5685  1.1987  6.2086  nan  1.1240  7.7528    2015-05-13  0.8118  3.0265  1.5748  1.1950  6.2043  nan  1.1372  7.7517    2015-05-14  0.8082  2.9910  1.5766  1.1991  6.2013  nan  1.1368  7.7505    2015-05-15  0.8053  2.9779  1.5772  1.2009  6.2051  nan  1.1428  7.7505                   inr     jpy   ...       nzd     nok     sgd      zar      krw  date                        ...                                                2015-05-11  63.96  120.05   ...    0.7350  7.5605  1.3361  12.0820  1095.39    2015-05-12  64.19  119.80   ...    0.7377  7.4720  1.3336  12.0430  1093.81    2015-05-13  63.88  119.09   ...    0.7488  7.3597  1.3239  11.8760  1089.72    2015-05-14  63.47  119.20   ...    0.7500  7.3829  1.3199  11.8220  1089.46    2015-05-15  63.36  119.36   ...    0.7489  7.3113  1.3195  11.7645  1083.05                   lkr     sek     chf    thb     vef   date                                               2015-05-11  133.3  8.2950  0.9344  33.71  6.2842   2015-05-12  133.5  8.3022  0.9266  33.70  6.2842   2015-05-13  133.5  8.2085  0.9162  33.51  6.2842   2015-05-14  133.4  8.2531  0.9146  33.50  6.2842   2015-05-15  133.4  8.2174  0.9174  33.48  6.2842    [5 rows x 23 columns] 

Comments

Popular posts from this blog

node.js - Using Node without global install -

How to access a php class file from PHPFox framework into javascript code written in simple HTML file? -

java - Null response to php query in android, even though php works properly -