fred <- function(id) {
d <- read.csv(paste0("https://fred.stlouisfed.org/graph/fredgraph.csv?id=", id))
d <- data.frame(date = as.Date(d[[1]]), value = suppressWarnings(as.numeric(d[[2]])))
d[!is.na(d$value), ]
}
ecb <- function(key) {
d <- read.csv(paste0("https://data-api.ecb.europa.eu/service/data/", key, "?format=csvdata"))
t <- d$TIME_PERIOD
t <- ifelse(nchar(t) == 7, paste0(t, "-01"), t) # monthly "YYYY-MM" -> date
data.frame(date = as.Date(t), value = d$OBS_VALUE)
}
# Country averages of OECD immediate (interbank) rates since 2000
cc <- c("US", "GB", "JP", "CA", "CH", "AU", "NZ", "SE",
"NO", "DK", "KR", "MX", "PL", "HU", "CZ", "ZA")
rates <- do.call(rbind, lapply(cc, function(iso) {
d <- fred(paste0("IRSTCI01", iso, "M156N"))
d <- d[d$date >= as.Date("2000-01-01"), ]
data.frame(iso2 = iso, mean = mean(d$value), sd = sd(d$value))
}))
dfr <- ecb("FM/D.U2.EUR.4F.KR.DFR.LEV") # ECB deposit facility rate, daily
brk <- data.frame(
date = as.Date(c("2008-10-15", "2014-06-11", "2022-07-27")),
label = c("Financial crisis", "Negative rates", "Hiking cycle")
)
ff <- fred("FEDFUNDS")
ff <- ff[ff$date >= as.Date("2000-01-01"), ]
ext <- ff[c(which.min(ff$date), which.max(ff$value), which.min(ff$value), which.max(ff$date)), ]
m3 <- ecb("BSI/M.U2.Y.V.M30.X.1.U2.2300.Z01.E") # euro area M3, EUR millions