5

I have been using the function the last months but the last couple of day it stopped working:

library(quantmod)
getFX("USD/JPY")

Error in open.connection(con, "rb") : HTTP error 404.

Anyone else having the same problem? Any alternatives in R for downloading FX data?

UPDATE: the quantmod creator provided a fix for the issue, just copying the code for installing it:

install.packages("curl")
library(devtools)
devtools::install_github("joshuaulrich/quantmod", ref="225_getsymbols_oanda") 
sen_saven
  • 182
  • 12
  • 1
    It seems that `quantmod` uses the [oanda v1 REST API](http://developer.oanda.com/rest-live/introduction/) which is deprecated. Until the package authors implement the [v20 REST API](http://developer.oanda.com/rest-live-v20/introduction/) or another workaround you better use other sources to aquire the FX data. – wici Apr 06 '18 at 08:59

2 Answers2

2

Could be Quandl, but you have to sign up. The key is free.

library(Quandl)

Quandl.api_key("NEED_FREE_KEY!!")

#q <- Quandl.search(query = "DEXJPUS", database_code = "FRED")
#Japan / U.S. Foreign Exchange Rate
#Code: FRED/DEXJPUS
#Desc: Japanese Yen to One U.S. Dollar Not Seasonally Adjusted, Noon buying     rates in New York City for cable transfers payable in foreign currencies. 
#Freq: daily
#Cols: Date | Value

jpus <- Quandl(code = "FRED/DEXJPUS", 
               type = "raw", 
               collapse = "monthly", 
               start_date = "2018-01-01", 
               end_date = "2018-03-01")
r.user.05apr
  • 5,356
  • 3
  • 22
  • 39
2

I can reproduce your problems. You can use Yahoo or FRED:

library(quantmod)
getSymbols("DEXJPUS", src = "FRED")
getSymbols("JPY=X", src = "yahoo")

According to https://github.com/joshuaulrich/quantmod/issues/225 this has been fixed in a development branch.

Ralf Stubner
  • 26,263
  • 3
  • 40
  • 75