Data for the yield curve is available in B3’s website, section DI X Pre. The data is built using interest rate futures. See this pdf for more details about the source of the yield curves.
library(rb3)
library(ggplot2)
library(stringr)
<- yc_mget(
df_yc first_date = Sys.Date() - 255 * 5,
last_date = Sys.Date(),
by = 255
)
<- ggplot(
p
df_yc,aes(
x = forward_date,
y = r_252,
group = refdate,
color = factor(refdate)
)+
) geom_line() +
labs(
title = "Yield Curves for Brazil",
subtitle = "Built using interest rates future contracts",
caption = str_glue("Data imported using rb3 at {Sys.Date()}"),
x = "Forward Date",
y = "Annual Interest Rate",
color = "Reference Date"
+
) theme_light() +
scale_y_continuous(labels = scales::percent)
print(p)