Data for the yield curve is available in B3’s website. 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)
library(dplyr)
<- 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(size = 1) +
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)
<- yc_ipca_mget(
df_yc first_date = Sys.Date() - 255 * 5,
last_date = Sys.Date(),
by = 255
)
<- ggplot(
p |> filter(biz_days > 21, biz_days < 1008),
df_yc aes(
x = forward_date,
y = r_252,
group = refdate,
color = factor(refdate)
)+
) geom_line(size = 1) +
labs(
title = "DIxIPCA 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)
<- yc_usd_mget(
df_yc first_date = Sys.Date() - 255 * 5,
last_date = Sys.Date(),
by = 255
)
<- ggplot(
p |> filter(biz_days > 21, biz_days < 2520),
df_yc aes(
x = forward_date,
y = r_360,
group = refdate,
color = factor(refdate)
)+
) geom_line(size = 1) +
labs(
title = "Cupom Limpo (USD) 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)