How to get an XDR Exchange Rate XML feed from the IMF

There’s a currency used by the IMF called the Special Drawing Right (XDR), which is a unit of currency that floats at a value relative to all other currencies weighted by the strengths of their country’s economy. In a world where the USD wanes in strength, it’s as close to a global currency as we’ve got right now.

By running the following two commands, you should end up with a file rates.xml filled with exchange rates into XDR for the last 30 days.

wget -O/tmp/rates.html --no-cache --save-cookies=cookies.txt --keep-session-cookies "http://www.imf.org/external/np/fin/ert/GUI/Pages/Report.aspx?CU='EUR','JPY','GBP','USD','ARS','AUD','ATS','BHD','BEF','VEF','BWP','BRL','BND','CAD','CLP','CNY','COP','CYP','CZK','DKK','DEM','FIM','FRF','GRD','HUF','ISK','INR','IDR','IRR','IEP','ILS','ITL','KZT','KRW','KWD','LYD','LUF','MYR','MTL','MUR','MXN','NPR','NLG','NZD','NOK','PKR','PLN','PTE','QAR','OMR','RUB','SAR','SGD','SKK','SIT','ZAR','ESP','LKR','SEK','CHF','THB','TTD','AED','VEB'&EX=SDRC&P=Last30Days&CF=UnCompressed&CUF=Period&DS=Ascending&DT=Blank"

wget -O/tmp/rates.xml --no-cache --load-cookies=cookies.txt --keep-session-cookies "http://www.imf.org/external/np/fin/ert/GUI/Pages/ReportData.aspx?Type=XML"

2 Comments

  • Shri
    Posted September 30, 2011 at 4:21 am | Permalink

    Hi,

    I am using wget -O/tmp/rates.html –no-cache –save-cookies=cookies.txt –keep-session-cookies “http://www.imf.org/external/np/fin/ert/GUI/Pages/Report.aspx?CU=’EUR’,’JPY’,’GBP’,’USD’,’DZD’,’ARS’,’AUD’,’ATS’,’BHD’,’BEF’,’VEF’,’BWP’,’BRL’,’BND’,’CAD’,’CLP’,’CNY’,’COP’,’CYP’,’CZK’,’DKK’,’DEM’,’FIM’,’FRF’,’GRD’,’HUF’,’ISK’,’INR’,’IDR’,’IRR’,’IEP’,’ILS’,’ITL’,’KZT’,’KRW’,’EEK’,’KWD’,’LYD’,’LUF’,’MYR’,’MTL’,’MUR’,’MXN’,’NPR’,’NLG’,’NZD’,’NOK’,’PEN’,’PKR’,’UYU’,’PHP’,’PLN’,’PTE’,’QAR’,’OMR’,’RUB’,’SAR’,’SGD’,’SKK’,’SIT’,’ZAR’,’ESP’,’LKR’,’SEK’,’CHF’,’THB’,’TTD’,’TND’,’AED’,’VEB’&EX=REP&P=DateRange&Fr=634528512000000000&To=634528512000000000&CF=UnCompressed&CUF=Period&DS=Ascending&DT=Blank” command to get the exchange rates but looks like it is not working. I am trying to get the daily exchange rates to my Unix server. Could you please let me know if any alternativs exists, using wget command.

    Many Thanks,
    Shri

  • Posted September 30, 2011 at 6:10 pm | Permalink

    Hi Shri,

    They may have changed it. It looks like you now need to do 4 requests, going through their wizard, in order to setup a report.

    The key to this is –save-cookies=cookies.txt and –keep-session-cookies. You’re going through a wizard on their site, and the only way the wizard can keep the “state” (and know that it’s the same guy going through each step of the wizard) is to give you a cookie for your browser to hold on to.

    So you use these arguments to keep and pass back that cookie.

Post a Comment

Your email is kept private. Required fields are marked *