Skip to content

Instantly share code, notes, and snippets.

@MattCowgill
Last active May 10, 2022 04:24
Show Gist options
  • Save MattCowgill/c17262408c94f645809b3c70e3258a96 to your computer and use it in GitHub Desktop.
Save MattCowgill/c17262408c94f645809b3c70e3258a96 to your computer and use it in GitHub Desktop.
ANZ forward cash rate chart replication
library(readrba)
library(tidyverse)
theme_anz <- function(...) {
theme_minimal(...) +
theme(panel.grid.major.x = element_blank(),
panel.grid.minor = element_blank(),
legend.position = "bottom",
legend.direction = "horizontal",
legend.title = element_blank(),
axis.title.x = element_blank(),
plot.title = element_text(face = "bold"),
axis.ticks = element_line(),
axis.line = element_line(),
plot.title.position = "plot",
axis.text = element_text(family = "Courier New",
colour = "black",
face = "bold")
)
}
anz_grey <- "#C3C3C3"
anz_orange <- "#DAA76A"
f17_raw <- read_rba("F17")
forwards <- f17_raw |>
filter(str_detect(series, "Zero-coupon forward rate")) |>
separate(series, into = c("series", "horizon"), sep = " – ") |>
mutate(horizon = parse_number(horizon)) |>
mutate(horizon_date = date + (horizon * 365)) |>
select(series, date, horizon_date, value, horizon) |>
mutate(series = "Market pricing")
cash_rate_target <- read_rba_seriesid("FIRMMCRTD") |>
select(horizon_date = date, cash_rate_target = value) |>
filter(horizon_date >= min(forwards$horizon_date))
forwards <- cash_rate_target |>
rename(value = cash_rate_target) |>
mutate(series = "Actual") |>
bind_rows(forwards)
forwards |>
filter(horizon <= 1 | is.na(horizon)) |>
ggplot(aes(x = horizon_date,
y = value,
col = series,
group = date,
alpha = series)) +
geom_line() +
theme_anz(base_size = 8) +
scale_colour_manual(values = c(`Actual` = anz_orange,
`Market pricing` = anz_grey)) +
scale_alpha_manual(values = c(`Actual` = 1,
`Market pricing` = 0.075)) +
scale_size_manual(values = c(`Actual` = 2,
`Market pricing` = 0.5)) +
scale_x_date(date_labels = "%y",
date_breaks = "1 year") +
scale_y_continuous(breaks = seq(0, 6, 0.5)) +
guides(alpha = "none", size = "none") +
labs(y = "Zero-coupon forward rate",
title = "Market pricing for overnight cash rate")
ggsave("anz_cash_rate.png",
device = ragg::agg_png(),
scale = 0.33,
width = 16.2,
height = 10.37,
bg = "white",
dpi = "retina")
@MattCowgill
Copy link
Author

anz_cash_rate

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment