The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.

treasury

Lifecycle: experimental R-CMD-check

Overview

The goal of treasury is to provide a simple and modern interface to the US treasury XML feed for daily interest rates. The main difference to other packages is that it’s a modern implementation using the httr2 package.

Installation

You can install the development version of treasury from GitHub with:

# install.packages("pak")
pak::pak("m-muecke/treasury")

Usage

treasury functions are prefixed with tr_ and follow the naming convention of the XML feed.

library(ggplot2)
library(treasury)

yield_curve <- tr_yield_curve(2020)
yield_curve
#> # A tibble: 3,012 × 3
#>   date       maturity  rate
#>   <date>     <chr>    <dbl>
#> 1 2020-01-02 1 month   1.53
#> 2 2020-01-02 2 month   1.55
#> 3 2020-01-02 3 month   1.54
#> 4 2020-01-02 6 month   1.57
#> 5 2020-01-02 1 year    1.56
#> # ℹ 3,007 more rows

subset(yield_curve, maturity == "10 year") |>
  ggplot(aes(x = date, y = rate)) +
  geom_line() +
  labs(
    title = "US Treasury Yield Curve 2020 (10 Year Maturity)",
    x = NULL, y = NULL
  ) +
  theme_minimal()

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.