Quantmod getFX 函数错误

Quantmod getFX function error

过去几个月我一直在使用该功能,但最近几天它停止工作了:

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

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

还有其他人遇到同样的问题吗? R 中用于下载 FX 数据的任何替代方法?

更新:quantmod 创建者提供了一个问题的修复,只需复制安装代码即可:

install.packages("curl")
library(devtools)
devtools::install_github("joshuaulrich/quantmod", ref="225_getsymbols_oanda") 

可能是 Quandl,但你必须注册。钥匙是免费的。

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")

我可以重现你的问题。您可以使用 Yahoo 或 FRED:

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

根据 https://github.com/joshuaulrich/quantmod/issues/225 这已在开发分支中修复。