World Bank Commodity Price Data (The Pink Sheet) - CMO

Data - WB

variable

Natural Gas: Europe and US

Nominal prices

Linear

Code
plot_linear <- CMO |>
  filter(Variable %in% c("Natural gas, US", "Natural gas, Europe")) |>
  ggplot() + geom_line(aes(x = date, y = value, color = Variable)) +
  labs(x = "", y = "Price of natural gas (Current $/mmbtu)") + theme_minimal() +
  scale_x_date(breaks = seq(1920, 2100, 10) |> paste0("-01-01") |> as.Date(),
               labels = date_format("%Y")) +
  scale_color_commodity() +
  theme(legend.position = c(0.4, 0.8),
        legend.title = element_blank()) +
  scale_y_continuous(breaks = seq(-20, 400, 10),
                     labels = dollar_format(a = 1))

plot_linear

Log

All

Code
plot_log <- CMO |>
  filter(Variable %in% c("Natural gas, US", "Natural gas, Europe")) |>
  ggplot() + geom_line(aes(x = date, y = value, color = Variable)) +
  labs(x = "", y = "Price of natural gas (Current $/mmbtu)") + theme_minimal() +
  scale_x_date(breaks = seq(1920, 2100, 10) |> paste0("-01-01") |> as.Date(),
               labels = date_format("%Y")) +
  scale_color_commodity() +
  theme(legend.position = c(0.4, 0.8),
        legend.title = element_blank()) +
  scale_y_log10(breaks = c(0.1, 0.2, 0.3, 0.5, 0.8, 1, 2, 3, 4, 5, 8, 10, 15, 20, 30, 40, 50),
                     labels = dollar_format(a = .1))

plot_log

1990-

Code
CMO |>
  filter(Variable %in% c("Natural gas, US", "Natural gas, Europe")) |>
  filter(date >= as.Date("1990-01-01")) |>
  ggplot() + geom_line(aes(x = date, y = value, color = Variable)) +
  labs(x = "", y = "Price of natural gas (Current $/mmbtu)") + theme_minimal() +
  scale_x_date(breaks = seq(1920, 2100, 5) |> paste0("-01-01") |> as.Date(),
               labels = date_format("%Y")) +
  scale_color_commodity() +
  theme(legend.position = c(0.4, 0.8),
        legend.title = element_blank()) +
  scale_y_log10(breaks = c(0.1, 0.2, 0.3, 0.5, 0.8, 1, 2, 3, 4, 5, 8, 10, 15, 20, 30, 40, 50, 80, 100),
                     labels = dollar_format(a = 1))

2000-

Code
CMO |>
  filter(Variable %in% c("Natural gas, US", "Natural gas, Europe")) |>
  filter(date >= as.Date("2000-01-01")) |>
  ggplot() + geom_line(aes(x = date, y = value, color = Variable)) +
  labs(x = "", y = "Price of natural gas (Current $/mmbtu)") + theme_minimal() +
  scale_x_date(breaks = seq(1920, 2100, 2) |> paste0("-01-01") |> as.Date(),
               labels = scales::date_format("%Y")) +
  scale_color_commodity() +
  theme(legend.position = c(0.4, 0.8),
        legend.title = element_blank()) +
  scale_y_log10(breaks = c(0.1, 0.2, 0.3, 0.5, 0.8, 1, 2, 3, 4, 5, 8, 10, 15, 20, 30, 40, 50, 80, 100),
                     labels = dollar_format(a = 1))

2000- (en français)

Code
gaz_fr <- c("Natural gas, Europe" = "Europe", "Natural gas, US" = "États-Unis")
pal <- commodity_colors[names(gaz_fr)]
names(pal) <- gaz_fr
d <- CMO |>
  filter(Variable %in% names(gaz_fr), date >= as.Date("2000-01-01"), !is.na(value)) |>
  mutate(zone = factor(gaz_fr[Variable], levels = gaz_fr))
d_fin <- d |> slice_max(date, by = zone)

# Point du jour : prix de marché (TTF en €/MWh converti en $/MMBtu, Henry Hub en $/MMBtu)
eurusd <- read_parquet(here::here("data", "investing", "fx_majors.parquet")) |>
  filter(pair == "EUR/USD") |>
  slice_max(scraped_at, n = 1, with_ties = FALSE) |>
  pull(bid)
d_jour <- read_parquet(here::here("data", "investing", "commodities.parquet")) |>
  filter(commodity %in% c("Dutch TTF Natural Gas", "Natural Gas")) |>
  slice_max(Date, by = commodity, with_ties = FALSE) |>
  transmute(date = Date,
            value = ifelse(commodity == "Dutch TTF Natural Gas", Close * eurusd / 3.412, Close),
            zone = factor(ifelse(commodity == "Dutch TTF Natural Gas", "Europe", "États-Unis"),
                          levels = gaz_fr)) |>
  mutate(label = paste0(zone, " : ",
                        scales::label_number(accuracy = .1, decimal.mark = ",", suffix = " $")(value),
                        " (", format(date, "%d %b"), ")"))
d_lien <- bind_rows(d_fin |> select(date, value, zone), d_jour |> select(date, value, zone))

d |>
  ggplot(aes(x = date, y = value, color = zone)) +
  geom_line(linewidth = 0.6) +
  geom_line(data = d_lien, linetype = "dashed", linewidth = 0.4) +
  geom_point(data = d_jour, shape = 21, fill = "white", size = 2.2, stroke = 0.9) +
  ggrepel::geom_text_repel(data = d_jour, aes(label = label),
                           nudge_x = 600, hjust = 0, direction = "y", box.padding = 0.4,
                           xlim = c(as.numeric(max(d_jour$date)) + 250, NA),
                           segment.size = 0.3, min.segment.length = 0,
                           arrow = arrow(length = unit(0.015, "npc")),
                           size = 3.3, show.legend = FALSE) +
  theme_minimal() + xlab("") +
  ylab("Prix du gaz naturel\n($ courants par MMBtu, échelle log)") +
  labs(caption = "Lignes : moyennes mensuelles, Banque mondiale (Pink Sheet).
Point creux : prix de marché du jour (TTF, Henry Hub), investing.com.") +
  scale_x_date(breaks = seq(as.Date("2000-01-01"), max(d_jour$date), "2 years"),
               labels = scales::label_date("%Y"),
               expand = expansion(mult = c(0.01, 0.38))) +
  scale_y_log10(breaks = c(1, 2, 3, 5, 8, 10, 15, 20, 30, 50, 80),
                labels = scales::label_number(accuracy = 1, suffix = " $")) +
  scale_color_manual(values = pal) +
  theme(legend.position = "none", panel.grid.minor = element_blank(),
        plot.caption = element_text(size = 8, color = "grey40"))

Bind

Code
ggpubr::ggarrange(plot_linear + ggtitle("Linear Scale"), plot_log  + ggtitle("Log Scale"), common.legend = T)

Real prices

Linear

Code
plot_linear <- CMO |>
  filter(Variable %in% c("Natural gas, US", "Natural gas, Europe")) |>
  left_join(CPIAUCSL, by = "date") |>
  arrange(desc(date)) |>
  filter(!is.na(CPIAUCSL)) |>
  mutate(value = value*CPIAUCSL[1]/CPIAUCSL) |>
  ggplot() + geom_line(aes(x = date, y = value, color = Variable)) +
  labs(x = "", y = "Price of natural gas (Constant $/mmbtu)") + theme_minimal() +
  scale_x_date(breaks = seq(1920, 2100, 10) |> paste0("-01-01") |> as.Date(),
               labels = date_format("%Y")) +
  scale_color_commodity() +
  theme(legend.position = c(0.2, 0.9),
        legend.title = element_blank()) +
  scale_y_continuous(breaks = seq(-20, 400, 5),
                     labels = dollar_format(a = 1))

plot_linear

Log

All

Code
plot_log <- CMO |>
  filter(Variable %in% c("Natural gas, US", "Natural gas, Europe")) |>
  left_join(CPIAUCSL, by = "date") |>
  arrange(desc(date)) |>
  filter(!is.na(CPIAUCSL)) |>
  mutate(value = value*CPIAUCSL[1]/CPIAUCSL) |>
  ggplot() + geom_line(aes(x = date, y = value, color = Variable)) +
  labs(x = "", y = "Price of natural gas (Constant $/mmbtu)") + theme_minimal() +
  scale_x_date(breaks = seq(1920, 2100, 10) |> paste0("-01-01") |> as.Date(),
               labels = date_format("%Y")) +
  scale_color_commodity() +
  theme(legend.position = c(0.2, 0.9),
        legend.title = element_blank()) +
  scale_y_log10(breaks = c(1, 2, 3, 4, 5, 8, 10, 15, 20, 30, 40, 50, 100),
                     labels = dollar_format(a = 1))

plot_log

1990-

Code
CMO |>
  filter(Variable %in% c("Natural gas, US", "Natural gas, Europe")) |>
  left_join(CPIAUCSL, by = "date") |>
  arrange(desc(date)) |>
  filter(!is.na(CPIAUCSL)) |>
  filter(date >= as.Date("1990-01-01")) |>
  mutate(value = value*CPIAUCSL[1]/CPIAUCSL) |>
  ggplot() + geom_line(aes(x = date, y = value, color = Variable)) +
  labs(x = "", y = "Price of natural gas (Constant $/mmbtu)") + theme_minimal() +
  scale_x_date(breaks = seq(1920, 2100, 5) |> paste0("-01-01") |> as.Date(),
               labels = date_format("%Y")) +
  scale_color_commodity() +
  theme(legend.position = c(0.2, 0.9),
        legend.title = element_blank()) +
  scale_y_log10(breaks = c(1, 2, 3, 4, 5, 8, 10, 15, 20, 30, 40, 50),
                     labels = dollar_format(a = 1))

2000-

Code
CMO |>
  filter(Variable %in% c("Natural gas, US", "Natural gas, Europe")) |>
  left_join(CPIAUCSL, by = "date") |>
  arrange(desc(date)) |>
  filter(!is.na(CPIAUCSL)) |>
  filter(date >= as.Date("2000-01-01")) |>
  mutate(value = value*CPIAUCSL[1]/CPIAUCSL) |>
  ggplot() + geom_line(aes(x = date, y = value, color = Variable)) +
  labs(x = "", y = "Price of natural gas (Constant $/mmbtu)") + theme_minimal() +
  scale_x_date(breaks = seq(1920, 2100, 2) |> paste0("-01-01") |> as.Date(),
               labels = date_format("%Y")) +
  scale_color_commodity() +
  theme(legend.position = c(0.2, 0.9),
        legend.title = element_blank()) +
  scale_y_log10(breaks = c(1, 2, 3, 4, 5, 8, 10, 15, 20, 30, 40, 50, 80, 100, 120, 250),
                     labels = dollar_format(a = 1))

1999-

Linear
Code
plot_linear <- CMO |>
  filter(Variable %in% c("Natural gas, US", "Natural gas, Europe")) |>
  arrange(desc(date)) |>
  filter(date >= as.Date("1999-01-01")) |>
  mutate(country = case_when(Variable == "Natural gas, US" ~ "États-Unis",
                             Variable == "Natural gas, Europe" ~ "Europe",
                             T ~ NA))  |>
  ggplot() + geom_line(aes(x = date, y = value, color = country)) +
  labs(x = "", y = "") + theme_minimal() +
  scale_x_date(breaks = c(seq(1999, 2100, 2)) |> paste0("-01-01") |> as.Date(),
               labels = date_format("%Y")) +
  scale_color_commodity() +
  theme(legend.position = c(0.2, 0.9),
        legend.title = element_blank(),
        axis.text.x = element_text(angle = 45, vjust = 1, hjust = 1)) +
  scale_y_continuous(breaks = seq(0, 100, 5),
                     labels = dollar_format(a = 1)) +
  labs(caption = "")
  

plot <- plot_linear
plot_linear

Code
save(plot, file = "CMO_files/figure-html/natural-gas-real-linear-1999-1.RData")
Log
Code
plot_log <- plot_linear +
  scale_y_log10(breaks = c(1, 2, 3, 4, 5, 8, 10, 15, 20, 30, 40, 50, 80),
                     labels = dollar_format(a = 1))

plot <- plot_log
save(plot, file = "CMO_files/figure-html/natural-gas-real-log-1999-1.RData")
plot

Both
Code
plot_both <- ggarrange(plot_linear + ggtitle("Linear Scale"), plot_log  + ggtitle("Log Scale"), common.legend = T)

plot <- plot_both
save(plot, file = "CMO_files/figure-html/natural-gas-real-both-1999-1.RData")
plot

Bind

Code
ggarrange(plot_linear + ggtitle("Linear Scale"), plot_log  + ggtitle("Log Scale"), common.legend = T)

Wheat Prices

Nominal prices

Linear

Code
plot_linear <- CMO |>
  filter(Variable %in% c("Wheat, US HRW", "Wheat, US SRW")) |>
  ggplot() + geom_line(aes(x = date, y = value, color = Variable)) +
  labs(x = "", y = "Price of wheat (Current $/mt)") + theme_minimal() +
  scale_x_date(breaks = seq(1920, 2100, 10) |> paste0("-01-01") |> as.Date(),
               labels = date_format("%Y")) +
  scale_color_commodity() +
  theme(legend.position = c(0.4, 0.8),
        legend.title = element_blank()) +
  scale_y_continuous(breaks = seq(0, 2000, 50),
                     labels = dollar_format(a = 1))

plot_linear

Log

Code
plot_log <- CMO |>
  filter(Variable %in% c("Wheat, US HRW", "Wheat, US SRW")) |>
  ggplot() + geom_line(aes(x = date, y = value, color = Variable)) +
  labs(x = "", y = "Price of wheat (Current $/mt)") + theme_minimal() +
  scale_x_date(breaks = seq(1920, 2100, 10) |> paste0("-01-01") |> as.Date(),
               labels = date_format("%Y")) +
  scale_color_commodity() +
  theme(legend.position = c(0.4, 0.8),
        legend.title = element_blank()) +
  scale_y_log10(breaks = 100*c(0.1, 0.2, 0.3, 0.5, 0.8, 1, 1.5, 2, 3, 4, 5, 7, 8, 10, 12, 14, 20, 30, 40, 50, 80),
                     labels = dollar_format(a = 1))

plot_log

Bind

Code
ggarrange(plot_linear + ggtitle("Linear Scale"), plot_log  + ggtitle("Log Scale"), common.legend = T)

Real prices

Linear

Code
plot_linear <- CMO |>
  filter(Variable %in% c("Wheat, US HRW", "Wheat, US SRW")) |>
  left_join(CPIAUCSL, by = "date") |>
  arrange(desc(date)) |>
  filter(!is.na(CPIAUCSL)) |>
  mutate(value = value*CPIAUCSL[1]/CPIAUCSL) |>
  ggplot() + geom_line(aes(x = date, y = value, color = Variable)) +
  labs(x = "", y = "Price of wheat (Current $/mt)") + theme_minimal() +
  scale_x_date(breaks = seq(1920, 2100, 10) |> paste0("-01-01") |> as.Date(),
               labels = date_format("%Y")) +
  scale_color_commodity() +
  theme(legend.position = c(0.8, 0.9),
        legend.title = element_blank()) +
  scale_y_continuous(breaks = seq(0, 2000, 50),
                     labels = dollar_format(a = 1))

plot_linear

Log

Code
plot_log <- CMO |>
  filter(Variable %in% c("Wheat, US HRW", "Wheat, US SRW")) |>
  left_join(CPIAUCSL, by = "date") |>
  arrange(desc(date)) |>
  filter(!is.na(CPIAUCSL)) |>
  mutate(value = value*CPIAUCSL[1]/CPIAUCSL) |>
  ggplot() + geom_line(aes(x = date, y = value, color = Variable)) +
  labs(x = "", y = "Price of wheat (Current $/mt)") + theme_minimal() +
  scale_x_date(breaks = seq(1920, 2100, 10) |> paste0("-01-01") |> as.Date(),
               labels = date_format("%Y")) +
  scale_color_commodity() +
  theme(legend.position = c(0.8, 0.9),
        legend.title = element_blank()) +
  scale_y_log10(breaks = 100*c(0.1, 0.2, 0.3, 0.5, 0.8, 1, 1.5, 2, 3, 4, 5,  8, 10, 12, 14, 20, 30, 40, 50),
                     labels = dollar_format(a = 1))

plot_log

Bind

Code
ggarrange(plot_linear + ggtitle("Linear Scale"), plot_log  + ggtitle("Log Scale"), common.legend = T)

Oil

Nominal prices

Linear

Code
plot_linear <- CMO |>
  filter(Variable %in% c("Crude oil, Dubai", "Crude oil, WTI")) |>
  ggplot() + geom_line(aes(x = date, y = value, color = Variable)) +
  labs(x = "", y = "Price of oil ($/bbl)") + theme_minimal() +
  scale_x_date(breaks = seq(1920, 2100, 10) |> paste0("-01-01") |> as.Date(),
               labels = date_format("%Y")) +
  scale_color_commodity() +
  theme(legend.position = c(0.4, 0.8),
        legend.title = element_blank()) +
  scale_y_continuous(breaks = seq(-20, 400, 10),
                     labels = dollar_format(a = 1))

plot_linear

Log

Code
plot_log <- CMO |>
  filter(Variable %in% c("Crude oil, Dubai", "Crude oil, WTI")) |>
  ggplot() + geom_line(aes(x = date, y = value, color = Variable)) +
  labs(x = "", y = "Price of oil ($/bbl)") + theme_minimal() +
  scale_x_date(breaks = seq(1920, 2100, 10) |> paste0("-01-01") |> as.Date(),
               labels = date_format("%Y")) +
  scale_color_commodity() +
  theme(legend.position = c(0.4, 0.8),
        legend.title = element_blank()) +
  scale_y_log10(breaks = c(1, 2, 3, 4, 5, 8, 10, 15, 20, 30, 40, 50, 80, 100, 200, 300, 500),
                     labels = dollar_format(a = 1))

plot_log

Bind

Code
ggarrange(plot_linear + ggtitle("Linear Scale"), plot_log  + ggtitle("Log Scale"), common.legend = T)

Real prices

Linear

Code
plot_linear <- CMO |>
  filter(Variable %in% c("Crude oil, Dubai", "Crude oil, WTI")) |>
  left_join(CPIAUCSL, by = "date") |>
  arrange(desc(date)) |>
  filter(!is.na(CPIAUCSL)) |>
  mutate(value = value*CPIAUCSL[1]/CPIAUCSL) |>
  ggplot() + geom_line(aes(x = date, y = value, color = Variable)) +
  labs(x = "", y = "Real price of oil ($/bbl)") + theme_minimal() +
  scale_x_date(breaks = seq(1920, 2100, 10) |> paste0("-01-01") |> as.Date(),
               labels = date_format("%Y")) +
  scale_color_commodity() +
  theme(legend.position = c(0.2, 0.9),
        legend.title = element_blank()) +
  scale_y_continuous(breaks = seq(-20, 400, 5),
                     labels = dollar_format(a = 1))

plot_linear

Log

Code
plot_log <- CMO |>
  filter(Variable %in% c("Crude oil, Dubai", "Crude oil, WTI")) |>
  left_join(CPIAUCSL, by = "date") |>
  arrange(desc(date)) |>
  filter(!is.na(CPIAUCSL)) |>
  mutate(value = value*CPIAUCSL[1]/CPIAUCSL) |>
  ggplot() + geom_line(aes(x = date, y = value, color = Variable)) +
  labs(x = "", y = "Real price of oil ($/bbl)") + theme_minimal() +
  scale_x_date(breaks = seq(1920, 2100, 10) |> paste0("-01-01") |> as.Date(),
               labels = date_format("%Y")) +
  scale_color_commodity() +
  theme(legend.position = c(0.2, 0.9),
        legend.title = element_blank()) +
  scale_y_log10(breaks = c(1, 2, 3, 4, 5, 8, 10, 15, 20, 30, 40, 50, 100, 200, 300, 500),
                     labels = dollar_format(a = 1))

plot_log

Bind

Code
ggarrange(plot_linear + ggtitle("Linear Scale"), plot_log  + ggtitle("Log Scale"), common.legend = T)