Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/m-muecke/bbk

R client for the Bundesbank & ECB APIs
https://github.com/m-muecke/bbk

api bundesbank central-bank deutsche-bundesbank ecb european-central-bank r r-package smdx

Last synced: about 2 months ago
JSON representation

R client for the Bundesbank & ECB APIs

Awesome Lists containing this project

README

        

---
output: github_document
---

```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
options(tibble.print_min = 5L, tibble.print_max = 5L)
```

# bbk

[![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html#experimental)
[![R-CMD-check](https://github.com/m-muecke/bbk/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/m-muecke/bbk/actions/workflows/R-CMD-check.yaml)
[![CRAN status](https://www.r-pkg.org/badges/version/bbk)](https://CRAN.R-project.org/package=bbk)

bbk is minimal R client for the
[Deutsche Bundesbank](https://www.bundesbank.de/en/statistics/time-series-databases/help-for-sdmx-web-service)
and the [European Central Bank (ECB)](https://data.ecb.europa.eu/help/api/overview) APIs.

> In the future, it may be extended to other central banks and financial institutions.
> Feel free to open an issue if you have a specific request.

## Installation

You can install the released version of **bbk** from [CRAN](https://CRAN.R-project.org) with:

```{r, eval = FALSE}
install.packages("bbk")
```

And the development version from [GitHub](https://github.com/) with:

```{r, eval = FALSE}
# install.packages("pak")
pak::pak("m-muecke/bbk")
```

## Usage

bbk functions are prefixed with either `bbk_` or `ecb_` depending on the origin of the
data and follow the naming convention of the APIs.
The usual workflow would be to search for the time series key on the [ECB Portal](https://data.ecb.europa.eu/) or
[Bundesbank website](https://www.bundesbank.de/en/statistics/time-series-databases)
and then use it to retrieve the data.

```{r demo, message = FALSE}
library(bbk)

# fetch 10 year daily yield curve
yield_curve <- bbk_data(
flow = "BBSIS",
key = "D.I.ZAR.ZI.EUR.S1311.B.A604.R10XX.R.A.A._Z._Z.A",
start_period = "2020-01-01"
)
yield_curve
```

```{r plotting, message = FALSE, echo = FALSE, dpi = 300}
library(ggplot2)

ggplot(yield_curve, aes(x = date, y = value)) +
geom_line() +
theme_minimal() +
theme(
plot.title = element_text(face = "bold"),
panel.grid.major.y = element_line(color = "black", linewidth = 0.2),
panel.grid.major.x = element_blank(),
panel.grid.minor = element_blank(),
axis.text = element_text(color = "black"),
axis.title = element_blank()
) +
scale_y_continuous(labels = scales::percent) +
labs(title = "Daily Yields of 10-Year Federal Securities")
```

## Related work

* [bundesbank](https://github.com/enricoschumann/bundesbank): R scripts for downloading time-series data from the Bundesbank.
* [ecb](https://github.com/expersso/ecb): R interface to the European Central Bank's Statistical Data Warehouse (SDW) API.
* [rsdmx](https://github.com/opensdmx/rsdmx): R package for reading SDMX data and metadata.
* [readsdmx](https://github.com/mdequeljoe/readsdmx): R package for reading SDMX data and metadata.
* [pdfetch](https://github.com/abielr/pdfetch): R package for downloading economic and financial time series from public sources.