Dear all Is there any R function that would perform currency conversion using up-to-date exchange rates? I would be looking for a function that allows to download recent exchange rates (say, from Yahoo!) and then use these in converting currencies (say, USD to EUR). I am not sure whether r-sig-finance would be more appropriate, but the (off-)topic feels general enough to me. Thank you Liviu -- Do you know how to read? http://www.alienetworks.com/srtest.cfm Do you know how to write? http://garbl.home.comcast.net/~garbl/stylemanual/e.htm#e-mail
Hi Liviu, try yahooSeries from fImport example: library("fImport") yahooSeries("EURUSD=X") Best, andreas -- www.er.ethz.ch/people/ahuesler
You can try something about like this: foo <- function(from, to, date){ url <- "http://www.oanda.com/convert/classic?script=..%2Fconvert%2Fclassic&language=en&value=1" params <- sprintf("%s&date=%s&exch=%s&exch2=&margin_fixed=0&expr=%s&expr2=&SUBMIT=Convert+Now&lang=en&date_fmt=us", url, format(as.Date(date), "%m/%d/%y"), from, to) Lines <- readLines(params) value <- gsub(".*([0-9]\\.+[0-9]+).*", "\\1", grep("nl", grep(from, grep(to, Lines, value = TRUE), value = TRUE), value = TRUE)) as.numeric(value) } foo('BRL', 'USD', '2009-10-14') On Wed, Oct 14, 2009 at 6:40 AM, Liviu Andronic <landronimirc at gmail.com> wrote:> Dear all > Is there any R function that would perform currency conversion using > up-to-date exchange rates? I would be looking for a function that > allows to download recent exchange rates (say, from Yahoo!) and then > use these in converting currencies (say, USD to EUR). > > I am not sure whether r-sig-finance would be more appropriate, but the > (off-)topic feels general enough to me. Thank you > Liviu > > > > -- > Do you know how to read? > http://www.alienetworks.com/srtest.cfm > Do you know how to write? > http://garbl.home.comcast.net/~garbl/stylemanual/e.htm#e-mail > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >-- Henrique Dallazuanna Curitiba-Paran?-Brasil 25? 25' 40" S 49? 16' 22" O
There was such a function in the form of getFX in package=quantmod , but testing it makes me think there might have been a change in how the website on which it depended might be expecting to get requests. library(quantmod) > getFX("EUR/USD",from=as.Date("2008-01-01")) Error: oanda.com limits data to 500 days per request You might look at how they implemented it and see if it could be modified to work with your selected target web-server. Or you could see if Rowlingson's reply to james in the archives was helpful: http://finzi.psych.upenn.edu/Rhelp08/2009-June/202979.html -- David On Oct 14, 2009, at 5:40 AM, Liviu Andronic wrote:> Dear all > Is there any R function that would perform currency conversion using > up-to-date exchange rates? I would be looking for a function that > allows to download recent exchange rates (say, from Yahoo!) and then > use these in converting currencies (say, USD to EUR). > > I am not sure whether r-sig-finance would be more appropriate, but the > (off-)topic feels general enough to me. Thank you > Liviu > > > > -- > Do you know how to read? > http://www.alienetworks.com/srtest.cfm > Do you know how to write? > http://garbl.home.comcast.net/~garbl/stylemanual/e.htm#e-mail > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.David Winsemius, MD Heritage Laboratories West Hartford, CT