## ----setup, include = FALSE---------------------------------------------------
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

## ----eval=FALSE---------------------------------------------------------------
# library(aemo)
# 
# # All timestamps come back in AEST (UTC+10, no DST).
# # The tzone attribute is "Australia/Brisbane" throughout.
# p <- aemo_price("NSW1", "2024-01-15 14:00", "2024-01-15 15:00")
# attr(p$settlementdate, "tzone")  # "Australia/Brisbane"
# 
# # January is summer in Australia. Australia/Sydney would give UTC+11 here,
# # shifting every timestamp one hour ahead of the AEMO file clock.
# # Australia/Brisbane correctly gives UTC+10.
# format(p$settlementdate[1], "%Y-%m-%d %H:%M:%S %Z")

## ----eval=FALSE---------------------------------------------------------------
# # Convert market time to NSW wall clock (observes DST)
# p$local_time_nsw <- format(p$settlementdate, tz = "Australia/Sydney")
# 
# # Convert market time to SA wall clock (UTC+9:30 / UTC+10:30 with DST)
# p$local_time_sa <- format(p$settlementdate, tz = "Australia/Adelaide")

## ----eval=FALSE---------------------------------------------------------------
# # Period-start timestamps for 5-min intervals
# p$period_start <- p$settlementdate - as.difftime(5, units = "mins")
# 
# # Period-start timestamps for 30-min trading intervals
# t$period_start <- t$settlementdate - as.difftime(30, units = "mins")

## ----eval=FALSE---------------------------------------------------------------
# # Default: market pricing run only
# p_market <- aemo_price("NSW1", "2022-06-13", "2022-06-14")
# 
# # Both runs (for intervention analysis)
# p_both <- aemo_price("NSW1", "2022-06-13", "2022-06-14",
#                      intervention = TRUE)
# table(p_both$intervention)

