-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.Rmd
80 lines (62 loc) · 2.42 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# treasury
<!-- badges: start -->
[![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/treasury/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/m-muecke/treasury/actions/workflows/R-CMD-check.yaml)
[![CRAN status](https://www.r-pkg.org/badges/version/treasury)](https://CRAN.R-project.org/package=treasury)
<!-- badges: end -->
## Overview
The goal of treasury is to provide a simple and modern interface to the [US treasury XML feed](https://home.treasury.gov/treasury-daily-interest-rate-xml-feed) for daily interest rates.
## Installation
You can install the released version of **treasury** from [CRAN](https://CRAN.R-project.org) with:
```{r, eval = FALSE}
install.packages("treasury")
```
And the development version from [GitHub](https://github.com/) with:
```{r, eval = FALSE}
# install.packages("pak")
pak::pak("m-muecke/treasury")
```
## Usage
treasury functions are prefixed with `tr_` and follow the naming convention of the XML feed.
```{r usage, message = FALSE, dpi = 300}
library(treasury)
yield_curve <- tr_yield_curve(2023)
head(yield_curve)
```
```{r plot, message = FALSE, echo = FALSE, dpi = 300}
library(ggplot2)
subset(yield_curve, maturity == "10 year") |>
ggplot(aes(x = date, y = rate)) +
geom_line() +
theme_minimal() +
theme(
legend.title = element_blank(),
legend.position = "top",
plot.title = element_text(face = "bold"),
plot.caption = element_text(
hjust = 0, vjust = 0, size = 8, margin = margin(10, 0, 0, 0)
),
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(),
plot.margin = margin(10, 10, 10, 10)
) +
labs(title = "US Treasury Yield Curve 2023 (10 Year Maturity)")
```
## Related work
- [ustyc](https://github.com/mrbcuda/ustyc) - R package to download and parse the US Treasury yield curve data
- [ustfd](https://github.com/groditi/ustfd) - R client for US Treasury Fiscal Data API