diff --git a/DESCRIPTION b/DESCRIPTION
index 7597fb73..5abe5933 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -1,7 +1,7 @@
Package: entsoeapi
Type: Package
Title: An R Wrapper for the European Network of Transmission System Operators for Electricity Application Programming Interface
-Version: 0.9.2.0
+Version: 0.9.3.0
Authors@R: c(person("Kenneth", "Rose", role="aut", email="kennethrose82@gmail.com"),
person("Sándor", "Budai", role=c("aut", "cre"), email="sbudai.ga@gmail.com"))
Description: Simple and standardized wrappers around Entso-E API's Market, Load, Generation,
diff --git a/NAMESPACE b/NAMESPACE
index 64dba701..94aab1a2 100644
--- a/NAMESPACE
+++ b/NAMESPACE
@@ -1,23 +1,33 @@
# Generated by roxygen2: do not edit by hand
export(accounting_point_eic)
+export(activated_balancing_prices)
+export(aggregated_balancing_energy_bids)
export(all_approved_eic)
export(allocated_transfer_capacities_3rd_countries)
+export(allocation_of_cross_zonal_balancing_cap)
export(already_allocated_total_capacity)
export(area_eic)
export(auction_revenue)
export(balancing_border_cap_limit)
+export(balancing_energy_bids)
+export(changes_to_bid_availability)
export(congestion_income)
export(continuous_offered_transfer_capacity)
+export(contracted_reserves)
export(costs_of_congestion_management)
export(countertrading)
export(cross_border_physical_flows)
+export(current_balancing_state)
export(day_ahead_commercial_sched)
export(day_ahead_prices)
export(elastic_demands)
export(exchanged_volumes)
+export(exchanged_volumes_per_border)
export(expansion_and_dismantling_project)
export(explicit_offered_transfer_capacity)
+export(fcr_total_capacity)
+export(financial_expenses_and_income_for_balancing)
export(flow_based_allocations)
export(forecasted_transfer_capacities)
export(gen_day_ahead_forecast)
@@ -27,6 +37,9 @@ export(gen_per_gen_unit)
export(gen_per_prod_type)
export(gen_storage_mean_filling_rate)
export(gen_wind_solar_forecasts)
+export(hvdc_link_constrains)
+export(imbalance_prices)
+export(imbalance_volumes)
export(implicit_offered_transfer_capacity)
export(intraday_cross_border_transfer_limits)
export(load_actual_total)
@@ -46,9 +59,13 @@ export(outages_offshore_grid)
export(outages_prod_units)
export(outages_transmission_grid)
export(party_eic)
+export(procured_balancing_capacity)
export(redispatching_cross_border)
export(redispatching_internal)
export(resource_object_eic)
+export(rr_actual_capacity)
+export(rr_and_frr_actual_capacity)
+export(shares_of_fcr_capacity)
export(substation_eic)
export(tie_line_eic)
export(total_commercial_sched)
diff --git a/NEWS.md b/NEWS.md
index 0b37a66e..2c268cce 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -1,3 +1,14 @@
+# entsoeapi v0.9.3.0 (2026-03-01)
+
+## New functionality
+
+- The beta versions of `exchanged_volumes_per_border()`, `hvdc_link_constrains()`, `changes_to_bid_availability()`, `current_balancing_state()`, `balancing_energy_bids()`, `aggregated_balancing_energy_bids()`, `procured_balancing_capacity()`, `allocation_of_cross_zonal_balancing_cap()`, `contracted_reserves()`, `activated_balancing_prices()`, `imbalance_prices()`, `imbalance_volumes()`, `financial_expenses_and_income_for_balancing()`, `fcr_total_capacity()`, `shares_of_fcr_capacity()`, `rr_and_frr_actual_capacity()` and `rr_actual_capacity()` queries have been introduced.
+
+## Miscellaneous
+
+- The warnings about not attached type names, eic names and definitions have been changed to simple console messages.
+- Minor under the hood improvements and fixes.
+
# entsoeapi v0.9.2.0 (2026-02-23)
## New functionality
diff --git a/R/en_balancing.R b/R/en_balancing.R
index 55683601..1e562425 100644
--- a/R/en_balancing.R
+++ b/R/en_balancing.R
@@ -16,8 +16,8 @@ utils::globalVariables(
#'
#' @param eic Energy Identification Code of the scheduling area
#' @param process_type type of frequency restoration reserve
-#' A47 mFRR
-#' A51 aFRR
+#' "A47" mFRR
+#' "A51" aFRR
#' @param period_start POSIXct or YYYY-MM-DD HH:MM:SS format
#' One year range limit applies
#' @param period_end POSIXct or YYYY-MM-DD HH:MM:SS format
@@ -29,11 +29,11 @@ utils::globalVariables(
#'
#' @examples
#' df <- entsoeapi::elastic_demands(
-#' eic = "10YCZ-CEPS-----N",
+#' eic = "10YCZ-CEPS-----N",
#' process_type = "A47",
#' period_start = lubridate::ymd(x = "2024-01-01", tz = "CET"),
-#' period_end = lubridate::ymd(x = "2024-11-01", tz = "CET"),
-#' tidy_output = TRUE
+#' period_end = lubridate::ymd(x = "2024-11-01", tz = "CET"),
+#' tidy_output = TRUE
#' )
#'
#' str(df)
@@ -63,17 +63,17 @@ elastic_demands <- function(
stop("The 'process_type' should be 'A47' or 'A51'.")
}
+ # check if valid security token is provided
+ if (security_token == "") stop("Valid security token should be provided.")
+
# check if the requested period is not longer than one year
if (difftime(period_end, period_start, units = "day") > 365L) {
stop("One year range limit should be applied!")
}
- # check if valid security token is provided
- if (security_token == "") stop("Valid security token should be provided.")
-
# convert timestamps into accepted format
period_start <- url_posixct_format(period_start)
- period_end <- url_posixct_format(period_end)
+ period_end <- url_posixct_format(period_end)
# compose GET request url for a (maximum) 1 year long period
query_string <- paste0(
@@ -119,11 +119,12 @@ elastic_demands <- function(
#'
#' @examples
#' df <- entsoeapi::netted_volumes(
-#' eic = "10YCZ-CEPS-----N",
+#' eic = "10YCZ-CEPS-----N",
#' period_start = lubridate::ymd(x = "2022-08-16", tz = "CET"),
-#' period_end = lubridate::ymd(x = "2022-08-17", tz = "CET"),
-#' tidy_output = TRUE
+#' period_end = lubridate::ymd(x = "2022-08-17", tz = "CET"),
+#' tidy_output = TRUE
#' )
+#'
#' str(df)
#'
netted_volumes <- function(
@@ -145,17 +146,17 @@ netted_volumes <- function(
stop("This wrapper only supports one control area EIC per request.")
}
+ # check if valid security token is provided
+ if (security_token == "") stop("Valid security token should be provided.")
+
# check if the requested period is not longer than one day
if (difftime(period_end, period_start, units = "day") > 1L) {
stop("One day range limit should be applied!")
}
- # check if valid security token is provided
- if (security_token == "") stop("Valid security token should be provided.")
-
# convert timestamps into accepted format
period_start <- url_posixct_format(period_start)
- period_end <- url_posixct_format(period_end)
+ period_end <- url_posixct_format(period_end)
# compose GET request url for a (maximum) 1 year long period
query_string <- paste0(
@@ -194,9 +195,9 @@ netted_volumes <- function(
#'
#' @param eic Energy Identification Code of the area
#' @param process_type type of frequency restoration reserve
-#' A51 aFRR
-#' A60 mFRR with scheduled activation
-#' A61 mFRR with direct activation
+#' "A51" aFRR
+#' "A60" mFRR with scheduled activation
+#' "A61" mFRR with direct activation
#' @param period_start POSIXct or YYYY-MM-DD HH:MM:SS format
#' One day range limit applies
#' @param period_end POSIXct or YYYY-MM-DD HH:MM:SS format
@@ -208,21 +209,22 @@ netted_volumes <- function(
#'
#' @examples
#' df1 <- entsoeapi::exchanged_volumes(
-#' eic = "10YCZ-CEPS-----N",
+#' eic = "10YCZ-CEPS-----N",
#' process_type = "A51",
#' period_start = lubridate::ymd(x = "2022-08-16", tz = "CET"),
-#' period_end = lubridate::ymd(x = "2022-08-17", tz = "CET"),
-#' tidy_output = TRUE
+#' period_end = lubridate::ymd(x = "2022-08-17", tz = "CET"),
+#' tidy_output = TRUE
#' )
#' str(df1)
#'
#' df2 <- entsoeapi::exchanged_volumes(
-#' eic = "10YCZ-CEPS-----N",
+#' eic = "10YCZ-CEPS-----N",
#' process_type = "A60",
#' period_start = lubridate::ymd(x = "2024-07-11", tz = "CET"),
-#' period_end = lubridate::ymd(x = "2024-07-12", tz = "CET"),
-#' tidy_output = TRUE
+#' period_end = lubridate::ymd(x = "2024-07-12", tz = "CET"),
+#' tidy_output = TRUE
#' )
+#'
#' str(df2)
#'
exchanged_volumes <- function(
@@ -251,17 +253,17 @@ exchanged_volumes <- function(
stop("The 'process_type' should be 'A51', 'A60' or 'A61'.")
}
+ # check if valid security token is provided
+ if (security_token == "") stop("Valid security token should be provided.")
+
# check if the requested period is not longer than one day
if (difftime(period_end, period_start, units = "day") > 1L) {
stop("One day range limit should be applied!")
}
- # check if valid security token is provided
- if (security_token == "") stop("Valid security token should be provided.")
-
# convert timestamps into accepted format
period_start <- url_posixct_format(period_start)
- period_end <- url_posixct_format(period_end)
+ period_end <- url_posixct_format(period_end)
# compose GET request url for a (maximum) 1 year long period
query_string <- paste0(
@@ -296,12 +298,10 @@ exchanged_volumes <- function(
#' or in Scheduling area (SCA)
#' @param eic_out Energy Identification Code of out an out LFC Area (LFA)
#' or out Scheduling area (SCA)
-#' @param eic_interconnector Energy Identification Code of a Transmission Asset,
-#' optional filter
#' @param process_type type of frequency restoration reserve
-#' A47 mFRR
-#' A51 aFRR
-#' A63 Imbalance Netting
+#' "A47" mFRR
+#' "A51" aFRR
+#' "A63" Imbalance Netting
#' @param period_start POSIXct or YYYY-MM-DD HH:MM:SS format
#' One year range limit applies
#' @param period_end POSIXct or YYYY-MM-DD HH:MM:SS format
@@ -313,20 +313,20 @@ exchanged_volumes <- function(
#'
#' @examples
#' df <- entsoeapi::balancing_border_cap_limit(
-#' eic_in = "10YDE-RWENET---I",
-#' eic_out = "10YBE----------2",
+#' eic_in = "10YDE-RWENET---I",
+#' eic_out = "10YBE----------2",
#' process_type = "A51",
#' period_start = lubridate::ymd(x = "2022-06-22", tz = "CET"),
-#' period_end = lubridate::ymd(x = "2022-06-23", tz = "CET"),
-#' tidy_output = TRUE
+#' period_end = lubridate::ymd(x = "2022-06-23", tz = "CET"),
+#' tidy_output = TRUE
#' )
+#'
#' str(df)
#'
balancing_border_cap_limit <- function(
eic_in = NULL,
eic_out = NULL,
- eic_interconnector = NULL,
- process_type = NULL,
+ process_type = "A51",
period_start = lubridate::ymd(
Sys.Date() - lubridate::days(x = 7L),
tz = "CET"
@@ -345,14 +345,6 @@ balancing_border_cap_limit <- function(
stop("This wrapper only supports one in and one out EIC per request.")
}
- # check if none or only one eic_interconnector provided
- if (!is.null(eic_interconnector) && length(eic_interconnector) > 1L) {
- stop(
- "None or one Transmission Asset (eic_interconnector) ",
- "should be provided."
- )
- }
-
# check if proper process_type provided
if (!process_type %in% c("A47", "A51", "A63")) {
stop("The 'process_type' should be 'A47', 'A51' or 'A63'.")
@@ -381,14 +373,6 @@ balancing_border_cap_limit <- function(
"&periodEnd=", period_end
)
- # if eic_interconnector is provided, then add it to the query string
- if (!is.null(eic_interconnector)) {
- query_string <- paste0(
- query_string,
- "®isteredResource=", eic_interconnector
- )
- }
-
# send GET request
en_cont_list <- api_req_safe(
query_string = query_string,
@@ -401,553 +385,1623 @@ balancing_border_cap_limit <- function(
-# 4.6.24. Permanent Allocation Limitations to
-# Cross-border Capacity on HVDC Lines [IFs 4.5]
-# Minimum time interval in query response depends on the duration
-# of matching published instances.
-# Mandatory parameters:
-# - DocumentType
-# - ProcessType
-# - BusinessType
-# - In_Domain
-# - Out_Domain
-# - TimeInterval or combination of PeriodStart and PeriodEnd
-# Optional Parameters:
-# - registeredResource (If used, data for the given
-# Transmission Asset is returned, otherwise,
-# the data for IC not specified is returned.)
-# GET /api?documentType=A99
-# &processType=A51
-# &BusinessType=B06
-# &In_Domain=10YAT-APG------L
-# &TimeInterval=2020-12-31T23:00Z/2021-01-01T23:00Z
-# &Out_Domain=10YDE-RWENET---I
-
-
-
-# 4.6.3.Changes to Bid Availability [IFs mFRR 9.9, aFRR 9.6 & 9.8]
-# 100 documents limit applies
-# Mandatory Parameters:
-# - DocumentType
-# - ProcessType
-# - Domain
-# - TimeInterval or combination of PeriodStart and PeriodEnd
-# Optional Parameters:
-# - Offset (allows downloading more than 100 documents. The offset ∈ [0,4800]
-# so that paging is restricted to query for 4900 documents max.,
-# offset=n returns files in sequence between n+1 and n+100)
-# - BusinessType
-# GET /api? documentType=B45
-# &processtype=A47
-# &Domain=10YCZ-CEPS-----N
-# &periodStart=202208152200
-# &periodEnd=202208162200
-
-
-
-# 4.6.1. Current Balancing State [GL EB 12.3.A]
-# 100 day range limit applies
-# Mandatory Parameters:
-# - DocumentType
-# - BusinessType
-# - Area_Domain
-# - TimeInterval or combination of PeriodStart and PeriodEnd
-# GET /api?documentType=A86
-# &businessType=B33
-# &Area_Domain=10YCZ-CEPS-----N
-# &periodStart=201912190000
-# &periodEnd=201912190010
-
-
-
-# 4.6.2.Balancing Energy Bids [GL EB 12.3.B&C]
-# 100 documents limit applies
-# Mandatory Parameters:
-# - DocumentType
-# - ProcessType
-# - connecting_Domain
-# - businessType
-# - TimeInterval or combination of PeriodStart and PeriodEnd
-# Optional Parameters:
-# - Offset (allows downloading more than 100 documents. The offset ∈ [0,4800]
-# so that paging is restricted to query for 4900 documents max.,
-# offset=n returns files in sequence between n+1 and n+100)
-# - Standard_MarketProduct
-# - Original_MarketProduct
-# - Direction
-# GET /api? documentType=A37
-# &ProcessType=A47
-# &businessType=B74
-# &connecting_Domain=10YCZ-CEPS-----N
-# &periodStart=202208152200
-# &periodEnd=202208162200
-
-
-
-# 4.6.4. Aggregated Balancing Energy Bids [GL EB 12.3.E]
-# One year range limit applies
-# Mandatory Parameters:
-# - DocumentType
-# - ProcessType
-# - Area_Domain
-# - TimeInterval or combination of PeriodStart and PeriodEnd
-# GET /api? documentType=A24
-# &processType=A51
-# &area_Domain=10YCZ-CEPS-----N
-# &TimeInterval=2019-12-16T13:00Z/2019-12-16T18:00Z
-
-
-
-# 4.6.5. Procured Balancing Capacity [GL EB 12.3.F]
-# 100 document limit applies
-# Mandatory Parameters:
-# - DocumentType
-# - ProcessType
-# - Area_Domain
-# - TimeInterval or combination of PeriodStart and PeriodEnd
-# Optional Parameters:
-# - Offset (allows downloading more than 100 documents.
-# The offset [0,4800] so that paging is restricted to query for
-# 4900 documents max., offset=n returns files in sequence between
-# n+1 and n+100)
-# - Type_MarketAgreement.Type
-# GET /api? documentType=A15
-# &processType=A51
-# &area_Domain=10YCZ-CEPS-----N
-# &TimeInterval=2019-12-31T23:00Z/2020-01-01T00:00Z
-
-
-
-# 4.6.6. Use of Allocated Cross-Zonal Balancing Capacity [GL EB 12.3.H & I]
-# Mandatory parameters:
-# - DocumentType
-# - ProcessType
-# - Acquiring_Domain
-# - Connecting_Domain
-# - TimeInterval or combination of PeriodStart and PeriodEnd
-# Optional parameters:
-# - Type_MarketAgreement.Type
-# GET /api?documentType=A38
-# &processType=A46
-# &Acquiring_Domain=10YAT-APG------L
-# &Connecting_Domain=10YCH-SWISSGRIDZ
-# &TimeInterval=2019-12-16T00:00Z/2019-12-17T00:00Z
-
-
-
-# 4.6.8. Amount of Balancing Reserves Under Contract [17.1.B]
-# Minimum time interval in query response ranges from
-# part of day to year, depending on selected Type_MarketAgreement.Type
-# Mandatory parameters:
-# - DocumentType
-# - Type_MarketAgreement.Type
-# - ControlArea_Domain
-# - TimeInterval or combination of PeriodStart and PeriodEnd
-# Optional parameters:
-# - BusinessType
-# - PsrType
-# - offset (allows downloading more than 100 documents.
-# The offset ∈ [0,4800] so that paging is restricted to query for
-# 4900 documents max., offset=n returns files in sequence
-# between n+1 and n+100)
-# GET /api?documentType=A81
-# &type_MarketAgreement.Type=A13
-# &businessType=A95
-# &psrType=A04
-# &controlArea_Domain=10YCZ-CEPS-----N
-# &periodStart=201512312300
-# &periodEnd=201601012300
-
-
-
-# 4.6.9. Prices of Procured Balancing Reserves [17.1.C]
-# Minimum time interval in query response ranges from part of day to year,
-# depending on selected Type_MarketAgreement.Type
-# Mandatory parameters:
-# - DocumentType
-# - Type_MarketAgreement.Type
-# - ControlArea_Domain
-# - TimeInterval or combination of PeriodStart and PeriodEnd
-# Optional parameters:
-# - BusinessType
-# - PsrType
-# - offset (allows downloading more than 100 documents.
-# The offset ∈ [0,4800] so that paging is restricted to query for 4900
-# documents max., offset=n returns files in sequence between n+1 and n+100)
-# GET /api?documentType=A89
-# &type_MarketAgreement.Type=A01
-# &businessType=A96
-# &controlArea_Domain=10YCZ-CEPS-----N
-# &periodStart=201512312300
-# &periodEnd=201601012300
-
-
-
-# 4.6.7. Volumes and Prices of Contracted Reserves [17.1.B & C]
-# Minimum time interval in query response ranges from part of day to year,
-# depending on selected Type_MarketAgreement.Type
-# Mandatory parameters:
-# - DocumentType
-# - BusinessType
-# - ProcessType
-# - Type_MarketAgreement.Type
-# - ControlArea_Domain
-# - TimeInterval or combination of PeriodStart and PeriodEnd
-# Optional parameters:
-# - PsrType
-# - offset - (allows downloading more than 100 documents.
-# The offset must belong to the range [0,4800] so
-# that paging is restricted to query for 4900 documents max.,
-# offset=n returns files in sequence between n+1 and n+100)
-# GET /api?documentType=A81
-# &type_MarketAgreement.Type=A13
-# &businessType=B95
-# &processType=A52
-# &psrType=A04
-# &controlArea_Domain=10YCZ-CEPS-----N
-# &periodStart=201512312300
-# &periodEnd=201601012300
-
-
-
-#' #' @title
-#' #' Get Accepted Aggregated Offers (17.1.D)
-#' #'
-#' #' @description
-#' #' Energy volumes available for activation.
-#' #'
-#' #' @param eic Energy Identification Code of the control area domain
-#' #' @param period_start POSIXct or YYYY-MM-DD HH:MM:SS format
-#' #' One year range limit applies
-#' #' @param period_end POSIXct or YYYY-MM-DD HH:MM:SS format
-#' #' One year range limit applies
-#' #' @param reserve_type Defaults to NULL, otherwise choose among the
-#' #' list of reserve type codes (A95, A96, A97, A98)
-#' #' from business_types table
-#' #' @param tidy_output Defaults to TRUE. flatten nested tables
-#' #' @param security_token Security token for ENTSO-E transparency platform
-#' #'
-#' #' export
-#' #'
-#' #' @examples
-#' #' df <- entsoeapi::balancing_accepted_aggr_offers(
-#' #' eic = "10YHU-MAVIR----U",
-#' #' period_start = lubridate::ymd(x = "2020-02-01", tz = "CET"),
-#' #' period_end = lubridate::ymd(x = "2020-03-01", tz = "CET"),
-#' #' tidy_output = TRUE,
-#' #' reserve_type = "A96"
-#' #' )
-#' #' str(df)
-#' #'
-#' balancing_accepted_aggr_offers <- function(
-#' eic = NULL,
-#' period_start = lubridate::ymd(
-#' Sys.Date() - lubridate::days(x = 7L),
-#' tz = "CET"
-#' ),
-#' period_end = lubridate::ymd(Sys.Date(), tz = "CET"),
-#' reserve_type = NULL,
-#' tidy_output = TRUE,
-#' security_token = Sys.getenv("ENTSOE_PAT")
-#' ) {
-#'
-#' # check if only one eic provided
-#' if (is.null(eic)) stop("One control area EIC should be provided.")
-#' if (length(eic) > 1L) {
-#' stop("This wrapper only supports one control area EIC per request.")
-#' }
+#' @title
+#' Get Netted & Exchanged Volumes Per Border (IFs 3.10, 3.16 & 3.17)
#'
-#' # check if the requested period is not longer than one year
-#' if (difftime(period_end, period_start, units = "day") > 365) {
-#' stop("One year range limit should be applied!")
-#' }
+#' @description
+#' Netted and exchanged balancing energy volumes on a specific border between
+#' an acquiring and a connecting domain.
#'
-#' # check if valid security token is provided
-#' if (security_token == "") stop("Valid security token should be provided.")
+#' @param acquiring_eic Energy Identification Code of the acquiring area
+#' @param connecting_eic Energy Identification Code of the connecting area
+#' @param process_type type of frequency restoration reserve
+#' "A51" aFRR
+#' "A60" mFRR with scheduled activation
+#' "A61" mFRR with direct activation
+#' @param period_start POSIXct or YYYY-MM-DD HH:MM:SS format
+#' One day range limit applies
+#' @param period_end POSIXct or YYYY-MM-DD HH:MM:SS format
+#' One day range limit applies
+#' @param tidy_output Defaults to TRUE. flatten nested tables
+#' @param security_token Security token for ENTSO-E transparency platform
#'
-#' # convert timestamps into accepted format
-#' period_start <- url_posixct_format(period_start)
-#' period_end <- url_posixct_format(period_end)
+#' @export
#'
-#' # compose GET request url for a (maximum) 1 year long period
-#' query_string <- paste0(
-#' "documentType=A82",
-#' "&controlArea_Domain=", eic,
-#' "&periodStart=", period_start,
-#' "&periodEnd=", period_end,
-#' {
-#' if (is.null(reserve_type)) "" else paste0("&businessType=",
-#' reserve_type)
-#' }
-#' )
+#' @examples
+#' df <- entsoeapi::exchanged_volumes_per_border(
+#' acquiring_eic = "10YBE----------2",
+#' connecting_eic = "10YFR-RTE------C",
+#' process_type = "A60",
+#' period_start = lubridate::ymd(x = "2025-03-01", tz = "CET"),
+#' period_end = lubridate::ymd(x = "2025-03-02", tz = "CET"),
+#' tidy_output = TRUE
+#' )
#'
-#' # send GET request
-#' en_cont_list <- api_req_safe(
-#' query_string = query_string,
-#' security_token = security_token
-#' )
+#' str(df)
#'
-#' # return with the extracted the response
-#' return(extract_response(content = en_cont_list, tidy_output = tidy_output))
-#' }
+exchanged_volumes_per_border <- function(
+ acquiring_eic = NULL,
+ connecting_eic = NULL,
+ process_type = NULL,
+ period_start = lubridate::ymd(
+ Sys.Date() - lubridate::days(x = 7L),
+ tz = "CET"
+ ),
+ period_end = lubridate::ymd(
+ Sys.Date(),
+ tz = "CET"
+ ),
+ tidy_output = TRUE,
+ security_token = Sys.getenv("ENTSOE_PAT")
+) {
+ # check if only one acquiring_eic provided
+ if (is.null(acquiring_eic)) {
+ stop("One acquiring EIC should be provided.")
+ }
+ if (length(acquiring_eic) > 1L) {
+ stop("This wrapper only supports one acquiring EIC per request.")
+ }
+ # check if only one connecting_eic provided
+ if (is.null(connecting_eic)) {
+ stop("One connecting EIC should be provided.")
+ }
+ if (length(connecting_eic) > 1L) {
+ stop("This wrapper only supports one connecting EIC per request.")
+ }
+ # check if proper process_type provided
+ if (is.null(process_type) || !process_type %in% c("A51", "A60", "A61")) {
+ stop("The 'process_type' should be 'A51', 'A60' or 'A61'.")
+ }
-#' #' @title
-#' #' Get Activated Balancing Reserves (17.1.E)
-#' #'
-#' #' @description
-#' #' The amount of activated balancing energy.
-#' #'
-#' #' @param eic Energy Identification Code of the control area domain
-#' #' @param period_start POSIXct or YYYY-MM-DD HH:MM:SS format
-#' #' One year range limit applies
-#' #' @param period_end POSIXct or YYYY-MM-DD HH:MM:SS format
-#' #' One year range limit applies
-#' #' @param reserve_type Defaults to NULL, otherwise choose among the
-#' #' list of reserve type codes (A95, A96, A97, A98)
-#' #' from business_types table
-#' #' @param tidy_output Defaults to TRUE. flatten nested tables
-#' #' @param security_token Security token for ENTSO-E transparency platform
-#' #'
-#' #' export
-#' #'
-#' #' @examples
-#' #' df <- entsoeapi::balancing_activated_reserves(
-#' #' eic = "10YHU-MAVIR----U",
-#' #' period_start = lubridate::ymd(x = "2020-02-01", tz = "CET"),
-#' #' period_end = lubridate::ymd(x = "2020-03-01", tz = "CET"),
-#' #' tidy_output = TRUE,
-#' #' reserve_type = "A96"
-#' #' )
-#' #' str(df)
-#' #'
-#' balancing_activated_reserves <- function(
-#' eic = NULL,
-#' period_start = lubridate::ymd(
-#' Sys.Date() - lubridate::days(x = 7L),
-#' tz = "CET"
-#' ),
-#' period_end = lubridate::ymd(Sys.Date(), tz = "CET"),
-#' reserve_type = NULL,
-#' tidy_output = TRUE,
-#' security_token = Sys.getenv("ENTSOE_PAT")
-#' ) {
-#'
-#' # check if only one eic provided
-#' if (is.null(eic)) stop("One control area EIC should be provided.")
-#' if (length(eic) > 1L) {
-#' stop("This wrapper only supports one control area EIC per request.")
-#' }
+ # check if valid security token is provided
+ if (security_token == "") stop("Valid security token should be provided.")
+
+ # check if the requested period is not longer than one day
+ if (difftime(period_end, period_start, units = "day") > 1L) {
+ stop("One day range limit should be applied!")
+ }
+
+ # convert timestamps into accepted format
+ period_start <- url_posixct_format(period_start)
+ period_end <- url_posixct_format(period_end)
+
+ # compose GET request url
+ query_string <- paste0(
+ "documentType=A30",
+ "&processType=", process_type,
+ "&Acquiring_domain=", acquiring_eic,
+ "&Connecting_Domain=", connecting_eic,
+ "&periodStart=", period_start,
+ "&periodEnd=", period_end
+ )
+
+ # send GET request
+ en_cont_list <- api_req_safe(
+ query_string = query_string,
+ security_token = security_token
+ )
+
+ # return with the extracted the response
+ extract_response(content = en_cont_list, tidy_output = tidy_output)
+}
+
+
+
+#' @title
+#' Get HVDC Link Constraints (IFs 4.5)
#'
-#' # check if the requested period is not longer than one year
-#' if (difftime(period_end, period_start, units = "day") > 365) {
-#' stop("One year range limit should be applied!")
-#' }
+#' @description
+#' Permanent allocation limitations to cross-border capacity on HVDC lines.
#'
-#' # check if valid security token is provided
-#' if (security_token == "") stop("Valid security token should be provided.")
+#' @param eic_in Energy Identification Code of the in domain
+#' @param eic_out Energy Identification Code of the out domain
+#' @param eic_ic Energy Identification Code of the interconnector
+#' If used, data for the given Transmission Asset is returned
+#' @param process_type "A47" Manual frequency restoration reserve
+#' "A51" Automatic Frequency Restoration Reserve
+#' "A63" Imbalance Netting;
+#' Defaults to "A63"
+#' @param period_start POSIXct or YYYY-MM-DD HH:MM:SS format
+#' One year range limit applies
+#' @param period_end POSIXct or YYYY-MM-DD HH:MM:SS format
+#' One year range limit applies
+#' @param tidy_output Defaults to TRUE. flatten nested tables
+#' @param security_token Security token for ENTSO-E transparency platform
#'
-#' # convert timestamps into accepted format
-#' period_start <- url_posixct_format(period_start)
-#' period_end <- url_posixct_format(period_end)
+#' @export
#'
-#' # compose GET request url for a (maximum) 1 year long period
-#' query_string <- paste0(
-#' "documentType=A83",
-#' "&controlArea_Domain=", eic,
-#' "&periodStart=", period_start,
-#' "&periodEnd=", period_end,
-#' {
-#' if (is.null(reserve_type)) "" else paste0("&businessType=",
-#' reserve_type)
-#' }
-#' )
+#' @examples
+#' df <- entsoeapi::hvdc_link_constrains(
+#' eic_in = "10YAT-APG------L",
+#' eic_out = "10YDE-RWENET---I",
+#' process_type = "A63",
+#' period_start = lubridate::ymd(x = "2022-01-01", tz = "CET"),
+#' period_end = lubridate::ymd(x = "2022-01-02", tz = "CET"),
+#' tidy_output = TRUE
+#' )
#'
-#' # send GET request
-#' en_cont_list <- api_req_safe(
-#' query_string = query_string,
-#' security_token = security_token
-#' )
+#' str(df)
#'
-#' # return with the extracted the response
-#' return(extract_response(content = en_cont_list, tidy_output = tidy_output))
-#' }
+hvdc_link_constrains <- function(
+ eic_in = NULL,
+ eic_out = NULL,
+ eic_ic = NULL,
+ process_type = "A63",
+ period_start = lubridate::ymd(
+ Sys.Date() - lubridate::days(x = 7L),
+ tz = "CET"
+ ),
+ period_end = lubridate::ymd(
+ Sys.Date(),
+ tz = "CET"
+ ),
+ tidy_output = TRUE,
+ security_token = Sys.getenv("ENTSOE_PAT")
+) {
+ # check if only one eic provided
+ if (is.null(eic_in)) stop("One 'in' domain EIC should be provided.")
+ if (is.null(eic_out)) stop("One 'out' domain EIC should be provided.")
+ if (length(eic_in) > 1L || length(eic_out) > 1L) {
+ stop("This wrapper only supports one in and one out EIC per request.")
+ }
+ if (length(eic_ic) > 1L) {
+ stop("This wrapper only supports one interconnector EIC per request.")
+ }
+
+ # check if proper process_type provided
+ if (!process_type %in% c("A47", "A51", "A63")) {
+ stop("The 'process_type' should be 'A47', 'A51' or 'A63'.")
+ }
+
+ # check if valid security token is provided
+ if (security_token == "") stop("Valid security token should be provided.")
+
+ # check if the requested period is not longer than one year
+ if (difftime(period_end, period_start, units = "day") > 365L) {
+ stop("One year range limit should be applied!")
+ }
+
+ # convert timestamps into accepted format
+ period_start <- url_posixct_format(period_start)
+ period_end <- url_posixct_format(period_end)
+
+ # compose GET request url
+ query_string <- paste0(
+ "documentType=A99",
+ "&processType=", process_type,
+ "&BusinessType=B06",
+ "&In_Domain=", eic_in,
+ "&Out_Domain=", eic_out,
+ if (is.null(eic_ic)) "" else "®isteredResource=", eic_ic,
+ "&periodStart=", period_start,
+ "&periodEnd=", period_end
+ )
+
+ # send GET request
+ en_cont_list <- api_req_safe(
+ query_string = query_string,
+ security_token = security_token
+ )
+
+ # return with the extracted the response
+ extract_response(content = en_cont_list, tidy_output = tidy_output)
+}
-# 4.6.12. Prices of Activated Balancing Energy &
-# aFRR CBMPs [TR 17.1.F, IF aFRR 3.16]
-# One year range limit applies
-# Minimum time interval in query response is one ISP period
-# Mandatory parameters:
-# - DocumentType
-# - ControlArea_Domain
-# - TimeInterval or combination of PeriodStart and PeriodEnd
-# - ProcessType - A16 used if not provided (temporary solution)
-# Optional parameters:
-# - BusinessType
-# - PsrType
-# - Standard_MarketProduct
-# - Original_MarketProduct
-# - ExportType=zip (to be used only when queried data is available
-# in legacy and new technologies)
-# GET /api?documentType=A84
-# &processtype=A16
-# &controlArea_Domain=10YCZ-CEPS-----N
-# &periodStart=202208152200
-# &periodEnd=202208162200
-
-
-
-# 4.6.13. Imbalance Prices [17.1.G]
-# One year range limit applies
-# Minimum time interval in query response is one BTU period
-# Mandatory parameters:
-# - DocumentType
-# - ControlArea_Domain
-# - TimeInterval or combination of PeriodStart and PeriodEnd
-# Optional parameters:
-# - PsrType
-# GET /api?documentType=A85
-# &controlArea_Domain=10YCZ-CEPS-----N
-# &periodStart=201512312300
-# &periodEnd=201612312300
-
-
-
-# 4.6.14. Total Imbalance Volumes [17.1.H]
-# One year range limit applies
-# Minimum time interval in query response is one BTU period
-# Mandatory parameters:
-# - DocumentType
-# - ControlArea_Domain
-# - TimeInterval or combination of PeriodStart and PeriodEnd
-# GET /api?documentType=A86
-# &controlArea_Domain=10YCZ-CEPS-----N
-# &periodStart=201512312300
-# &periodEnd=201612312300
-
-
-
-# 4.6.15. Financial Expenses and Income for Balancing [17.1.I]
-# One year range limit applies
-# Minimum time interval in query response is one month
-# Mandatory parameters:
-# - DocumentType
-# - ControlArea_Domain
-# - TimeInterval or combination of PeriodStart and PeriodEnd
-# GET /api?documentType=A87
-# &controlArea_Domain=10YCZ-CEPS-----N
-# &periodStart=201512312300
-# &periodEnd=201612312300
-
-
-
-# 4.6.16. Cross-border Balancing [17.1.J]
-# One year range limit applies
-# Minimum time interval in query response is one BTU period
-# Mandatory parameters:
-# - DocumentType
-# - Acquiring_Domain
-# - Connecting_Domain
-# - TimeInterval or combination of PeriodStart and PeriodEnd
-# In the query response, the attribute secondaryQuantity contains
-# the Aggregated offers, quantity contains the activated offers
-# and prices are available in the minimum_Price.amount and
-# maximum_Price.amount attributes.
-# GET /api?documentType=A88
-# &acquiring_Domain=10YCZ-CEPS-----N
-# &connecting_Domain=10YSK-SEPS-----K
-# &periodStart=201512312300
-# &periodEnd=201601010100
-
-
-
-# 4.6.17. FCR Total capacity [SO GL 187.2]
-# One year range limit applies
-# Mandatory parameters:
-# - DocumentType
-# - BusinessType
-# - Area_Domain
-# - TimeInterval or combination of PeriodStart and PeriodEnd
-# GET /api?documentType=A26
-# &area_Domain=10YEU-CONT-SYNC0
-# &businessType=A25
-# &TimeInterval=2018-12-31T23:00Z/2019-12-31T23:00Z
-
-
-
-# 4.6.18. Shares of FCR capacity - share of capacity [SO GL 187.2]
-# One year range limit applies
-# Mandatory parameters:
-# - DocumentType
-# - BusinessType
-# - Area_Domain
-# - TimeInterval or combination of PeriodStart and PeriodEnd
-# GET /api?documentType=A26
-# &area_Domain=10YDE-VE-------2
-# &businessType=C23
-# &TimeInterval=2019-12-31T23:00Z/2020-12-31T23:00Z
-
-
-
-# 4.6.19. Shares of FCR capacity - contracted reserve capacity [SO GL 187.2]
-# One year range limit applies
-# Mandatory parameters:
-# - DocumentType
-# - BusinessType
-# - Area_Domain
-# - TimeInterval or combination of PeriodStart and PeriodEnd
-# GET /api?documentType=A26
-# &businessType=B95
-# &TimeInterval=2019-12-31T23:00Z/2020-12-31T23:00Z
-# &Area_Domain=10YDE-RWENET---I
-
-
-
-# 4.6.20. FRR Actual Capacity [SO GL 188.4]
-# Mandatory parameters:
-# - DocumentType
-# - ProcessType
-# - BusinessType
-# - Area_Domain
-# - TimeInterval or combination of PeriodStart and PeriodEnd
-# GET /api?documentType=A26
-# &processType=A56
-# &businessType=C24
-# &Area_Domain=10YAT-APG------L
-# &TimeInterval=2019-12-31T23:00Z/2020-03-31T22:00Z
-
-
-
-# 4.6.21. RR Actual Capacity [SO GL 189.3]
-# Mandatory parameters:
-# - DocumentType
-# - ProcessType
-# - BusinessType
-# - Area_Domain
-# - TimeInterval or combination of PeriodStart and PeriodEnd
-# GET /api?documentType=A26
-# &processType=A46
-# &businessType=C24
-# &Area_Domain=10YAT-APG------L
-# &TimeInterval=2019-12-31T23:00Z/2020-03-31T22:00Z
-
-
-
-# 4.6.22. Sharing of RR and FRR [SO GL 190.1]
-# One year range limit applies
-# Mandatory parameters:
-# - DocumentType
-# - BusinessType
-# - ProcessType
-# - Acquiring_Domain
-# - Connecting_Domain
-# T- imeInterval or combination of PeriodStart and PeriodEnd
-# GET /api?documentType=A26
-# &businessType=C22
-# &TimeInterval=2019-12-31T23:00Z/2020-12-31T23:00Z
-# &Connecting_Domain=10YAT-APG------L
-# &Acquiring_Domain=10YCB-GERMANY--8
-# &processType=A56
+#' @title
+#' Get Changes to Bid Availability (IFs mFRR 9.9, aFRR 9.6 & 9.8)
+#'
+#' @description
+#' Changes to bid availability for scheduled activation products.
+#' 100 documents limit applies; paging is handled transparently.
+#'
+#' @param eic Energy Identification Code of the domain
+#' @param business_type type of frequency restoration reserve
+#' "C40" Conditional bid
+#' "C41" Thermal limit
+#' "C42" Frequency limit
+#' "C43" Voltage limit
+#' "C44" Current limit
+#' "C45" Short-circuit current limits
+#' "C46" Dynamic stability limit
+#' Defaults to "C46".
+#' @param period_start POSIXct or YYYY-MM-DD HH:MM:SS format
+#' One year range limit applies
+#' @param period_end POSIXct or YYYY-MM-DD HH:MM:SS format
+#' One year range limit applies
+#' @param tidy_output Defaults to TRUE. flatten nested tables
+#' @param security_token Security token for ENTSO-E transparency platform
+#'
+#' @export
+#'
+#' @examples
+#' df <- entsoeapi::changes_to_bid_availability(
+#' eic = "10YCZ-CEPS-----N",
+#' business_type = "C46",
+#' period_start = lubridate::ymd(x = "2024-01-01", tz = "CET"),
+#' period_end = lubridate::ymd(x = "2024-01-02", tz = "CET"),
+#' tidy_output = TRUE
+#' )
+#'
+#' str(df)
+#'
+changes_to_bid_availability <- function(
+ eic = NULL,
+ business_type = "C46",
+ period_start = lubridate::ymd(
+ Sys.Date() - lubridate::days(x = 7L),
+ tz = "CET"
+ ),
+ period_end = lubridate::ymd(
+ Sys.Date(),
+ tz = "CET"
+ ),
+ tidy_output = TRUE,
+ security_token = Sys.getenv("ENTSOE_PAT")
+) {
+ # check if only one eic provided
+ if (is.null(eic)) stop("One control area EIC should be provided.")
+ if (length(eic) > 1L) {
+ stop("This wrapper only supports one control area EIC per request.")
+ }
+
+ # check if proper business_type provided
+ if (is.null(business_type) || !business_type %in% c(
+ "C40", "C41", "C42", "C43", "C44", "C45", "C46"
+ )
+ ) {
+ stop(
+ "The 'business_type' should be 'C40', 'C41', ",
+ "'C42', 'C43', 'C44', 'C45', 'C46'."
+ )
+ }
+
+ # check if valid security token is provided
+ if (security_token == "") stop("Valid security token should be provided.")
+
+ # check if the requested period is not longer than one year
+ if (difftime(period_end, period_start, units = "day") > 365L) {
+ stop("One year range limit should be applied!")
+ }
+
+ # convert timestamps into accepted format
+ period_start <- url_posixct_format(period_start)
+ period_end <- url_posixct_format(period_end)
+
+ # compose GET request url
+ query_string <- paste0(
+ "documentType=B45",
+ "&processType=A47",
+ "&businessType=", business_type,
+ "&ControlArea_Domain=", eic,
+ "&periodStart=", period_start,
+ "&periodEnd=", period_end
+ )
+
+ # send GET request
+ en_cont_list <- api_req_safe(
+ query_string = query_string,
+ security_token = security_token
+ )
+
+ # return with the extracted the response
+ extract_response(content = en_cont_list, tidy_output = tidy_output)
+}
+
+
+
+#' @title
+#' Get Current Balancing State (GL EB 12.3.A)
+#'
+#' @description
+#' Current balancing state of the control area.
+#' 100 day range limit applies.
+#'
+#' @param eic Energy Identification Code of the area domain
+#' @param period_start POSIXct or YYYY-MM-DD HH:MM:SS format
+#' 100 day range limit applies
+#' @param period_end POSIXct or YYYY-MM-DD HH:MM:SS format
+#' 100 day range limit applies
+#' @param tidy_output Defaults to TRUE. flatten nested tables
+#' @param security_token Security token for ENTSO-E transparency platform
+#'
+#' @export
+#'
+#' @examples
+#' df <- entsoeapi::current_balancing_state(
+#' eic = "10YCZ-CEPS-----N",
+#' period_start = lubridate::ymd(x = "2024-01-01", tz = "CET"),
+#' period_end = lubridate::ymd(x = "2024-01-02", tz = "CET"),
+#' tidy_output = TRUE
+#' )
+#'
+#' str(df)
+#'
+current_balancing_state <- function(
+ eic = NULL,
+ period_start = lubridate::ymd(
+ Sys.Date() - lubridate::days(x = 7L),
+ tz = "CET"
+ ),
+ period_end = lubridate::ymd(
+ Sys.Date(),
+ tz = "CET"
+ ),
+ tidy_output = TRUE,
+ security_token = Sys.getenv("ENTSOE_PAT")
+) {
+ # check if only one eic provided
+ if (is.null(eic)) stop("One control area EIC should be provided.")
+ if (length(eic) > 1L) {
+ stop("This wrapper only supports one control area EIC per request.")
+ }
+
+ # check if valid security token is provided
+ if (security_token == "") stop("Valid security token should be provided.")
+
+ # check if the requested period is not longer than 100 days
+ if (difftime(period_end, period_start, units = "day") > 100L) {
+ stop("100 day range limit should be applied!")
+ }
+
+ # convert timestamps into accepted format
+ period_start <- url_posixct_format(period_start)
+ period_end <- url_posixct_format(period_end)
+
+ # compose GET request url
+ query_string <- paste0(
+ "documentType=A86",
+ "&businessType=B33",
+ "&Area_Domain=", eic,
+ "&periodStart=", period_start,
+ "&periodEnd=", period_end
+ )
+
+ # send GET request
+ en_cont_list <- api_req_safe(
+ query_string = query_string,
+ security_token = security_token
+ )
+
+ # return with the extracted the response
+ extract_response(content = en_cont_list, tidy_output = tidy_output)
+}
+
+
+
+#' @title
+#' Get Balancing Energy Bids (GL EB 12.3.B&C)
+#'
+#' @description
+#' Balancing energy bids submitted by BSPs.
+#' 100 documents limit applies; paging is handled transparently.
+#'
+#' @param eic Energy Identification Code of the connecting domain
+#' @param process_type Process type (currently only A47 is supported)
+#' @param period_start POSIXct or YYYY-MM-DD HH:MM:SS format
+#' @param period_end POSIXct or YYYY-MM-DD HH:MM:SS format
+#' @param tidy_output Defaults to TRUE. flatten nested tables
+#' @param security_token Security token for ENTSO-E transparency platform
+#'
+#' @export
+#'
+#' @examples
+#' df <- entsoeapi::balancing_energy_bids(
+#' eic = "10YCZ-CEPS-----N",
+#' process_type = "A47",
+#' period_start = lubridate::ymd(x = "2024-01-01", tz = "CET"),
+#' period_end = lubridate::ymd(x = "2024-01-02", tz = "CET"),
+#' tidy_output = TRUE
+#' )
+#'
+#' str(df)
+#'
+balancing_energy_bids <- function(
+ eic = NULL,
+ process_type = "A47",
+ period_start = lubridate::ymd(
+ Sys.Date() - lubridate::days(x = 7L),
+ tz = "CET"
+ ),
+ period_end = lubridate::ymd(
+ Sys.Date(),
+ tz = "CET"
+ ),
+ tidy_output = TRUE,
+ security_token = Sys.getenv("ENTSOE_PAT")
+) {
+ # check if only one eic provided
+ if (is.null(eic)) stop("One connecting domain EIC should be provided.")
+ if (length(eic) > 1L) {
+ stop("This wrapper only supports one connecting domain EIC per request.")
+ }
+
+ # check if valid security token is provided
+ if (security_token == "") stop("Valid security token should be provided.")
+
+ # convert timestamps into accepted format
+ period_start <- url_posixct_format(period_start)
+ period_end <- url_posixct_format(period_end)
+
+ # compose GET request url
+ query_string <- paste0(
+ "documentType=A37",
+ "&processType=", process_type,
+ "&businessType=B74",
+ "&Connecting_Domain=", eic,
+ "&periodStart=", period_start,
+ "&periodEnd=", period_end
+ )
+
+ # send GET request
+ en_cont_list <- api_req_safe(
+ query_string = query_string,
+ security_token = security_token
+ )
+
+ # return with the extracted the response
+ extract_response(content = en_cont_list, tidy_output = tidy_output)
+}
+
+
+
+#' @title
+#' Get Aggregated Balancing Energy Bids (GL EB 12.3.E)
+#'
+#' @description
+#' Aggregated balancing energy bids.
+#' One year range limit applies.
+#'
+#' @param eic Energy Identification Code of the area domain
+#' @param process_type type of frequency restoration reserve
+#' "A51" aFRR
+#' "A46" RR
+#' "A47" mFRR
+#' "A60" mFRR with scheduled activation
+#' "A61" mFRR with direct activation
+#' @param period_start POSIXct or YYYY-MM-DD HH:MM:SS format
+#' One year range limit applies
+#' @param period_end POSIXct or YYYY-MM-DD HH:MM:SS format
+#' One year range limit applies
+#' @param tidy_output Defaults to TRUE. flatten nested tables
+#' @param security_token Security token for ENTSO-E transparency platform
+#'
+#' @export
+#'
+#' @examples
+#' df <- entsoeapi::aggregated_balancing_energy_bids(
+#' eic = "10YCZ-CEPS-----N",
+#' process_type = "A51",
+#' period_start = lubridate::ymd(x = "2024-01-01", tz = "CET"),
+#' period_end = lubridate::ymd(x = "2024-01-02", tz = "CET"),
+#' tidy_output = TRUE
+#' )
+#'
+#' str(df)
+#'
+aggregated_balancing_energy_bids <- function(
+ eic = NULL,
+ process_type = NULL,
+ period_start = lubridate::ymd(
+ Sys.Date() - lubridate::days(x = 7L),
+ tz = "CET"
+ ),
+ period_end = lubridate::ymd(
+ Sys.Date(),
+ tz = "CET"
+ ),
+ tidy_output = TRUE,
+ security_token = Sys.getenv("ENTSOE_PAT")
+) {
+ # check if only one eic provided
+ if (is.null(eic)) stop("One control area EIC should be provided.")
+ if (length(eic) > 1L) {
+ stop("This wrapper only supports one control area EIC per request.")
+ }
+
+ # check if proper process_type provided
+ if (
+ is.null(process_type) ||
+ !process_type %in% c("A51", "A46", "A47", "A60", "A61")
+ ) {
+ stop("The 'process_type' should be 'A51', 'A46', 'A47', 'A60' or 'A61'.")
+ }
+
+ # check if valid security token is provided
+ if (security_token == "") stop("Valid security token should be provided.")
+
+ # check if the requested period is not longer than one year
+ if (difftime(period_end, period_start, units = "day") > 365L) {
+ stop("One year range limit should be applied!")
+ }
+
+ # convert timestamps into accepted format
+ period_start <- url_posixct_format(period_start)
+ period_end <- url_posixct_format(period_end)
+
+ # compose GET request url
+ query_string <- paste0(
+ "documentType=A24",
+ "&processType=", process_type,
+ "&area_Domain=", eic,
+ "&periodStart=", period_start,
+ "&periodEnd=", period_end
+ )
+
+ # send GET request
+ en_cont_list <- api_req_safe(
+ query_string = query_string,
+ security_token = security_token
+ )
+
+ # return with the extracted the response
+ extract_response(content = en_cont_list, tidy_output = tidy_output)
+}
+
+
+
+#' @title
+#' Get Procured Balancing Capacity (GL EB 12.3.F)
+#'
+#' @description
+#' Procured balancing capacity by TSOs.
+#' 100 documents limit applies; paging is handled transparently.
+#'
+#' @param eic Energy Identification Code of the area domain
+#' @param process_type type of frequency restoration reserve
+#' "A51" aFRR
+#' "A52" FCR
+#' "A47" mFRR
+#' @param type_market_agreement Optional market agreement type code
+#' @param period_start POSIXct or YYYY-MM-DD HH:MM:SS format
+#' @param period_end POSIXct or YYYY-MM-DD HH:MM:SS format
+#' @param tidy_output Defaults to TRUE. flatten nested tables
+#' @param security_token Security token for ENTSO-E transparency platform
+#'
+#' @export
+#'
+#' @examples
+#' df <- entsoeapi::procured_balancing_capacity(
+#' eic = "10YCZ-CEPS-----N",
+#' process_type = "A51",
+#' period_start = lubridate::ymd(x = "2024-01-01", tz = "CET"),
+#' period_end = lubridate::ymd(x = "2024-01-02", tz = "CET"),
+#' tidy_output = TRUE
+#' )
+#'
+#' str(df)
+#'
+procured_balancing_capacity <- function(
+ eic = NULL,
+ process_type = NULL,
+ type_market_agreement = NULL,
+ period_start = lubridate::ymd(
+ Sys.Date() - lubridate::days(x = 7L),
+ tz = "CET"
+ ),
+ period_end = lubridate::ymd(
+ Sys.Date(),
+ tz = "CET"
+ ),
+ tidy_output = TRUE,
+ security_token = Sys.getenv("ENTSOE_PAT")
+) {
+ # check if only one eic provided
+ if (is.null(eic)) stop("One control area EIC should be provided.")
+ if (length(eic) > 1L) {
+ stop("This wrapper only supports one control area EIC per request.")
+ }
+
+ # check if proper process_type provided
+ if (is.null(process_type) || !process_type %in% c("A51", "A52", "A47")) {
+ stop("The 'process_type' should be 'A51', 'A52' or 'A47'.")
+ }
+
+ # check if none or only one type_market_agreement provided
+ if (!is.null(type_market_agreement) && length(type_market_agreement) > 1L) {
+ stop("None or one 'type_market_agreement' should be provided.")
+ }
+
+ # check if valid security token is provided
+ if (security_token == "") stop("Valid security token should be provided.")
+
+ # convert timestamps into accepted format
+ period_start <- url_posixct_format(period_start)
+ period_end <- url_posixct_format(period_end)
+
+ # compose GET request url
+ query_string <- paste0(
+ "documentType=A15",
+ "&processType=", process_type,
+ "&area_Domain=", eic,
+ "&periodStart=", period_start,
+ "&periodEnd=", period_end
+ )
+
+ # if type_market_agreement is provided, add it to the query string
+ if (!is.null(type_market_agreement)) {
+ query_string <- paste0(
+ query_string,
+ "&type_MarketAgreement.Type=", type_market_agreement
+ )
+ }
+
+ # send GET request
+ en_cont_list <- api_req_safe(
+ query_string = query_string,
+ security_token = security_token
+ )
+
+ # return with the extracted the response
+ extract_response(content = en_cont_list, tidy_output = tidy_output)
+}
+
+
+
+#' @title
+#' Get Allocation of Cross-Zonal Balancing Capacity (GL EB 12.3.H&I)
+#'
+#' @description
+#' Use of allocated cross-zonal balancing capacity between
+#' an acquiring and a connecting domain.
+#'
+#' @param eic_acquiring Energy Identification Code of the acquiring domain
+#' @param eic_connecting Energy Identification Code of the connecting domain
+#' @param type_market_agreement Optional market agreement type code
+#' @param period_start POSIXct or YYYY-MM-DD HH:MM:SS format
+#' @param period_end POSIXct or YYYY-MM-DD HH:MM:SS format
+#' @param tidy_output Defaults to TRUE. flatten nested tables
+#' @param security_token Security token for ENTSO-E transparency platform
+#'
+#' @export
+#'
+#' @examples
+#' df <- entsoeapi::allocation_of_cross_zonal_balancing_cap(
+#' eic_acquiring = "10YAT-APG------L",
+#' eic_connecting = "10YCH-SWISSGRIDZ",
+#' period_start = lubridate::ymd(x = "2024-01-01", tz = "CET"),
+#' period_end = lubridate::ymd(x = "2024-01-02", tz = "CET"),
+#' tidy_output = TRUE
+#' )
+#'
+#' str(df)
+#'
+allocation_of_cross_zonal_balancing_cap <- function(
+ eic_acquiring = NULL,
+ eic_connecting = NULL,
+ type_market_agreement = NULL,
+ period_start = lubridate::ymd(
+ Sys.Date() - lubridate::days(x = 7L),
+ tz = "CET"
+ ),
+ period_end = lubridate::ymd(
+ Sys.Date(),
+ tz = "CET"
+ ),
+ tidy_output = TRUE,
+ security_token = Sys.getenv("ENTSOE_PAT")
+) {
+ # check if only one eic provided
+ if (is.null(eic_acquiring)) {
+ stop("One acquiring domain EIC should be provided.")
+ }
+ if (is.null(eic_connecting)) {
+ stop("One connecting domain EIC should be provided.")
+ }
+ if (length(eic_acquiring) > 1L || length(eic_connecting) > 1L) {
+ stop(
+ "This wrapper only supports one acquiring and one connecting EIC ",
+ "per request."
+ )
+ }
+
+ # check if none or only one type_market_agreement provided
+ if (!is.null(type_market_agreement) && length(type_market_agreement) > 1L) {
+ stop("None or one 'type_market_agreement' should be provided.")
+ }
+
+ # check if valid security token is provided
+ if (security_token == "") stop("Valid security token should be provided.")
+
+ # convert timestamps into accepted format
+ period_start <- url_posixct_format(period_start)
+ period_end <- url_posixct_format(period_end)
+
+ # compose GET request url
+ query_string <- paste0(
+ "documentType=A38",
+ "&processType=A46",
+ "&Acquiring_Domain=", eic_acquiring,
+ "&Connecting_Domain=", eic_connecting,
+ "&periodStart=", period_start,
+ "&periodEnd=", period_end
+ )
+
+ # if type_market_agreement is provided, add it to the query string
+ if (!is.null(type_market_agreement)) {
+ query_string <- paste0(
+ query_string,
+ "&type_MarketAgreement.Type=", type_market_agreement
+ )
+ }
+
+ # send GET request
+ en_cont_list <- api_req_safe(
+ query_string = query_string,
+ security_token = security_token
+ )
+
+ # return with the extracted the response
+ extract_response(content = en_cont_list, tidy_output = tidy_output)
+}
+
+
+
+#' @title
+#' Get Contracted Reserves (17.1.B&C)
+#'
+#' @description
+#' Volumes and prices of contracted reserves.
+#' 100 documents limit applies; paging is handled transparently.
+#'
+#' @param eic Energy Identification Code of the control area domain
+#' @param type_market_agreement Market agreement type code (mandatory)
+#' "A01" Daily
+#' "A02" Weekly
+#' "A03" Monthly
+#' "A04" Yearly
+#' "A06" Long term
+#' "A13" Hourly
+#' @param process_type Optional process type code
+#' "A46" Replacement reserve
+#' "A47" Manual frequency restoration reserve
+#' "A51" Automatic frequency restoration reserve
+#' "A52" Frequency containment reserve
+#' @param psr_type Optional PSR type code
+#' "A03" Mixed
+#' "A04" Generation
+#' "A05" Load
+#' @param period_start POSIXct or YYYY-MM-DD HH:MM:SS format
+#' @param period_end POSIXct or YYYY-MM-DD HH:MM:SS format
+#' @param tidy_output Defaults to TRUE. flatten nested tables
+#' @param security_token Security token for ENTSO-E transparency platform
+#'
+#' @export
+#'
+#' @examples
+#' df <- entsoeapi::contracted_reserves(
+#' eic = "10YCZ-CEPS-----N",
+#' type_market_agreement = "A13",
+#' period_start = lubridate::ymd(x = "2022-01-01", tz = "CET"),
+#' period_end = lubridate::ymd(x = "2022-01-02", tz = "CET"),
+#' tidy_output = TRUE
+#' )
+#'
+#' str(df)
+#'
+contracted_reserves <- function(
+ eic = NULL,
+ type_market_agreement = NULL,
+ process_type = NULL,
+ psr_type = NULL,
+ period_start = lubridate::ymd(
+ Sys.Date() - lubridate::days(x = 7L),
+ tz = "CET"
+ ),
+ period_end = lubridate::ymd(
+ Sys.Date(),
+ tz = "CET"
+ ),
+ tidy_output = TRUE,
+ security_token = Sys.getenv("ENTSOE_PAT")
+) {
+ # check if only one eic provided
+ if (is.null(eic)) stop("One control area EIC should be provided.")
+ if (length(eic) > 1L) {
+ stop("This wrapper only supports one control area EIC per request.")
+ }
+
+ # check if type_market_agreement is provided
+ if (is.null(type_market_agreement)) {
+ stop("A 'type_market_agreement' value should be provided.")
+ }
+ if (length(type_market_agreement) > 1L) {
+ stop("Only one 'type_market_agreement' value should be provided.")
+ }
+
+ # check if valid security token is provided
+ if (security_token == "") stop("Valid security token should be provided.")
+
+ # convert timestamps into accepted format
+ period_start <- url_posixct_format(period_start)
+ period_end <- url_posixct_format(period_end)
+
+ # compose GET request url
+ query_string <- paste0(
+ "documentType=A81",
+ "&businessType=B95",
+ "&type_MarketAgreement.Type=", type_market_agreement,
+ "&controlArea_Domain=", eic,
+ "&periodStart=", period_start,
+ "&periodEnd=", period_end
+ )
+
+ # add optional parameters if provided
+ if (!is.null(process_type)) {
+ query_string <- paste0(query_string, "&processType=", process_type)
+ }
+ if (!is.null(psr_type)) {
+ query_string <- paste0(query_string, "&psrType=", psr_type)
+ }
+
+ # send GET request
+ en_cont_list <- api_req_safe(
+ query_string = query_string,
+ security_token = security_token
+ )
+
+ # return with the extracted the response
+ extract_response(content = en_cont_list, tidy_output = tidy_output)
+}
+
+
+
+#' @title
+#' Get Activated Balancing Prices (TR 17.1.F, IF aFRR 3.16)
+#'
+#' @description
+#' Prices of activated balancing energy and aFRR cross-border marginal prices.
+#' One year range limit applies.
+#'
+#' @param eic Energy Identification Code of the control area domain
+#' @param process_type Process type code, defaults to "A16"
+#' @param business_type Optional business type code
+#' @param period_start POSIXct or YYYY-MM-DD HH:MM:SS format
+#' One year range limit applies
+#' @param period_end POSIXct or YYYY-MM-DD HH:MM:SS format
+#' One year range limit applies
+#' @param tidy_output Defaults to TRUE. flatten nested tables
+#' @param security_token Security token for ENTSO-E transparency platform
+#'
+#' @export
+#'
+#' @examples
+#' df <- entsoeapi::activated_balancing_prices(
+#' eic = "10YCZ-CEPS-----N",
+#' period_start = lubridate::ymd(x = "2024-01-01", tz = "CET"),
+#' period_end = lubridate::ymd(x = "2024-01-02", tz = "CET"),
+#' tidy_output = TRUE
+#' )
+#'
+#' str(df)
+#'
+activated_balancing_prices <- function(
+ eic = NULL,
+ process_type = "A16",
+ business_type = NULL,
+ period_start = lubridate::ymd(
+ Sys.Date() - lubridate::days(x = 7L),
+ tz = "CET"
+ ),
+ period_end = lubridate::ymd(
+ Sys.Date(),
+ tz = "CET"
+ ),
+ tidy_output = TRUE,
+ security_token = Sys.getenv("ENTSOE_PAT")
+) {
+ # check if only one eic provided
+ if (is.null(eic)) stop("One control area EIC should be provided.")
+ if (length(eic) > 1L) {
+ stop("This wrapper only supports one control area EIC per request.")
+ }
+
+ # check if valid security token is provided
+ if (security_token == "") stop("Valid security token should be provided.")
+
+ # check if the requested period is not longer than one year
+ if (difftime(period_end, period_start, units = "day") > 365L) {
+ stop("One year range limit should be applied!")
+ }
+
+ # convert timestamps into accepted format
+ period_start <- url_posixct_format(period_start)
+ period_end <- url_posixct_format(period_end)
+
+ # compose GET request url
+ query_string <- paste0(
+ "documentType=A84",
+ "&processType=", process_type,
+ "&controlArea_Domain=", eic,
+ "&periodStart=", period_start,
+ "&periodEnd=", period_end
+ )
+
+ # add optional business_type if provided
+ if (!is.null(business_type)) {
+ query_string <- paste0(query_string, "&businessType=", business_type)
+ }
+
+ # send GET request
+ en_cont_list <- api_req_safe(
+ query_string = query_string,
+ security_token = security_token
+ )
+
+ # return with the extracted the response
+ extract_response(content = en_cont_list, tidy_output = tidy_output)
+}
+
+
+
+#' @title
+#' Get Imbalance Prices (17.1.G)
+#'
+#' @description
+#' Imbalance prices of the control area.
+#' One year range limit applies.
+#'
+#' @param eic Energy Identification Code of the control area domain
+#' @param period_start POSIXct or YYYY-MM-DD HH:MM:SS format
+#' One year range limit applies
+#' @param period_end POSIXct or YYYY-MM-DD HH:MM:SS format
+#' One year range limit applies
+#' @param tidy_output Defaults to TRUE. flatten nested tables
+#' @param security_token Security token for ENTSO-E transparency platform
+#'
+#' @export
+#'
+#' @examples
+#' df <- entsoeapi::imbalance_prices(
+#' eic = "10YCZ-CEPS-----N",
+#' period_start = lubridate::ymd(x = "2024-01-01", tz = "CET"),
+#' period_end = lubridate::ymd(x = "2024-01-02", tz = "CET"),
+#' tidy_output = TRUE
+#' )
+#'
+#' str(df)
+#'
+imbalance_prices <- function(
+ eic = NULL,
+ period_start = lubridate::ymd(
+ Sys.Date() - lubridate::days(x = 7L),
+ tz = "CET"
+ ),
+ period_end = lubridate::ymd(
+ Sys.Date(),
+ tz = "CET"
+ ),
+ tidy_output = TRUE,
+ security_token = Sys.getenv("ENTSOE_PAT")
+) {
+ # check if only one eic provided
+ if (is.null(eic)) stop("One control area EIC should be provided.")
+ if (length(eic) > 1L) {
+ stop("This wrapper only supports one control area EIC per request.")
+ }
+
+ # check if valid security token is provided
+ if (security_token == "") stop("Valid security token should be provided.")
+
+ # check if the requested period is not longer than one year
+ if (difftime(period_end, period_start, units = "day") > 365L) {
+ stop("One year range limit should be applied!")
+ }
+
+ # convert timestamps into accepted format
+ period_start <- url_posixct_format(period_start)
+ period_end <- url_posixct_format(period_end)
+
+ # compose GET request url
+ query_string <- paste0(
+ "documentType=A85",
+ "&controlArea_Domain=", eic,
+ "&periodStart=", period_start,
+ "&periodEnd=", period_end
+ )
+
+ # send GET request
+ en_cont_list <- api_req_safe(
+ query_string = query_string,
+ security_token = security_token
+ )
+
+ # return with the extracted the response
+ extract_response(content = en_cont_list, tidy_output = tidy_output)
+}
+
+
+
+#' @title
+#' Get Imbalance Volumes (17.1.H)
+#'
+#' @description
+#' Total imbalance volumes of the control area.
+#' One year range limit applies.
+#'
+#' @param eic Energy Identification Code of the control area domain
+#' @param period_start POSIXct or YYYY-MM-DD HH:MM:SS format
+#' One year range limit applies
+#' @param period_end POSIXct or YYYY-MM-DD HH:MM:SS format
+#' One year range limit applies
+#' @param tidy_output Defaults to TRUE. flatten nested tables
+#' @param security_token Security token for ENTSO-E transparency platform
+#'
+#' @export
+#'
+#' @examples
+#' df <- entsoeapi::imbalance_volumes(
+#' eic = "10YCZ-CEPS-----N",
+#' period_start = lubridate::ymd(x = "2024-01-01", tz = "CET"),
+#' period_end = lubridate::ymd(x = "2024-01-02", tz = "CET"),
+#' tidy_output = TRUE
+#' )
+#'
+#' str(df)
+#'
+imbalance_volumes <- function(
+ eic = NULL,
+ period_start = lubridate::ymd(
+ Sys.Date() - lubridate::days(x = 7L),
+ tz = "CET"
+ ),
+ period_end = lubridate::ymd(
+ Sys.Date(),
+ tz = "CET"
+ ),
+ tidy_output = TRUE,
+ security_token = Sys.getenv("ENTSOE_PAT")
+) {
+ # check if only one eic provided
+ if (is.null(eic)) stop("One control area EIC should be provided.")
+ if (length(eic) > 1L) {
+ stop("This wrapper only supports one control area EIC per request.")
+ }
+
+ # check if valid security token is provided
+ if (security_token == "") stop("Valid security token should be provided.")
+
+ # check if the requested period is not longer than one year
+ if (difftime(period_end, period_start, units = "day") > 365L) {
+ stop("One year range limit should be applied!")
+ }
+
+ # convert timestamps into accepted format
+ period_start <- url_posixct_format(period_start)
+ period_end <- url_posixct_format(period_end)
+
+ # compose GET request url
+ query_string <- paste0(
+ "documentType=A86",
+ "&controlArea_Domain=", eic,
+ "&periodStart=", period_start,
+ "&periodEnd=", period_end
+ )
+
+ # send GET request
+ en_cont_list <- api_req_safe(
+ query_string = query_string,
+ security_token = security_token
+ )
+
+ # return with the extracted the response
+ extract_response(content = en_cont_list, tidy_output = tidy_output)
+}
+
+
+
+#' @title
+#' Get Financial Expenses and Income for Balancing (17.1.I)
+#'
+#' @description
+#' Financial expenses and income for balancing of the control area.
+#' One year range limit applies.
+#'
+#' @param eic Energy Identification Code of the control area domain
+#' @param period_start POSIXct or YYYY-MM-DD HH:MM:SS format
+#' One year range limit applies
+#' @param period_end POSIXct or YYYY-MM-DD HH:MM:SS format
+#' One year range limit applies
+#' @param tidy_output Defaults to TRUE. flatten nested tables
+#' @param security_token Security token for ENTSO-E transparency platform
+#'
+#' @export
+#'
+#' @examples
+#' df <- entsoeapi::financial_expenses_and_income_for_balancing(
+#' eic = "10YCZ-CEPS-----N",
+#' period_start = lubridate::ymd(x = "2022-01-01", tz = "CET"),
+#' period_end = lubridate::ymd(x = "2022-01-02", tz = "CET"),
+#' tidy_output = TRUE
+#' )
+#'
+#' str(df)
+#'
+financial_expenses_and_income_for_balancing <- function(
+ eic = NULL,
+ period_start = lubridate::ymd(
+ Sys.Date() - lubridate::days(x = 7L),
+ tz = "CET"
+ ),
+ period_end = lubridate::ymd(
+ Sys.Date(),
+ tz = "CET"
+ ),
+ tidy_output = TRUE,
+ security_token = Sys.getenv("ENTSOE_PAT")
+) {
+ # check if only one eic provided
+ if (is.null(eic)) stop("One control area EIC should be provided.")
+ if (length(eic) > 1L) {
+ stop("This wrapper only supports one control area EIC per request.")
+ }
+
+ # check if valid security token is provided
+ if (security_token == "") stop("Valid security token should be provided.")
+
+ # check if the requested period is not longer than one year
+ if (difftime(period_end, period_start, units = "day") > 365L) {
+ stop("One year range limit should be applied!")
+ }
+
+ # convert timestamps into accepted format
+ period_start <- url_posixct_format(period_start)
+ period_end <- url_posixct_format(period_end)
+
+ # compose GET request url
+ query_string <- paste0(
+ "documentType=A87",
+ "&controlArea_Domain=", eic,
+ "&periodStart=", period_start,
+ "&periodEnd=", period_end
+ )
+
+ # send GET request
+ en_cont_list <- api_req_safe(
+ query_string = query_string,
+ security_token = security_token
+ )
+
+ # return with the extracted the response
+ extract_response(content = en_cont_list, tidy_output = tidy_output)
+}
+
+
+
+#' @title
+#' Get FCR Total Capacity (SO GL 187.2)
+#'
+#' @description
+#' Total Frequency Containment Reserve capacity.
+#' One year range limit applies.
+#'
+#' @param eic Energy Identification Code of the area domain
+#' @param period_start POSIXct or YYYY-MM-DD HH:MM:SS format
+#' One year range limit applies
+#' @param period_end POSIXct or YYYY-MM-DD HH:MM:SS format
+#' One year range limit applies
+#' @param tidy_output Defaults to TRUE. flatten nested tables
+#' @param security_token Security token for ENTSO-E transparency platform
+#'
+#' @export
+#'
+#' @examples
+#' df <- entsoeapi::fcr_total_capacity(
+#' eic = "10YEU-CONT-SYNC0",
+#' period_start = lubridate::ymd(x = "2022-01-01", tz = "CET"),
+#' period_end = lubridate::ymd(x = "2022-01-02", tz = "CET"),
+#' tidy_output = TRUE
+#' )
+#'
+#' str(df)
+#'
+fcr_total_capacity <- function(
+ eic = NULL,
+ period_start = lubridate::ymd(
+ Sys.Date() - lubridate::days(x = 7L),
+ tz = "CET"
+ ),
+ period_end = lubridate::ymd(
+ Sys.Date(),
+ tz = "CET"
+ ),
+ tidy_output = TRUE,
+ security_token = Sys.getenv("ENTSOE_PAT")
+) {
+ # check if only one eic provided
+ if (is.null(eic)) stop("One area EIC should be provided.")
+ if (length(eic) > 1L) {
+ stop("This wrapper only supports one area EIC per request.")
+ }
+
+ # check if valid security token is provided
+ if (security_token == "") stop("Valid security token should be provided.")
+
+ # check if the requested period is not longer than one year
+ if (difftime(period_end, period_start, units = "day") > 365L) {
+ stop("One year range limit should be applied!")
+ }
+
+ # convert timestamps into accepted format
+ period_start <- url_posixct_format(period_start)
+ period_end <- url_posixct_format(period_end)
+
+ # compose GET request url
+ query_string <- paste0(
+ "documentType=A26",
+ "&businessType=A25",
+ "&area_Domain=", eic,
+ "&periodStart=", period_start,
+ "&periodEnd=", period_end
+ )
+
+ # send GET request
+ en_cont_list <- api_req_safe(
+ query_string = query_string,
+ security_token = security_token
+ )
+
+ # return with the extracted the response
+ extract_response(content = en_cont_list, tidy_output = tidy_output)
+}
+
+
+
+#' @title
+#' Get Shares of FCR Capacity (SO GL 187.2)
+#'
+#' @description
+#' Shares of Frequency Containment Reserve capacity per area.
+#' One year range limit applies.
+#'
+#' @param eic Energy Identification Code of the area domain
+#' @param business_type type of FCR capacity share
+#' "C23" share of FCR capacity
+#' "B95" contracted FCR capacity
+#' @param period_start POSIXct or YYYY-MM-DD HH:MM:SS format
+#' One year range limit applies
+#' @param period_end POSIXct or YYYY-MM-DD HH:MM:SS format
+#' One year range limit applies
+#' @param tidy_output Defaults to TRUE. flatten nested tables
+#' @param security_token Security token for ENTSO-E transparency platform
+#'
+#' @export
+#'
+#' @examples
+#' df <- entsoeapi::shares_of_fcr_capacity(
+#' eic = "10YDE-VE-------2",
+#' business_type = "C23",
+#' period_start = lubridate::ymd(x = "2022-01-01", tz = "CET"),
+#' period_end = lubridate::ymd(x = "2022-01-02", tz = "CET"),
+#' tidy_output = TRUE
+#' )
+#'
+#' str(df)
+#'
+shares_of_fcr_capacity <- function(
+ eic = NULL,
+ business_type = NULL,
+ period_start = lubridate::ymd(
+ Sys.Date() - lubridate::days(x = 7L),
+ tz = "CET"
+ ),
+ period_end = lubridate::ymd(
+ Sys.Date(),
+ tz = "CET"
+ ),
+ tidy_output = TRUE,
+ security_token = Sys.getenv("ENTSOE_PAT")
+) {
+ # check if only one eic provided
+ if (is.null(eic)) stop("One area EIC should be provided.")
+ if (length(eic) > 1L) {
+ stop("This wrapper only supports one area EIC per request.")
+ }
+
+ # check if proper business_type provided
+ if (is.null(business_type) || !business_type %in% c("C23", "B95")) {
+ stop("The 'business_type' should be 'C23' or 'B95'.")
+ }
+
+ # check if valid security token is provided
+ if (security_token == "") stop("Valid security token should be provided.")
+
+ # check if the requested period is not longer than one year
+ if (difftime(period_end, period_start, units = "day") > 365L) {
+ stop("One year range limit should be applied!")
+ }
+
+ # convert timestamps into accepted format
+ period_start <- url_posixct_format(period_start)
+ period_end <- url_posixct_format(period_end)
+
+ # compose GET request url
+ query_string <- paste0(
+ "documentType=A26",
+ "&businessType=", business_type,
+ "&area_Domain=", eic,
+ "&periodStart=", period_start,
+ "&periodEnd=", period_end
+ )
+
+ # send GET request
+ en_cont_list <- api_req_safe(
+ query_string = query_string,
+ security_token = security_token
+ )
+
+ # return with the extracted the response
+ extract_response(content = en_cont_list, tidy_output = tidy_output)
+}
+
+
+
+#' @title
+#' Get RR and FRR Actual Capacity (SO GL 188.4 & 189.3)
+#'
+#' @description
+#' Actual capacity of Frequency Restoration Reserve (FRR) or
+#' Replacement Reserve (RR).
+#'
+#' @param eic Energy Identification Code of the area domain
+#' @param process_type type of reserve
+#' "A56" FRR
+#' "A46" RR
+#' @param business_type type of aggregation
+#' "C77" minimum
+#' "C78" average
+#' "C79" max
+#' defaults to "C78"
+#' @param period_start POSIXct or YYYY-MM-DD HH:MM:SS format
+#' @param period_end POSIXct or YYYY-MM-DD HH:MM:SS format
+#' @param tidy_output Defaults to TRUE. flatten nested tables
+#' @param security_token Security token for ENTSO-E transparency platform
+#'
+#' @export
+#'
+#' @examples
+#' df <- entsoeapi::rr_and_frr_actual_capacity(
+#' eic = "10YAT-APG------L",
+#' process_type = "A56",
+#' period_start = lubridate::ymd(x = "2022-01-01", tz = "CET"),
+#' period_end = lubridate::ymd(x = "2022-04-01", tz = "CET"),
+#' tidy_output = TRUE
+#' )
+#'
+#' str(df)
+#'
+rr_and_frr_actual_capacity <- function(
+ eic = NULL,
+ process_type = NULL,
+ business_type = "C78",
+ period_start = lubridate::ymd(
+ Sys.Date() - lubridate::days(x = 7L),
+ tz = "CET"
+ ),
+ period_end = lubridate::ymd(
+ Sys.Date(),
+ tz = "CET"
+ ),
+ tidy_output = TRUE,
+ security_token = Sys.getenv("ENTSOE_PAT")
+) {
+ # check if only one eic provided
+ if (is.null(eic)) stop("One area EIC should be provided.")
+ if (length(eic) > 1L) {
+ stop("This wrapper only supports one area EIC per request.")
+ }
+
+ # check if proper process_type provided
+ if (is.null(process_type) || !process_type %in% c("A56", "A46")) {
+ stop("The 'process_type' should be 'A56' (FRR) or 'A46' (RR).")
+ }
+
+ # check if proper process_type provided
+ if (is.null(business_type) || !business_type %in% c("C77", "C78", "C79")) {
+ stop("The 'business_type' should be 'C77', 'C78' or 'C79'.")
+ }
+
+ # check if valid security token is provided
+ if (security_token == "") stop("Valid security token should be provided.")
+
+ # convert timestamps into accepted format
+ period_start <- url_posixct_format(period_start)
+ period_end <- url_posixct_format(period_end)
+
+ # compose GET request url
+ query_string <- paste0(
+ "documentType=A26",
+ "&processType=", process_type,
+ "&businessType=", business_type,
+ "&Area_Domain=", eic,
+ "&periodStart=", period_start,
+ "&periodEnd=", period_end
+ )
+
+ # send GET request
+ en_cont_list <- api_req_safe(
+ query_string = query_string,
+ security_token = security_token
+ )
+
+ # return with the extracted the response
+ extract_response(content = en_cont_list, tidy_output = tidy_output)
+}
+
+
+
+#' @title
+#' Get RR Actual Capacity (SO GL 189.3)
+#'
+#' @description
+#' Actual capacity of Replacement Reserve (RR).
+#' Process type is hardcoded to A46 (Replacement Reserve).
+#'
+#' @param eic Energy Identification Code of the area domain
+#' @param period_start POSIXct or YYYY-MM-DD HH:MM:SS format
+#' @param period_end POSIXct or YYYY-MM-DD HH:MM:SS format
+#' @param tidy_output Defaults to TRUE. flatten nested tables
+#' @param security_token Security token for ENTSO-E transparency platform
+#'
+#' @export
+#'
+#' @examples
+#' df <- entsoeapi::rr_actual_capacity(
+#' eic = "10YAT-APG------L",
+#' period_start = lubridate::ymd(x = "2022-01-01", tz = "CET"),
+#' period_end = lubridate::ymd(x = "2022-04-01", tz = "CET"),
+#' tidy_output = TRUE
+#' )
+#'
+#' str(df)
+#'
+rr_actual_capacity <- function(
+ eic = NULL,
+ period_start = lubridate::ymd(
+ Sys.Date() - lubridate::days(x = 7L),
+ tz = "CET"
+ ),
+ period_end = lubridate::ymd(
+ Sys.Date(),
+ tz = "CET"
+ ),
+ tidy_output = TRUE,
+ security_token = Sys.getenv("ENTSOE_PAT")
+) {
+ # check if only one eic provided
+ if (is.null(eic)) stop("One area EIC should be provided.")
+ if (length(eic) > 1L) {
+ stop("This wrapper only supports one area EIC per request.")
+ }
+
+ # check if valid security token is provided
+ if (security_token == "") stop("Valid security token should be provided.")
+
+ # convert timestamps into accepted format
+ period_start <- url_posixct_format(period_start)
+ period_end <- url_posixct_format(period_end)
+
+ # compose GET request url (processType=A46 hardcoded for RR)
+ query_string <- paste0(
+ "documentType=A26",
+ "&processType=A46",
+ "&businessType=C77",
+ "&area_Domain=", eic,
+ "&periodStart=", period_start,
+ "&periodEnd=", period_end
+ )
+
+ # send GET request
+ en_cont_list <- api_req_safe(
+ query_string = query_string,
+ security_token = security_token
+ )
+
+ # return with the extracted the response
+ extract_response(content = en_cont_list, tidy_output = tidy_output)
+}
+
+
+
+#' #' @title
+#' #' Get Sharing of FRR Capacity (SO GL 190.1)
+#' #'
+#' #' @description
+#' #' Sharing of Frequency Restoration Reserve capacity between areas.
+#' #' One year range limit applies.
+#' #'
+#' #' @param eic_acquiring Energy Identification Code of the acquiring domain
+#' #' @param eic_connecting Energy Identification Code of the connecting domain
+#' #' @param process_type type of reserve
+#' #' "A56" FRR
+#' #' "A46" RR
+#' #' @param period_start POSIXct or YYYY-MM-DD HH:MM:SS format
+#' #' One year range limit applies
+#' #' @param period_end POSIXct or YYYY-MM-DD HH:MM:SS format
+#' #' One year range limit applies
+#' #' @param tidy_output Defaults to TRUE. flatten nested tables
+#' #' @param security_token Security token for ENTSO-E transparency platform
+#' #'
+#' #' export
+#' #'
+#' #' @examples
+#' #' df <- entsoeapi::sharing_of_frr_capacity(
+#' #' eic_acquiring = "10YCB-GERMANY--8",
+#' #' eic_connecting = "10YAT-APG------L",
+#' #' process_type = "A56",
+#' #' period_start = lubridate::ymd(x = "2022-01-01", tz = "CET"),
+#' #' period_end = lubridate::ymd(x = "2022-01-02", tz = "CET"),
+#' #' tidy_output = TRUE
+#' #' )
+#' #'
+#' #' str(df)
+#' #'
+#' sharing_of_frr_capacity <- function(
+#' eic_acquiring = NULL,
+#' eic_connecting = NULL,
+#' process_type = NULL,
+#' period_start = lubridate::ymd(
+#' Sys.Date() - lubridate::days(x = 7L),
+#' tz = "CET"
+#' ),
+#' period_end = lubridate::ymd(
+#' Sys.Date(),
+#' tz = "CET"
+#' ),
+#' tidy_output = TRUE,
+#' security_token = Sys.getenv("ENTSOE_PAT")
+#' ) {
+#' # check if only one eic provided
+#' if (is.null(eic_acquiring)) {
+#' stop("One acquiring domain EIC should be provided.")
+#' }
+#' if (is.null(eic_connecting)) {
+#' stop("One connecting domain EIC should be provided.")
+#' }
+#' if (length(eic_acquiring) > 1L || length(eic_connecting) > 1L) {
+#' stop(
+#' "This wrapper only supports one acquiring and one connecting EIC ",
+#' "per request."
+#' )
+#' }
+#'
+#' # check if proper process_type provided
+#' if (is.null(process_type) || !process_type %in% c("A56", "A46")) {
+#' stop("The 'process_type' should be 'A56' (FRR) or 'A46' (RR).")
+#' }
+#'
+#' # check if valid security token is provided
+#' if (security_token == "") stop("Valid security token should be provided.")
+#'
+#' # check if the requested period is not longer than one year
+#' if (difftime(period_end, period_start, units = "day") > 365L) {
+#' stop("One year range limit should be applied!")
+#' }
+#'
+#' # convert timestamps into accepted format
+#' period_start <- url_posixct_format(period_start)
+#' period_end <- url_posixct_format(period_end)
+#'
+#' # compose GET request url
+#' query_string <- paste0(
+#' "documentType=A26",
+#' "&BusinessType=C22",
+#' "&processType=", process_type,
+#' "&Acquiring_Domain=", eic_acquiring,
+#' "&Connecting_Domain=", eic_connecting,
+#' "&periodStart=", period_start,
+#' "&periodEnd=", period_end
+#' )
+#'
+#' # send GET request
+#' en_cont_list <- api_req_safe(
+#' query_string = query_string,
+#' security_token = security_token
+#' )
+#'
+#' # return with the extracted the response
+#' extract_response(content = en_cont_list, tidy_output = tidy_output)
+#' }
diff --git a/R/en_market.R b/R/en_market.R
index 09886ce8..19b13b3c 100644
--- a/R/en_market.R
+++ b/R/en_market.R
@@ -1056,8 +1056,8 @@ allocated_transfer_capacities_3rd_countries <- function(
# check if the optional position value is a positive integer
if ((!is.numeric(position) ||
- position != as.integer(position) ||
- position < 1L)) {
+ position != as.integer(position) ||
+ position < 1L)) {
stop("The 'position' parameter should be a positive integer.")
}
diff --git a/R/utils.R b/R/utils.R
index eb6ffb6a..6918e936 100644
--- a/R/utils.R
+++ b/R/utils.R
@@ -604,7 +604,7 @@ read_zipped_xml <- function(temp_file_path) {
en_cont_list <- unzipped_files$result |>
purrr::map(~{
xml_content <- xml2::read_xml(.x)
- message(.x, " has read in")
+ message(.x, " has been read in")
return(xml_content)
})
@@ -712,7 +712,7 @@ api_req <- function(
# retrieve content-type from response headers
if (is.null(error_obj$resp)) stop(error_obj$parent$message, call. = FALSE)
rhct <- httr2::resp_content_type(resp = error_obj$resp)
- expt_html <- c("text/html;charset=UTF-8")
+ expt_html <- c("text/html")
expt_xml <- c("text/xml", "application/xml")
expt_json <- c("text/xml", "application/json")
@@ -737,7 +737,8 @@ api_req <- function(
xmlconvert::xml_to_list() |>
purrr::pluck("Reason")
- if (!all(names(response_reason) == c("code", "text"))) {
+ if (!is.list(response_reason) ||
+ !identical(names(response_reason), c("code", "text"))) {
stop(
sprintf("%s: %s",
httr2::resp_status(error_obj$resp),
@@ -838,7 +839,7 @@ url_posixct_format <- function(x) {
} else if (inherits(x = x, what = "POSIXct")) {
y <- strftime(x = x, format = "%Y%m%d%H%M", tz = "UTC", usetz = FALSE)
} else if (inherits(x = x, what = "character")) {
- y <- lubridate::parse_date_time(x = x,
+ y <- lubridate::parse_date_time(x = x,
orders = c("%Y-%m-%d %H:%M:%S",
"%Y-%m-%d %H:%M",
"%Y-%m-%d",
@@ -848,8 +849,8 @@ url_posixct_format <- function(x) {
"%Y%m%d%H%M%S",
"%Y%m%d%H%M",
"%Y%m%d"),
- tz = "UTC",
- quiet = TRUE) |>
+ tz = "UTC",
+ quiet = TRUE) |>
strftime(format = "%Y%m%d%H%M", tz = "UTC", usetz = FALSE)
if (is.na(y)) {
stop(
@@ -861,7 +862,7 @@ url_posixct_format <- function(x) {
)
} else {
warning(
- "The ", x, " value has interpreted as UTC!",
+ "The ", x, " value has been interpreted as UTC!",
call. = FALSE
)
}
@@ -903,19 +904,19 @@ get_eiccodes <- function(
)
if (is.null(content$error)) {
lns <- content$result |>
- stringr::str_replace_all(pattern = "tutkimustehdas;\\sImatra",
+ stringr::str_replace_all(pattern = "tutkimustehdas;\\sImatra",
replacement = "tutkimustehdas, Imatra") |>
- stringr::str_replace_all(pattern = "; S\\.L\\.;",
+ stringr::str_replace_all(pattern = "; S\\.L\\.;",
replacement = ", S.L.;") |>
- stringr::str_replace_all(pattern = "\\$amp;",
+ stringr::str_replace_all(pattern = "\\$amp;",
replacement = "&")
# reading lines as they would be a csv
eiccodes <- data.table::fread(
- text = lns,
- sep = ";",
+ text = lns,
+ sep = ";",
na.strings = c("", "n / a", "n/a", "N/A", "-", "-------", "."),
- encoding = "UTF-8"
+ encoding = "UTF-8"
)
# trimming character columns
@@ -934,12 +935,7 @@ get_eiccodes <- function(
eiccodes
} else {
-
- stop(
- sprintf("cannot open the connection to '%s'!", complete_url),
- call. = FALSE
- )
-
+ stop(content$error$message, call. = FALSE)
}
}
@@ -972,7 +968,11 @@ get_all_allocated_eic <- function() {
body_req = FALSE,
body_resp = FALSE
) |>
- httr2::req_timeout(seconds = 60)
+ httr2::req_timeout(seconds = 120) |>
+ httr2::req_retry(
+ max_tries = 3L,
+ backoff = \(resp) 10
+ )
resp <- "No response."
resp <- req_perform_safe(req = req)
@@ -1013,8 +1013,8 @@ get_all_allocated_eic <- function() {
purrr::imap(
\(scnd_ns, idx) {
times <- second_level_length - idx + 1L
- thsnd_idx <- ((second_level_length - times) %/% 1000L + 1L)
if (times %% 1000L == 0L) {
+ thsnd_idx <- (idx - 1L) %/% 1000L + 1L
message(thsnd_idx, " ", rep(x = "<", times = times %/% 1000L))
}
# extract as named list
@@ -1023,17 +1023,21 @@ get_all_allocated_eic <- function() {
convert.types = FALSE
)
# collapse duplicated elements
- dupl_col <- which(table(names(nodeset_list)) > 1L) |>
- names()
- for (col in dupl_col) {
- indices <- which(names(nodeset_list) == col)
- first_idx <- indices[[1L]]
- rest_idx <- base::setdiff(x = indices, y = first_idx)
- nodeset_list[first_idx] <- paste(
- nodeset_list[indices],
- collapse = " - "
- )
- nodeset_list[rest_idx] <- NULL
+ if (anyDuplicated(names(nodeset_list))) {
+ dupl_lgl <- names(nodeset_list) |>
+ duplicated()
+ dupl_col <- names(nodeset_list)[dupl_lgl] |>
+ unique()
+ for (col in dupl_col) {
+ indices <- which(names(nodeset_list) == col)
+ first_idx <- indices[[1L]]
+ rest_idx <- indices[-1L]
+ nodeset_list[first_idx] <- paste(
+ nodeset_list[indices],
+ collapse = " - "
+ )
+ nodeset_list[rest_idx] <- NULL
+ }
}
# convert named list to table
data.table::as.data.table(nodeset_list)
@@ -1122,153 +1126,55 @@ my_snakecase <- function(tbl) {
}
names(tbl) |>
stringr::str_replace_all(
- pattern = "mRID",
- replacement = "mrid"
- ) |>
- stringr::str_replace_all(
- pattern = "TimeSeries",
- replacement = "ts"
- ) |>
- stringr::str_remove(
- pattern = "^process"
- ) |>
- stringr::str_replace_all(
- pattern = "unavailability_Time_Period",
- replacement = "unavailability"
- ) |>
- stringr::str_replace_all(
- pattern = "ts.[p|P]roduction_RegisteredResource.pSRType",
- replacement = "ts.production"
- ) |>
- stringr::str_replace_all(
- pattern = "ts.[p|P]roduction_RegisteredResource",
- replacement = "ts.production"
- ) |>
- stringr::str_replace_all(
- pattern = "ts.[a|A]sset_RegisteredResource.pSRType",
- replacement = "ts.asset"
- ) |>
- stringr::str_replace_all(
- pattern = "ts.[a|A]sset_RegisteredResource",
- replacement = "ts.asset"
- ) |>
- stringr::str_replace_all(
- pattern = "[p|P]owerSystemResources",
- replacement = "psr"
- ) |>
- stringr::str_replace_all(
- pattern = "eICCode",
- replacement = "eicCode"
- ) |>
- stringr::str_replace_all(
- pattern = "aCERCode",
- replacement = "acerCode"
- ) |>
- stringr::str_replace_all(
- pattern = "vATCode",
- replacement = "vatCode"
- ) |>
- stringr::str_replace_all(
- pattern = "eICParent",
- replacement = "eic_parent"
- ) |>
- stringr::str_replace_all(
- pattern = "eICResponsible",
- replacement = "eicResponsible"
- ) |>
- stringr::str_replace_all(
- pattern = "EICCode_MarketDocument",
- replacement = "eicCode"
- ) |>
- stringr::str_replace_all(
- pattern = "eICResponsible",
- replacement = "eicResponsible"
+ c(
+ "mRID" = "mrid",
+ "TimeSeries" = "ts",
+ "^process" = "",
+ "unavailability_Time_Period" = "unavailability",
+ "ts.[p|P]roduction_RegisteredResource.pSRType" = "ts.production",
+ "ts.[p|P]roduction_RegisteredResource" = "ts.production",
+ "ts.[a|A]sset_RegisteredResource.pSRType" = "ts.asset",
+ "ts.[a|A]sset_RegisteredResource" = "ts.asset",
+ "[p|P]owerSystemResources" = "psr",
+ "eICCode" = "eicCode",
+ "aCERCode" = "acerCode",
+ "vATCode" = "vatCode",
+ "eICParent" = "eic_parent",
+ "eICResponsible" = "eicResponsible",
+ "EICCode_MarketDocument" = "eicCode"
+ )
) |>
snakecase::to_snake_case() |>
stringr::str_replace_all(
- pattern = "psr_type_psr_type",
- replacement = "psr_type"
- ) |>
- stringr::str_replace_all(
- pattern = "asset_psr_type",
- replacement = "psr_type"
- ) |>
- stringr::str_replace_all(
- pattern = "_direction_direction",
- replacement = "_direction"
- ) |>
- stringr::str_replace_all(
- pattern = "eic_code_eic_code_",
- replacement = "eic_code_"
- ) |>
- stringr::str_replace_all(
- pattern = "_names_name",
- replacement = "_name"
- ) |>
- stringr::str_remove(
- pattern = "ts_mkt_psr_type_voltage_psr_"
- ) |>
- stringr::str_remove_all(
- pattern = "_(wind|solar)_power_feedin"
- ) |>
- stringr::str_replace_all(
- pattern = "ts_period_",
- replacement = "ts_"
- ) |>
- stringr::str_replace_all(
- pattern = "_quantity_quantity",
- replacement = "_quantity"
- ) |>
- stringr::str_replace_all(
- pattern = "_market_product_market_product",
- replacement = "_market_product"
- ) |>
- stringr::str_replace_all(
- pattern = "_attribute_instance_component",
- replacement = ""
- ) |>
- stringr::str_replace_all(
- pattern = "ts_point_constraint_ts_",
- replacement = "constraint_ts_"
- ) |>
- stringr::str_remove(
- pattern = "ts_point_constraint_"
- ) |>
- stringr::str_replace_all(
- pattern = "ts_monitored_registered_resource_",
- replacement = "ts_monitored_"
- ) |>
- stringr::str_replace_all(
- pattern = "_ptdf_domain_p_tdf_quantity",
- replacement = "_ptdf_domain_quantity"
- ) |>
- stringr::str_replace_all(
- pattern = "_flow_based_study_domain_flow_based_margin_quantity",
- replacement = "_flow_based_study_domain_margin_quantity"
- ) |>
- stringr::str_replace_all(
- pattern = "attribute_instance_component_attribute",
- replacement = "instance_component_attribute"
- ) |>
- stringr::str_replace_all(
- pattern = "last_request_date_and_or_time_date",
- replacement = "last_request_date"
- ) |>
- stringr::str_replace_all(
- pattern = "eic_responsible_market_participant_mrid",
- replacement = "responsible_market_participant_mrid"
- ) |>
- stringr::str_replace_all(
- pattern = "eic_code_market_participant_vat_code_name",
- replacement = "market_participant_vat_code_name"
- ) |>
- stringr::str_replace_all(
- pattern = "eic_code_market_participant_acer_code_name",
- replacement = "market_participant_acer_code_name"
- ) |>
- stringr::str_replace_all(
- pattern = "eic_parent_market_document_mrid",
- replacement = "parent_market_document_mrid"
+ c(
+ "psr_type_psr_type" = "psr_type",
+ "asset_psr_type" = "psr_type",
+ "_direction_direction" = "_direction",
+ "eic_code_eic_code_" = "eic_code_",
+ "_names_name" = "_name",
+ "ts_mkt_psr_type_voltage_psr_" = "",
+ "_(wind|solar)_power_feedin" = "",
+ "ts_period_" = "ts_",
+ "_quantity_quantity" = "_quantity",
+ "_market_product_market_product" = "_market_product",
+ "_attribute_instance_component" = "",
+ "ts_point_constraint_ts_" = "constraint_ts_",
+ "ts_point_constraint_" = "",
+ "ts_monitored_registered_resource_" = "ts_monitored_",
+ "_ptdf_domain_p_tdf_quantity" = "_ptdf_domain_quantity",
+ "_flow_based_study_domain_flow_based_margin_quantity" =
+ "_flow_based_study_domain_margin_quantity",
+ "attribute_instance_component_attribute" =
+ "instance_component_attribute",
+ "last_request_date_and_or_time_date" = "last_request_date",
+ "eic_responsible_market_participant_mrid" =
+ "responsible_market_participant_mrid",
+ "eic_code_market_participant_vat_code_name" =
+ "market_participant_vat_code_name",
+ "eic_code_market_participant_acer_code_name" =
+ "market_participant_acer_code_name",
+ "eic_parent_market_document_mrid" = "parent_market_document_mrid"
+ )
)
}
@@ -1443,7 +1349,7 @@ add_type_names <- function(tbl) {
)
}
if (length(affected_cols) == 0L) {
- warning("No additional type names added!")
+ cat("No additional type names added!", sep = "\n")
}
tbl
@@ -1706,7 +1612,7 @@ add_eic_names <- function(tbl) {
)
}
if (length(affected_cols) == 0L) {
- warning("No additional eic names added!")
+ cat("No additional eic names added!", sep = "\n")
}
tbl
@@ -1850,7 +1756,7 @@ add_definitions <- function(tbl) {
)
}
if (length(affected_cols) == 0L) {
- warning("No additional definitions added!")
+ cat("No additional definitions added!", sep = "\n")
}
tbl
diff --git a/README.md b/README.md
index c2c137ad..5f106a7c 100644
--- a/README.md
+++ b/README.md
@@ -65,6 +65,24 @@ The goal of `entsoeapi` package is to create an easy wrapper for querying the EN
- netted_volumes (IFs IN 3.10)
- elastic_demands (IF mFRR 3.4)
- balancing_border_cap_limit (IFs 4.3 & 4.4)
+ - exchanged_volumes_per_border (3.10, 3.16 & 3.17) (beta test version)
+ - netted_volumes_per_border (3.10, 3.16 & 3.17) (beta test version)
+ - hvdc_link_constrains (4.5) (beta test version)
+ - changes_to_bid_availability (mFRR 9.9, aFRR 9.6&9.8) (beta test version)
+ - current_balancing_state (12.3.A) (beta test version)
+ - balancing_energy_bids (12.3.B&C) (beta test version)
+ - aggregated_balancing_energy_bids (12.3.E) (beta test version)
+ - procured_balancing_capacity (12.3.F) (beta test version)
+ - allocation_of_cross_zonal_balancing_cap (12.3.H&I) (beta test version)
+ - contracted_reserves (17.1.B&C) (beta test version)
+ - activated_balancing_prices (17.1.F) (beta test version)
+ - imbalance_prices (17.1.G) (beta test version)
+ - imbalance_volumes (17.1.H) (beta test version)
+ - financial_expenses_and_income_for_balancing (17.1.I) (beta test version)
+ - fcr_total_capacity (187.2) (beta test version)
+ - shares_of_fcr_capacity (187.2) (beta test version)
+ - rr_and_frr_actual_capacity (188.4 & 189.3) (beta test version)
+ - rr_actual_capacity (189.3) (beta test version)
All the function calls convert the xml responses to tabular data. Be aware, that not all endpoints are implemented. If you want to use an unimplemented endpoint, please submit an [issue](https://github.com/krose/entsoeapi/issues/new/choose) and we'll do our best to resolve it.\
IMPORTANT!\
@@ -114,11 +132,11 @@ For some of the data you need to translate the generation codes.
``` r
dplyr::glimpse(entsoeapi::asset_types)
-#> Rows: 29
+#> Rows: 90
#> Columns: 3
-#> $ Code "A01", "A02", "A03", "A04", "A05", "B01", "B02", "B0…
-#> $ Title "Tieline", "Line", "Resource Object", "Generation", …
-#> $ Description "A high voltage line used for cross border energy in…
+#> $ code "A01", "A02", "A03", "A04", "A05", "A06", "A07", "A0…
+#> $ title "Tieline", "Line", "Resource Object", "Generation", …
+#> $ description "A high voltage line used for cross border energy in…
```
Let’s get the demand in Germany.
@@ -166,31 +184,31 @@ entsoeapi::gen_per_prod_type(
tidy_output = TRUE
) |>
dplyr::glimpse()
-#> Rows: 1,581
+#> Rows: 1,632
#> Columns: 25
-#> $ ts_in_bidding_zone_domain_mrid "10Y1001A1001A83F", "10Y1001A1001A83F", "10Y100…
-#> $ ts_in_bidding_zone_domain_name "Germany", "Germany", "Germany", "Germany", "Ge…
-#> $ ts_out_bidding_zone_domain_mrid NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,…
-#> $ ts_out_bidding_zone_domain_name NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,…
-#> $ type "A75", "A75", "A75", "A75", "A75", "A75", "A75"…
-#> $ type_def "Actual generation per type", "Actual generatio…
-#> $ process_type "A16", "A16", "A16", "A16", "A16", "A16", "A16"…
-#> $ process_type_def "Realised", "Realised", "Realised", "Realised",…
-#> $ ts_object_aggregation "A08", "A08", "A08", "A08", "A08", "A08", "A08"…
-#> $ ts_object_aggregation_def "Resource type", "Resource type", "Resource typ…
-#> $ ts_business_type "A01", "A01", "A01", "A01", "A01", "A01", "A01"…
-#> $ ts_business_type_def "Production", "Production", "Production", "Prod…
-#> $ ts_mkt_psr_type "B01", "B01", "B01", "B01", "B01", "B01", "B01"…
-#> $ ts_mkt_psr_type_def "Biomass", "Biomass", "Biomass", "Biomass", "Bi…
-#> $ created_date_time 22026-02-16 08:56:28, 2026-02-16 08:56:28, 202…
-#> $ revision_number 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,…
-#> $ time_period_time_interval_start 2019-12-31 23:00:00, 2019-12-31 23:00:00, 2019…
-#> $ time_period_time_interval_end 2020-01-01 23:00:00, 2020-01-01 23:00:00, 2020…
-#> $ ts_resolution "PT15M", "PT15M", "PT15M", "PT15M", "PT15M", "P…
-#> $ ts_time_interval_start 2019-12-31 23:00:00, 2019-12-31 23:00:00, 2019…
-#> $ ts_time_interval_end 2020-01-01 23:00:00, 2020-01-01 23:00:00, 2020…
-#> $ ts_mrid 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,…
-#> $ ts_point_dt_start 2019-12-31 23:00:00, 2019-12-31 23:15:00, 2019…
-#> $ ts_point_quantity 4809.13, 4803.04, 4787.15, 4787.26, 4784.65, 47…
-#> $ ts_quantity_measure_unit_name "MAW", "MAW", "MAW", "MAW", "MAW", "MAW", "MAW"…
+#> $ ts_in_bidding_zone_domain_mrid "10Y1001A1001A83F", "10Y1001A1001A83F", "10Y1001…
+#> $ ts_in_bidding_zone_domain_name "Germany", "Germany", "Germany", "Germany", "Ger…
+#> $ ts_out_bidding_zone_domain_mrid NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, …
+#> $ ts_out_bidding_zone_domain_name NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, …
+#> $ type "A75", "A75", "A75", "A75", "A75", "A75", "A75",…
+#> $ type_def "Actual generation per type", "Actual generation…
+#> $ process_type "A16", "A16", "A16", "A16", "A16", "A16", "A16",…
+#> $ process_type_def "Realised", "Realised", "Realised", "Realised", …
+#> $ ts_object_aggregation "A08", "A08", "A08", "A08", "A08", "A08", "A08",…
+#> $ ts_object_aggregation_def "Resource type", "Resource type", "Resource type…
+#> $ ts_business_type "A01", "A01", "A01", "A01", "A01", "A01", "A01",…
+#> $ ts_business_type_def "Production", "Production", "Production", "Produ…
+#> $ ts_mkt_psr_type "B01", "B01", "B01", "B01", "B01", "B01", "B01",…
+#> $ ts_mkt_psr_type_def "Biomass", "Biomass", "Biomass", "Biomass", "Bio…
+#> $ created_date_time 2026-02-24 11:19:58, 2026-02-24 11:19:58, 2026-…
+#> $ revision_number 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, …
+#> $ time_period_time_interval_start 2019-12-31 23:00:00, 2019-12-31 23:00:00, 2019-…
+#> $ time_period_time_interval_end 2020-01-01 23:00:00, 2020-01-01 23:00:00, 2020-…
+#> $ ts_resolution "PT15M", "PT15M", "PT15M", "PT15M", "PT15M", "PT…
+#> $ ts_time_interval_start 2019-12-31 23:00:00, 2019-12-31 23:00:00, 2019-…
+#> $ ts_time_interval_end 2020-01-01 23:00:00, 2020-01-01 23:00:00, 2020-…
+#> $ ts_mrid 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, …
+#> $ ts_point_dt_start 2019-12-31 23:00:00, 2019-12-31 23:15:00, 2019-…
+#> $ ts_point_quantity 4809.13, 4803.04, 4787.15, 4787.26, 4784.65, 476…
+#> $ ts_quantity_measure_unit_name "MAW", "MAW", "MAW", "MAW", "MAW", "MAW", "MAW",…
```
diff --git a/man/activated_balancing_prices.Rd b/man/activated_balancing_prices.Rd
new file mode 100644
index 00000000..3b7f6503
--- /dev/null
+++ b/man/activated_balancing_prices.Rd
@@ -0,0 +1,48 @@
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/en_balancing.R
+\name{activated_balancing_prices}
+\alias{activated_balancing_prices}
+\title{Get Activated Balancing Prices (TR 17.1.F, IF aFRR 3.16)}
+\usage{
+activated_balancing_prices(
+ eic = NULL,
+ process_type = "A16",
+ business_type = NULL,
+ period_start = lubridate::ymd(Sys.Date() - lubridate::days(x = 7L), tz = "CET"),
+ period_end = lubridate::ymd(Sys.Date(), tz = "CET"),
+ tidy_output = TRUE,
+ security_token = Sys.getenv("ENTSOE_PAT")
+)
+}
+\arguments{
+\item{eic}{Energy Identification Code of the control area domain}
+
+\item{process_type}{Process type code, defaults to "A16"}
+
+\item{business_type}{Optional business type code}
+
+\item{period_start}{POSIXct or YYYY-MM-DD HH:MM:SS format
+One year range limit applies}
+
+\item{period_end}{POSIXct or YYYY-MM-DD HH:MM:SS format
+One year range limit applies}
+
+\item{tidy_output}{Defaults to TRUE. flatten nested tables}
+
+\item{security_token}{Security token for ENTSO-E transparency platform}
+}
+\description{
+Prices of activated balancing energy and aFRR cross-border marginal prices.
+One year range limit applies.
+}
+\examples{
+df <- entsoeapi::activated_balancing_prices(
+ eic = "10YCZ-CEPS-----N",
+ period_start = lubridate::ymd(x = "2024-01-01", tz = "CET"),
+ period_end = lubridate::ymd(x = "2024-01-02", tz = "CET"),
+ tidy_output = TRUE
+)
+
+str(df)
+
+}
diff --git a/man/aggregated_balancing_energy_bids.Rd b/man/aggregated_balancing_energy_bids.Rd
new file mode 100644
index 00000000..ca5448b1
--- /dev/null
+++ b/man/aggregated_balancing_energy_bids.Rd
@@ -0,0 +1,51 @@
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/en_balancing.R
+\name{aggregated_balancing_energy_bids}
+\alias{aggregated_balancing_energy_bids}
+\title{Get Aggregated Balancing Energy Bids (GL EB 12.3.E)}
+\usage{
+aggregated_balancing_energy_bids(
+ eic = NULL,
+ process_type = NULL,
+ period_start = lubridate::ymd(Sys.Date() - lubridate::days(x = 7L), tz = "CET"),
+ period_end = lubridate::ymd(Sys.Date(), tz = "CET"),
+ tidy_output = TRUE,
+ security_token = Sys.getenv("ENTSOE_PAT")
+)
+}
+\arguments{
+\item{eic}{Energy Identification Code of the area domain}
+
+\item{process_type}{type of frequency restoration reserve
+"A51" aFRR
+"A46" RR
+"A47" mFRR
+"A60" mFRR with scheduled activation
+"A61" mFRR with direct activation}
+
+\item{period_start}{POSIXct or YYYY-MM-DD HH:MM:SS format
+One year range limit applies}
+
+\item{period_end}{POSIXct or YYYY-MM-DD HH:MM:SS format
+One year range limit applies}
+
+\item{tidy_output}{Defaults to TRUE. flatten nested tables}
+
+\item{security_token}{Security token for ENTSO-E transparency platform}
+}
+\description{
+Aggregated balancing energy bids.
+One year range limit applies.
+}
+\examples{
+df <- entsoeapi::aggregated_balancing_energy_bids(
+ eic = "10YCZ-CEPS-----N",
+ process_type = "A51",
+ period_start = lubridate::ymd(x = "2024-01-01", tz = "CET"),
+ period_end = lubridate::ymd(x = "2024-01-02", tz = "CET"),
+ tidy_output = TRUE
+)
+
+str(df)
+
+}
diff --git a/man/allocation_of_cross_zonal_balancing_cap.Rd b/man/allocation_of_cross_zonal_balancing_cap.Rd
new file mode 100644
index 00000000..0e648929
--- /dev/null
+++ b/man/allocation_of_cross_zonal_balancing_cap.Rd
@@ -0,0 +1,47 @@
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/en_balancing.R
+\name{allocation_of_cross_zonal_balancing_cap}
+\alias{allocation_of_cross_zonal_balancing_cap}
+\title{Get Allocation of Cross-Zonal Balancing Capacity (GL EB 12.3.H&I)}
+\usage{
+allocation_of_cross_zonal_balancing_cap(
+ eic_acquiring = NULL,
+ eic_connecting = NULL,
+ type_market_agreement = NULL,
+ period_start = lubridate::ymd(Sys.Date() - lubridate::days(x = 7L), tz = "CET"),
+ period_end = lubridate::ymd(Sys.Date(), tz = "CET"),
+ tidy_output = TRUE,
+ security_token = Sys.getenv("ENTSOE_PAT")
+)
+}
+\arguments{
+\item{eic_acquiring}{Energy Identification Code of the acquiring domain}
+
+\item{eic_connecting}{Energy Identification Code of the connecting domain}
+
+\item{type_market_agreement}{Optional market agreement type code}
+
+\item{period_start}{POSIXct or YYYY-MM-DD HH:MM:SS format}
+
+\item{period_end}{POSIXct or YYYY-MM-DD HH:MM:SS format}
+
+\item{tidy_output}{Defaults to TRUE. flatten nested tables}
+
+\item{security_token}{Security token for ENTSO-E transparency platform}
+}
+\description{
+Use of allocated cross-zonal balancing capacity between
+an acquiring and a connecting domain.
+}
+\examples{
+df <- entsoeapi::allocation_of_cross_zonal_balancing_cap(
+ eic_acquiring = "10YAT-APG------L",
+ eic_connecting = "10YCH-SWISSGRIDZ",
+ period_start = lubridate::ymd(x = "2024-01-01", tz = "CET"),
+ period_end = lubridate::ymd(x = "2024-01-02", tz = "CET"),
+ tidy_output = TRUE
+)
+
+str(df)
+
+}
diff --git a/man/balancing_border_cap_limit.Rd b/man/balancing_border_cap_limit.Rd
index f623a30d..947bec58 100644
--- a/man/balancing_border_cap_limit.Rd
+++ b/man/balancing_border_cap_limit.Rd
@@ -7,8 +7,7 @@
balancing_border_cap_limit(
eic_in = NULL,
eic_out = NULL,
- eic_interconnector = NULL,
- process_type = NULL,
+ process_type = "A51",
period_start = lubridate::ymd(Sys.Date() - lubridate::days(x = 7L), tz = "CET"),
period_end = lubridate::ymd(Sys.Date(), tz = "CET"),
tidy_output = TRUE,
@@ -22,13 +21,10 @@ or in Scheduling area (SCA)}
\item{eic_out}{Energy Identification Code of out an out LFC Area (LFA)
or out Scheduling area (SCA)}
-\item{eic_interconnector}{Energy Identification Code of a Transmission Asset,
-optional filter}
-
\item{process_type}{type of frequency restoration reserve
-A47 mFRR
-A51 aFRR
-A63 Imbalance Netting}
+"A47" mFRR
+"A51" aFRR
+"A63" Imbalance Netting}
\item{period_start}{POSIXct or YYYY-MM-DD HH:MM:SS format
One year range limit applies}
@@ -46,13 +42,14 @@ participating or affected TSOs.
}
\examples{
df <- entsoeapi::balancing_border_cap_limit(
- eic_in = "10YDE-RWENET---I",
- eic_out = "10YBE----------2",
+ eic_in = "10YDE-RWENET---I",
+ eic_out = "10YBE----------2",
process_type = "A51",
period_start = lubridate::ymd(x = "2022-06-22", tz = "CET"),
- period_end = lubridate::ymd(x = "2022-06-23", tz = "CET"),
- tidy_output = TRUE
+ period_end = lubridate::ymd(x = "2022-06-23", tz = "CET"),
+ tidy_output = TRUE
)
+
str(df)
}
diff --git a/man/balancing_energy_bids.Rd b/man/balancing_energy_bids.Rd
new file mode 100644
index 00000000..04768137
--- /dev/null
+++ b/man/balancing_energy_bids.Rd
@@ -0,0 +1,44 @@
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/en_balancing.R
+\name{balancing_energy_bids}
+\alias{balancing_energy_bids}
+\title{Get Balancing Energy Bids (GL EB 12.3.B&C)}
+\usage{
+balancing_energy_bids(
+ eic = NULL,
+ process_type = "A47",
+ period_start = lubridate::ymd(Sys.Date() - lubridate::days(x = 7L), tz = "CET"),
+ period_end = lubridate::ymd(Sys.Date(), tz = "CET"),
+ tidy_output = TRUE,
+ security_token = Sys.getenv("ENTSOE_PAT")
+)
+}
+\arguments{
+\item{eic}{Energy Identification Code of the connecting domain}
+
+\item{process_type}{Process type (currently only A47 is supported)}
+
+\item{period_start}{POSIXct or YYYY-MM-DD HH:MM:SS format}
+
+\item{period_end}{POSIXct or YYYY-MM-DD HH:MM:SS format}
+
+\item{tidy_output}{Defaults to TRUE. flatten nested tables}
+
+\item{security_token}{Security token for ENTSO-E transparency platform}
+}
+\description{
+Balancing energy bids submitted by BSPs.
+100 documents limit applies; paging is handled transparently.
+}
+\examples{
+df <- entsoeapi::balancing_energy_bids(
+ eic = "10YCZ-CEPS-----N",
+ process_type = "A47",
+ period_start = lubridate::ymd(x = "2024-01-01", tz = "CET"),
+ period_end = lubridate::ymd(x = "2024-01-02", tz = "CET"),
+ tidy_output = TRUE
+)
+
+str(df)
+
+}
diff --git a/man/changes_to_bid_availability.Rd b/man/changes_to_bid_availability.Rd
new file mode 100644
index 00000000..8ade8079
--- /dev/null
+++ b/man/changes_to_bid_availability.Rd
@@ -0,0 +1,54 @@
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/en_balancing.R
+\name{changes_to_bid_availability}
+\alias{changes_to_bid_availability}
+\title{Get Changes to Bid Availability (IFs mFRR 9.9, aFRR 9.6 & 9.8)}
+\usage{
+changes_to_bid_availability(
+ eic = NULL,
+ business_type = "C46",
+ period_start = lubridate::ymd(Sys.Date() - lubridate::days(x = 7L), tz = "CET"),
+ period_end = lubridate::ymd(Sys.Date(), tz = "CET"),
+ tidy_output = TRUE,
+ security_token = Sys.getenv("ENTSOE_PAT")
+)
+}
+\arguments{
+\item{eic}{Energy Identification Code of the domain}
+
+\item{business_type}{type of frequency restoration reserve
+"C40" Conditional bid
+"C41" Thermal limit
+"C42" Frequency limit
+"C43" Voltage limit
+"C44" Current limit
+"C45" Short-circuit current limits
+"C46" Dynamic stability limit
+Defaults to "C46".}
+
+\item{period_start}{POSIXct or YYYY-MM-DD HH:MM:SS format
+One year range limit applies}
+
+\item{period_end}{POSIXct or YYYY-MM-DD HH:MM:SS format
+One year range limit applies}
+
+\item{tidy_output}{Defaults to TRUE. flatten nested tables}
+
+\item{security_token}{Security token for ENTSO-E transparency platform}
+}
+\description{
+Changes to bid availability for scheduled activation products.
+100 documents limit applies; paging is handled transparently.
+}
+\examples{
+df <- entsoeapi::changes_to_bid_availability(
+ eic = "10YCZ-CEPS-----N",
+ business_type = "C46",
+ period_start = lubridate::ymd(x = "2024-01-01", tz = "CET"),
+ period_end = lubridate::ymd(x = "2024-01-02", tz = "CET"),
+ tidy_output = TRUE
+)
+
+str(df)
+
+}
diff --git a/man/contracted_reserves.Rd b/man/contracted_reserves.Rd
new file mode 100644
index 00000000..ab83e7ae
--- /dev/null
+++ b/man/contracted_reserves.Rd
@@ -0,0 +1,63 @@
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/en_balancing.R
+\name{contracted_reserves}
+\alias{contracted_reserves}
+\title{Get Contracted Reserves (17.1.B&C)}
+\usage{
+contracted_reserves(
+ eic = NULL,
+ type_market_agreement = NULL,
+ process_type = NULL,
+ psr_type = NULL,
+ period_start = lubridate::ymd(Sys.Date() - lubridate::days(x = 7L), tz = "CET"),
+ period_end = lubridate::ymd(Sys.Date(), tz = "CET"),
+ tidy_output = TRUE,
+ security_token = Sys.getenv("ENTSOE_PAT")
+)
+}
+\arguments{
+\item{eic}{Energy Identification Code of the control area domain}
+
+\item{type_market_agreement}{Market agreement type code (mandatory)
+"A01" Daily
+"A02" Weekly
+"A03" Monthly
+"A04" Yearly
+"A06" Long term
+"A13" Hourly}
+
+\item{process_type}{Optional process type code
+"A46" Replacement reserve
+"A47" Manual frequency restoration reserve
+"A51" Automatic frequency restoration reserve
+"A52" Frequency containment reserve}
+
+\item{psr_type}{Optional PSR type code
+"A03" Mixed
+"A04" Generation
+"A05" Load}
+
+\item{period_start}{POSIXct or YYYY-MM-DD HH:MM:SS format}
+
+\item{period_end}{POSIXct or YYYY-MM-DD HH:MM:SS format}
+
+\item{tidy_output}{Defaults to TRUE. flatten nested tables}
+
+\item{security_token}{Security token for ENTSO-E transparency platform}
+}
+\description{
+Volumes and prices of contracted reserves.
+100 documents limit applies; paging is handled transparently.
+}
+\examples{
+df <- entsoeapi::contracted_reserves(
+ eic = "10YCZ-CEPS-----N",
+ type_market_agreement = "A13",
+ period_start = lubridate::ymd(x = "2022-01-01", tz = "CET"),
+ period_end = lubridate::ymd(x = "2022-01-02", tz = "CET"),
+ tidy_output = TRUE
+)
+
+str(df)
+
+}
diff --git a/man/current_balancing_state.Rd b/man/current_balancing_state.Rd
new file mode 100644
index 00000000..d837031c
--- /dev/null
+++ b/man/current_balancing_state.Rd
@@ -0,0 +1,42 @@
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/en_balancing.R
+\name{current_balancing_state}
+\alias{current_balancing_state}
+\title{Get Current Balancing State (GL EB 12.3.A)}
+\usage{
+current_balancing_state(
+ eic = NULL,
+ period_start = lubridate::ymd(Sys.Date() - lubridate::days(x = 7L), tz = "CET"),
+ period_end = lubridate::ymd(Sys.Date(), tz = "CET"),
+ tidy_output = TRUE,
+ security_token = Sys.getenv("ENTSOE_PAT")
+)
+}
+\arguments{
+\item{eic}{Energy Identification Code of the area domain}
+
+\item{period_start}{POSIXct or YYYY-MM-DD HH:MM:SS format
+100 day range limit applies}
+
+\item{period_end}{POSIXct or YYYY-MM-DD HH:MM:SS format
+100 day range limit applies}
+
+\item{tidy_output}{Defaults to TRUE. flatten nested tables}
+
+\item{security_token}{Security token for ENTSO-E transparency platform}
+}
+\description{
+Current balancing state of the control area.
+100 day range limit applies.
+}
+\examples{
+df <- entsoeapi::current_balancing_state(
+ eic = "10YCZ-CEPS-----N",
+ period_start = lubridate::ymd(x = "2024-01-01", tz = "CET"),
+ period_end = lubridate::ymd(x = "2024-01-02", tz = "CET"),
+ tidy_output = TRUE
+)
+
+str(df)
+
+}
diff --git a/man/elastic_demands.Rd b/man/elastic_demands.Rd
index 879123d7..d0340ddb 100644
--- a/man/elastic_demands.Rd
+++ b/man/elastic_demands.Rd
@@ -17,8 +17,8 @@ elastic_demands(
\item{eic}{Energy Identification Code of the scheduling area}
\item{process_type}{type of frequency restoration reserve
-A47 mFRR
-A51 aFRR}
+"A47" mFRR
+"A51" aFRR}
\item{period_start}{POSIXct or YYYY-MM-DD HH:MM:SS format
One year range limit applies}
@@ -35,11 +35,11 @@ Elastic demands for scheduled activation of standard aFRR/mFRR product.
}
\examples{
df <- entsoeapi::elastic_demands(
- eic = "10YCZ-CEPS-----N",
+ eic = "10YCZ-CEPS-----N",
process_type = "A47",
period_start = lubridate::ymd(x = "2024-01-01", tz = "CET"),
- period_end = lubridate::ymd(x = "2024-11-01", tz = "CET"),
- tidy_output = TRUE
+ period_end = lubridate::ymd(x = "2024-11-01", tz = "CET"),
+ tidy_output = TRUE
)
str(df)
diff --git a/man/exchanged_volumes.Rd b/man/exchanged_volumes.Rd
index 2b232372..e2df3289 100644
--- a/man/exchanged_volumes.Rd
+++ b/man/exchanged_volumes.Rd
@@ -17,9 +17,9 @@ exchanged_volumes(
\item{eic}{Energy Identification Code of the area}
\item{process_type}{type of frequency restoration reserve
-A51 aFRR
-A60 mFRR with scheduled activation
-A61 mFRR with direct activation}
+"A51" aFRR
+"A60" mFRR with scheduled activation
+"A61" mFRR with direct activation}
\item{period_start}{POSIXct or YYYY-MM-DD HH:MM:SS format
One day range limit applies}
@@ -43,21 +43,22 @@ show the import value.
}
\examples{
df1 <- entsoeapi::exchanged_volumes(
- eic = "10YCZ-CEPS-----N",
+ eic = "10YCZ-CEPS-----N",
process_type = "A51",
period_start = lubridate::ymd(x = "2022-08-16", tz = "CET"),
- period_end = lubridate::ymd(x = "2022-08-17", tz = "CET"),
- tidy_output = TRUE
+ period_end = lubridate::ymd(x = "2022-08-17", tz = "CET"),
+ tidy_output = TRUE
)
str(df1)
df2 <- entsoeapi::exchanged_volumes(
- eic = "10YCZ-CEPS-----N",
+ eic = "10YCZ-CEPS-----N",
process_type = "A60",
period_start = lubridate::ymd(x = "2024-07-11", tz = "CET"),
- period_end = lubridate::ymd(x = "2024-07-12", tz = "CET"),
- tidy_output = TRUE
+ period_end = lubridate::ymd(x = "2024-07-12", tz = "CET"),
+ tidy_output = TRUE
)
+
str(df2)
}
diff --git a/man/exchanged_volumes_per_border.Rd b/man/exchanged_volumes_per_border.Rd
new file mode 100644
index 00000000..b8ead33f
--- /dev/null
+++ b/man/exchanged_volumes_per_border.Rd
@@ -0,0 +1,53 @@
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/en_balancing.R
+\name{exchanged_volumes_per_border}
+\alias{exchanged_volumes_per_border}
+\title{Get Netted & Exchanged Volumes Per Border (IFs 3.10, 3.16 & 3.17)}
+\usage{
+exchanged_volumes_per_border(
+ acquiring_eic = NULL,
+ connecting_eic = NULL,
+ process_type = NULL,
+ period_start = lubridate::ymd(Sys.Date() - lubridate::days(x = 7L), tz = "CET"),
+ period_end = lubridate::ymd(Sys.Date(), tz = "CET"),
+ tidy_output = TRUE,
+ security_token = Sys.getenv("ENTSOE_PAT")
+)
+}
+\arguments{
+\item{acquiring_eic}{Energy Identification Code of the acquiring area}
+
+\item{connecting_eic}{Energy Identification Code of the connecting area}
+
+\item{process_type}{type of frequency restoration reserve
+"A51" aFRR
+"A60" mFRR with scheduled activation
+"A61" mFRR with direct activation}
+
+\item{period_start}{POSIXct or YYYY-MM-DD HH:MM:SS format
+One day range limit applies}
+
+\item{period_end}{POSIXct or YYYY-MM-DD HH:MM:SS format
+One day range limit applies}
+
+\item{tidy_output}{Defaults to TRUE. flatten nested tables}
+
+\item{security_token}{Security token for ENTSO-E transparency platform}
+}
+\description{
+Netted and exchanged balancing energy volumes on a specific border between
+an acquiring and a connecting domain.
+}
+\examples{
+df <- entsoeapi::exchanged_volumes_per_border(
+ acquiring_eic = "10YBE----------2",
+ connecting_eic = "10YFR-RTE------C",
+ process_type = "A60",
+ period_start = lubridate::ymd(x = "2025-03-01", tz = "CET"),
+ period_end = lubridate::ymd(x = "2025-03-02", tz = "CET"),
+ tidy_output = TRUE
+)
+
+str(df)
+
+}
diff --git a/man/fcr_total_capacity.Rd b/man/fcr_total_capacity.Rd
new file mode 100644
index 00000000..dd6b2149
--- /dev/null
+++ b/man/fcr_total_capacity.Rd
@@ -0,0 +1,42 @@
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/en_balancing.R
+\name{fcr_total_capacity}
+\alias{fcr_total_capacity}
+\title{Get FCR Total Capacity (SO GL 187.2)}
+\usage{
+fcr_total_capacity(
+ eic = NULL,
+ period_start = lubridate::ymd(Sys.Date() - lubridate::days(x = 7L), tz = "CET"),
+ period_end = lubridate::ymd(Sys.Date(), tz = "CET"),
+ tidy_output = TRUE,
+ security_token = Sys.getenv("ENTSOE_PAT")
+)
+}
+\arguments{
+\item{eic}{Energy Identification Code of the area domain}
+
+\item{period_start}{POSIXct or YYYY-MM-DD HH:MM:SS format
+One year range limit applies}
+
+\item{period_end}{POSIXct or YYYY-MM-DD HH:MM:SS format
+One year range limit applies}
+
+\item{tidy_output}{Defaults to TRUE. flatten nested tables}
+
+\item{security_token}{Security token for ENTSO-E transparency platform}
+}
+\description{
+Total Frequency Containment Reserve capacity.
+One year range limit applies.
+}
+\examples{
+df <- entsoeapi::fcr_total_capacity(
+ eic = "10YEU-CONT-SYNC0",
+ period_start = lubridate::ymd(x = "2022-01-01", tz = "CET"),
+ period_end = lubridate::ymd(x = "2022-01-02", tz = "CET"),
+ tidy_output = TRUE
+)
+
+str(df)
+
+}
diff --git a/man/financial_expenses_and_income_for_balancing.Rd b/man/financial_expenses_and_income_for_balancing.Rd
new file mode 100644
index 00000000..edcc3961
--- /dev/null
+++ b/man/financial_expenses_and_income_for_balancing.Rd
@@ -0,0 +1,42 @@
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/en_balancing.R
+\name{financial_expenses_and_income_for_balancing}
+\alias{financial_expenses_and_income_for_balancing}
+\title{Get Financial Expenses and Income for Balancing (17.1.I)}
+\usage{
+financial_expenses_and_income_for_balancing(
+ eic = NULL,
+ period_start = lubridate::ymd(Sys.Date() - lubridate::days(x = 7L), tz = "CET"),
+ period_end = lubridate::ymd(Sys.Date(), tz = "CET"),
+ tidy_output = TRUE,
+ security_token = Sys.getenv("ENTSOE_PAT")
+)
+}
+\arguments{
+\item{eic}{Energy Identification Code of the control area domain}
+
+\item{period_start}{POSIXct or YYYY-MM-DD HH:MM:SS format
+One year range limit applies}
+
+\item{period_end}{POSIXct or YYYY-MM-DD HH:MM:SS format
+One year range limit applies}
+
+\item{tidy_output}{Defaults to TRUE. flatten nested tables}
+
+\item{security_token}{Security token for ENTSO-E transparency platform}
+}
+\description{
+Financial expenses and income for balancing of the control area.
+One year range limit applies.
+}
+\examples{
+df <- entsoeapi::financial_expenses_and_income_for_balancing(
+ eic = "10YCZ-CEPS-----N",
+ period_start = lubridate::ymd(x = "2022-01-01", tz = "CET"),
+ period_end = lubridate::ymd(x = "2022-01-02", tz = "CET"),
+ tidy_output = TRUE
+)
+
+str(df)
+
+}
diff --git a/man/hvdc_link_constrains.Rd b/man/hvdc_link_constrains.Rd
new file mode 100644
index 00000000..2a7179d0
--- /dev/null
+++ b/man/hvdc_link_constrains.Rd
@@ -0,0 +1,56 @@
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/en_balancing.R
+\name{hvdc_link_constrains}
+\alias{hvdc_link_constrains}
+\title{Get HVDC Link Constraints (IFs 4.5)}
+\usage{
+hvdc_link_constrains(
+ eic_in = NULL,
+ eic_out = NULL,
+ eic_ic = NULL,
+ process_type = "A63",
+ period_start = lubridate::ymd(Sys.Date() - lubridate::days(x = 7L), tz = "CET"),
+ period_end = lubridate::ymd(Sys.Date(), tz = "CET"),
+ tidy_output = TRUE,
+ security_token = Sys.getenv("ENTSOE_PAT")
+)
+}
+\arguments{
+\item{eic_in}{Energy Identification Code of the in domain}
+
+\item{eic_out}{Energy Identification Code of the out domain}
+
+\item{eic_ic}{Energy Identification Code of the interconnector
+If used, data for the given Transmission Asset is returned}
+
+\item{process_type}{"A47" Manual frequency restoration reserve
+"A51" Automatic Frequency Restoration Reserve
+"A63" Imbalance Netting;
+Defaults to "A63"}
+
+\item{period_start}{POSIXct or YYYY-MM-DD HH:MM:SS format
+One year range limit applies}
+
+\item{period_end}{POSIXct or YYYY-MM-DD HH:MM:SS format
+One year range limit applies}
+
+\item{tidy_output}{Defaults to TRUE. flatten nested tables}
+
+\item{security_token}{Security token for ENTSO-E transparency platform}
+}
+\description{
+Permanent allocation limitations to cross-border capacity on HVDC lines.
+}
+\examples{
+df <- entsoeapi::hvdc_link_constrains(
+ eic_in = "10YAT-APG------L",
+ eic_out = "10YDE-RWENET---I",
+ process_type = "A63",
+ period_start = lubridate::ymd(x = "2022-01-01", tz = "CET"),
+ period_end = lubridate::ymd(x = "2022-01-02", tz = "CET"),
+ tidy_output = TRUE
+)
+
+str(df)
+
+}
diff --git a/man/imbalance_prices.Rd b/man/imbalance_prices.Rd
new file mode 100644
index 00000000..066612c3
--- /dev/null
+++ b/man/imbalance_prices.Rd
@@ -0,0 +1,42 @@
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/en_balancing.R
+\name{imbalance_prices}
+\alias{imbalance_prices}
+\title{Get Imbalance Prices (17.1.G)}
+\usage{
+imbalance_prices(
+ eic = NULL,
+ period_start = lubridate::ymd(Sys.Date() - lubridate::days(x = 7L), tz = "CET"),
+ period_end = lubridate::ymd(Sys.Date(), tz = "CET"),
+ tidy_output = TRUE,
+ security_token = Sys.getenv("ENTSOE_PAT")
+)
+}
+\arguments{
+\item{eic}{Energy Identification Code of the control area domain}
+
+\item{period_start}{POSIXct or YYYY-MM-DD HH:MM:SS format
+One year range limit applies}
+
+\item{period_end}{POSIXct or YYYY-MM-DD HH:MM:SS format
+One year range limit applies}
+
+\item{tidy_output}{Defaults to TRUE. flatten nested tables}
+
+\item{security_token}{Security token for ENTSO-E transparency platform}
+}
+\description{
+Imbalance prices of the control area.
+One year range limit applies.
+}
+\examples{
+df <- entsoeapi::imbalance_prices(
+ eic = "10YCZ-CEPS-----N",
+ period_start = lubridate::ymd(x = "2024-01-01", tz = "CET"),
+ period_end = lubridate::ymd(x = "2024-01-02", tz = "CET"),
+ tidy_output = TRUE
+)
+
+str(df)
+
+}
diff --git a/man/imbalance_volumes.Rd b/man/imbalance_volumes.Rd
new file mode 100644
index 00000000..9d800a22
--- /dev/null
+++ b/man/imbalance_volumes.Rd
@@ -0,0 +1,42 @@
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/en_balancing.R
+\name{imbalance_volumes}
+\alias{imbalance_volumes}
+\title{Get Imbalance Volumes (17.1.H)}
+\usage{
+imbalance_volumes(
+ eic = NULL,
+ period_start = lubridate::ymd(Sys.Date() - lubridate::days(x = 7L), tz = "CET"),
+ period_end = lubridate::ymd(Sys.Date(), tz = "CET"),
+ tidy_output = TRUE,
+ security_token = Sys.getenv("ENTSOE_PAT")
+)
+}
+\arguments{
+\item{eic}{Energy Identification Code of the control area domain}
+
+\item{period_start}{POSIXct or YYYY-MM-DD HH:MM:SS format
+One year range limit applies}
+
+\item{period_end}{POSIXct or YYYY-MM-DD HH:MM:SS format
+One year range limit applies}
+
+\item{tidy_output}{Defaults to TRUE. flatten nested tables}
+
+\item{security_token}{Security token for ENTSO-E transparency platform}
+}
+\description{
+Total imbalance volumes of the control area.
+One year range limit applies.
+}
+\examples{
+df <- entsoeapi::imbalance_volumes(
+ eic = "10YCZ-CEPS-----N",
+ period_start = lubridate::ymd(x = "2024-01-01", tz = "CET"),
+ period_end = lubridate::ymd(x = "2024-01-02", tz = "CET"),
+ tidy_output = TRUE
+)
+
+str(df)
+
+}
diff --git a/man/netted_volumes.Rd b/man/netted_volumes.Rd
index 01cf0dcc..fde624e4 100644
--- a/man/netted_volumes.Rd
+++ b/man/netted_volumes.Rd
@@ -34,11 +34,12 @@ Those rows which hold the queried eic value in the
}
\examples{
df <- entsoeapi::netted_volumes(
- eic = "10YCZ-CEPS-----N",
+ eic = "10YCZ-CEPS-----N",
period_start = lubridate::ymd(x = "2022-08-16", tz = "CET"),
- period_end = lubridate::ymd(x = "2022-08-17", tz = "CET"),
- tidy_output = TRUE
+ period_end = lubridate::ymd(x = "2022-08-17", tz = "CET"),
+ tidy_output = TRUE
)
+
str(df)
}
diff --git a/man/procured_balancing_capacity.Rd b/man/procured_balancing_capacity.Rd
new file mode 100644
index 00000000..7c23b566
--- /dev/null
+++ b/man/procured_balancing_capacity.Rd
@@ -0,0 +1,50 @@
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/en_balancing.R
+\name{procured_balancing_capacity}
+\alias{procured_balancing_capacity}
+\title{Get Procured Balancing Capacity (GL EB 12.3.F)}
+\usage{
+procured_balancing_capacity(
+ eic = NULL,
+ process_type = NULL,
+ type_market_agreement = NULL,
+ period_start = lubridate::ymd(Sys.Date() - lubridate::days(x = 7L), tz = "CET"),
+ period_end = lubridate::ymd(Sys.Date(), tz = "CET"),
+ tidy_output = TRUE,
+ security_token = Sys.getenv("ENTSOE_PAT")
+)
+}
+\arguments{
+\item{eic}{Energy Identification Code of the area domain}
+
+\item{process_type}{type of frequency restoration reserve
+"A51" aFRR
+"A52" FCR
+"A47" mFRR}
+
+\item{type_market_agreement}{Optional market agreement type code}
+
+\item{period_start}{POSIXct or YYYY-MM-DD HH:MM:SS format}
+
+\item{period_end}{POSIXct or YYYY-MM-DD HH:MM:SS format}
+
+\item{tidy_output}{Defaults to TRUE. flatten nested tables}
+
+\item{security_token}{Security token for ENTSO-E transparency platform}
+}
+\description{
+Procured balancing capacity by TSOs.
+100 documents limit applies; paging is handled transparently.
+}
+\examples{
+df <- entsoeapi::procured_balancing_capacity(
+ eic = "10YCZ-CEPS-----N",
+ process_type = "A51",
+ period_start = lubridate::ymd(x = "2024-01-01", tz = "CET"),
+ period_end = lubridate::ymd(x = "2024-01-02", tz = "CET"),
+ tidy_output = TRUE
+)
+
+str(df)
+
+}
diff --git a/man/rr_actual_capacity.Rd b/man/rr_actual_capacity.Rd
new file mode 100644
index 00000000..4a136c32
--- /dev/null
+++ b/man/rr_actual_capacity.Rd
@@ -0,0 +1,40 @@
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/en_balancing.R
+\name{rr_actual_capacity}
+\alias{rr_actual_capacity}
+\title{Get RR Actual Capacity (SO GL 189.3)}
+\usage{
+rr_actual_capacity(
+ eic = NULL,
+ period_start = lubridate::ymd(Sys.Date() - lubridate::days(x = 7L), tz = "CET"),
+ period_end = lubridate::ymd(Sys.Date(), tz = "CET"),
+ tidy_output = TRUE,
+ security_token = Sys.getenv("ENTSOE_PAT")
+)
+}
+\arguments{
+\item{eic}{Energy Identification Code of the area domain}
+
+\item{period_start}{POSIXct or YYYY-MM-DD HH:MM:SS format}
+
+\item{period_end}{POSIXct or YYYY-MM-DD HH:MM:SS format}
+
+\item{tidy_output}{Defaults to TRUE. flatten nested tables}
+
+\item{security_token}{Security token for ENTSO-E transparency platform}
+}
+\description{
+Actual capacity of Replacement Reserve (RR).
+Process type is hardcoded to A46 (Replacement Reserve).
+}
+\examples{
+df <- entsoeapi::rr_actual_capacity(
+ eic = "10YAT-APG------L",
+ period_start = lubridate::ymd(x = "2022-01-01", tz = "CET"),
+ period_end = lubridate::ymd(x = "2022-04-01", tz = "CET"),
+ tidy_output = TRUE
+)
+
+str(df)
+
+}
diff --git a/man/rr_and_frr_actual_capacity.Rd b/man/rr_and_frr_actual_capacity.Rd
new file mode 100644
index 00000000..d71e9923
--- /dev/null
+++ b/man/rr_and_frr_actual_capacity.Rd
@@ -0,0 +1,53 @@
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/en_balancing.R
+\name{rr_and_frr_actual_capacity}
+\alias{rr_and_frr_actual_capacity}
+\title{Get RR and FRR Actual Capacity (SO GL 188.4 & 189.3)}
+\usage{
+rr_and_frr_actual_capacity(
+ eic = NULL,
+ process_type = NULL,
+ business_type = "C78",
+ period_start = lubridate::ymd(Sys.Date() - lubridate::days(x = 7L), tz = "CET"),
+ period_end = lubridate::ymd(Sys.Date(), tz = "CET"),
+ tidy_output = TRUE,
+ security_token = Sys.getenv("ENTSOE_PAT")
+)
+}
+\arguments{
+\item{eic}{Energy Identification Code of the area domain}
+
+\item{process_type}{type of reserve
+"A56" FRR
+"A46" RR}
+
+\item{business_type}{type of aggregation
+"C77" minimum
+"C78" average
+"C79" max
+defaults to "C78"}
+
+\item{period_start}{POSIXct or YYYY-MM-DD HH:MM:SS format}
+
+\item{period_end}{POSIXct or YYYY-MM-DD HH:MM:SS format}
+
+\item{tidy_output}{Defaults to TRUE. flatten nested tables}
+
+\item{security_token}{Security token for ENTSO-E transparency platform}
+}
+\description{
+Actual capacity of Frequency Restoration Reserve (FRR) or
+Replacement Reserve (RR).
+}
+\examples{
+df <- entsoeapi::rr_and_frr_actual_capacity(
+ eic = "10YAT-APG------L",
+ process_type = "A56",
+ period_start = lubridate::ymd(x = "2022-01-01", tz = "CET"),
+ period_end = lubridate::ymd(x = "2022-04-01", tz = "CET"),
+ tidy_output = TRUE
+)
+
+str(df)
+
+}
diff --git a/man/shares_of_fcr_capacity.Rd b/man/shares_of_fcr_capacity.Rd
new file mode 100644
index 00000000..3f20968e
--- /dev/null
+++ b/man/shares_of_fcr_capacity.Rd
@@ -0,0 +1,48 @@
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/en_balancing.R
+\name{shares_of_fcr_capacity}
+\alias{shares_of_fcr_capacity}
+\title{Get Shares of FCR Capacity (SO GL 187.2)}
+\usage{
+shares_of_fcr_capacity(
+ eic = NULL,
+ business_type = NULL,
+ period_start = lubridate::ymd(Sys.Date() - lubridate::days(x = 7L), tz = "CET"),
+ period_end = lubridate::ymd(Sys.Date(), tz = "CET"),
+ tidy_output = TRUE,
+ security_token = Sys.getenv("ENTSOE_PAT")
+)
+}
+\arguments{
+\item{eic}{Energy Identification Code of the area domain}
+
+\item{business_type}{type of FCR capacity share
+"C23" share of FCR capacity
+"B95" contracted FCR capacity}
+
+\item{period_start}{POSIXct or YYYY-MM-DD HH:MM:SS format
+One year range limit applies}
+
+\item{period_end}{POSIXct or YYYY-MM-DD HH:MM:SS format
+One year range limit applies}
+
+\item{tidy_output}{Defaults to TRUE. flatten nested tables}
+
+\item{security_token}{Security token for ENTSO-E transparency platform}
+}
+\description{
+Shares of Frequency Containment Reserve capacity per area.
+One year range limit applies.
+}
+\examples{
+df <- entsoeapi::shares_of_fcr_capacity(
+ eic = "10YDE-VE-------2",
+ business_type = "C23",
+ period_start = lubridate::ymd(x = "2022-01-01", tz = "CET"),
+ period_end = lubridate::ymd(x = "2022-01-02", tz = "CET"),
+ tidy_output = TRUE
+)
+
+str(df)
+
+}
diff --git a/tests/testthat/fixtures/get_allocated_eic_dupl.xml b/tests/testthat/fixtures/get_allocated_eic_dupl.xml
new file mode 100644
index 00000000..f84b9719
--- /dev/null
+++ b/tests/testthat/fixtures/get_allocated_eic_dupl.xml
@@ -0,0 +1,23 @@
+
+
+ EIC_Registry_TEST
+ 1
+ B05
+ 10X1001A1001A450
+ A40
+ 10X1001A1001A450
+ A41
+ 2024-01-01T00:00:00Z
+
+ 10X-TEST--EIC--D
+ A05
+ International
+ Test EIC With Duplicate Functions
+ TEST-EIC-D
+ 2024-01-01
+ 10XDE-ENBW-----N
+ GENERATION
+ LOAD
+ TEST_PARENT_D
+
+
diff --git a/tests/testthat/test-en_balancing.R b/tests/testthat/test-en_balancing.R
index 5f4b4222..c5ad5804 100644
--- a/tests/testthat/test-en_balancing.R
+++ b/tests/testthat/test-en_balancing.R
@@ -2,7 +2,7 @@ testthat::test_that(
desc = "elastic_demands() works",
code = {
testthat::expect_no_error(
- object = elastic_demands(
+ object = result_full <- elastic_demands(
eic = "10YCZ-CEPS-----N",
period_start = lubridate::ymd(
x = "2024-01-01",
@@ -16,13 +16,15 @@ testthat::test_that(
tidy_output = TRUE
),
message = "uses offsetting"
- ) |>
- testthat::expect_warning() |>
- testthat::expect_warning() |>
- testthat::expect_warning() |>
- testthat::expect_warning() |>
- testthat::expect_warning() |>
- testthat::expect_warning()
+ )
+ testthat::expect_contains(
+ object = names(result_full),
+ expected = c(
+ "bid_ts_mrid",
+ "bid_ts_auction_mrid",
+ "bid_ts_flow_direction"
+ )
+ )
testthat::expect_no_error(
object = elastic_demands(
eic = "10YCZ-CEPS-----N",
@@ -37,36 +39,7 @@ testthat::test_that(
),
tidy_output = TRUE
)
- ) |>
- testthat::expect_warning() |>
- testthat::expect_warning()
- testthat::expect_contains(
- object = elastic_demands(
- eic = "10YCZ-CEPS-----N",
- process_type = "A47",
- period_start = lubridate::ymd(
- x = "2024-01-01",
- tz = "CET"
- ),
- period_end = lubridate::ymd(
- x = "2024-12-01",
- tz = "CET"
- ),
- tidy_output = TRUE
- ) |>
- names(),
- expected = c(
- "bid_ts_mrid",
- "bid_ts_auction_mrid",
- "bid_ts_flow_direction"
- )
- ) |>
- testthat::expect_warning() |>
- testthat::expect_warning() |>
- testthat::expect_warning() |>
- testthat::expect_warning() |>
- testthat::expect_warning() |>
- testthat::expect_warning()
+ )
testthat::expect_error(
object = elastic_demands(
eic = NULL,
@@ -132,6 +105,38 @@ testthat::test_that(
),
info = "Valid security token should be provided!"
)
+ testthat::expect_error(
+ object = elastic_demands(
+ eic = "10YHU-MAVIR----U",
+ process_type = NULL,
+ period_start = lubridate::ymd(
+ x = "2020-02-01",
+ tz = "CET"
+ ),
+ period_end = lubridate::ymd(
+ x = "2020-03-01",
+ tz = "CET"
+ ),
+ tidy_output = TRUE
+ ),
+ regexp = "The 'process_type' should be 'A47' or 'A51'."
+ )
+ testthat::expect_error(
+ object = elastic_demands(
+ eic = "10YHU-MAVIR----U",
+ process_type = "INVALID",
+ period_start = lubridate::ymd(
+ x = "2020-02-01",
+ tz = "CET"
+ ),
+ period_end = lubridate::ymd(
+ x = "2020-03-01",
+ tz = "CET"
+ ),
+ tidy_output = TRUE
+ ),
+ regexp = "The 'process_type' should be 'A47' or 'A51'."
+ )
}
)
@@ -301,8 +306,7 @@ testthat::test_that(
),
tidy_output = TRUE
)
- ) |>
- testthat::expect_warning()
+ )
testthat::expect_contains(
object = exchanged_volumes(
eic = "10YCZ-CEPS-----N",
@@ -323,8 +327,7 @@ testthat::test_that(
"ts_acquiring_domain_mrid",
"ts_point_quantity"
)
- ) |>
- testthat::expect_warning()
+ )
testthat::expect_error(
object = exchanged_volumes(
eic = NULL,
@@ -398,22 +401,24 @@ testthat::test_that(
testthat::test_that(
desc = "balancing_border_cap_limit() works",
code = {
- testthat::expect_no_error(
- object = balancing_border_cap_limit(
- eic_in = "10YDE-RWENET---I",
- eic_out = "10YBE----------2",
- process_type = "A51",
- period_start = lubridate::ymd(
- x = "2024-01-01",
- tz = "CET"
- ),
- period_end = lubridate::ymd(
- x = "2024-01-02",
- tz = "CET"
- ),
- tidy_output = TRUE
+ for (pt in c("A47", "A51", "A63")) {
+ testthat::expect_no_error(
+ object = balancing_border_cap_limit(
+ eic_in = "10YDE-RWENET---I",
+ eic_out = "10YBE----------2",
+ process_type = "A51",
+ period_start = lubridate::ymd(
+ x = "2024-01-01",
+ tz = "CET"
+ ),
+ period_end = lubridate::ymd(
+ x = "2024-01-02",
+ tz = "CET"
+ ),
+ tidy_output = TRUE
+ )
)
- )
+ }
testthat::expect_error(
object = balancing_border_cap_limit(
eic_in = "10YDE-RWENET---I",
@@ -445,9 +450,7 @@ testthat::test_that(
),
tidy_output = TRUE
)
- ) |>
- testthat::expect_warning() |>
- testthat::expect_warning()
+ )
testthat::expect_no_error(
object = balancing_border_cap_limit(
eic_in = "10YDE-RWENET---I",
@@ -576,181 +579,1232 @@ testthat::test_that(
),
info = "One year range limit should be applied!"
)
+ testthat::expect_error(
+ object = balancing_border_cap_limit(
+ eic_in = NULL,
+ eic_out = "10YBE----------2",
+ process_type = "A51",
+ period_start = lubridate::ymd(x = "2024-01-01", tz = "CET"),
+ period_end = lubridate::ymd(x = "2024-01-02", tz = "CET"),
+ tidy_output = TRUE
+ ),
+ regexp = "One 'in' control area EIC should be provided"
+ )
+ testthat::expect_error(
+ object = balancing_border_cap_limit(
+ eic_in = "10YDE-RWENET---I",
+ eic_out = NULL,
+ process_type = "A51",
+ period_start = lubridate::ymd(x = "2024-01-01", tz = "CET"),
+ period_end = lubridate::ymd(x = "2024-01-02", tz = "CET"),
+ tidy_output = TRUE
+ ),
+ regexp = "One 'out' control area EIC should be provided"
+ )
}
)
-# testthat::test_that(
-# desc = "balancing_accepted_aggr_offers() works",
-# code = {
-# testthat::expect_no_error(
-# object = balancing_accepted_aggr_offers(
-# eic = "10YHU-MAVIR----U",
-# period_start = lubridate::ymd(
-# x = "2020-02-01",
-# tz = "CET"
-# ),
-# period_end = lubridate::ymd(
-# x = "2020-03-01",
-# tz = "CET"
-# ),
-# reserve_type = "A96",
-# tidy_output = TRUE
-# )
-# )
-# testthat::expect_error(
-# object = balancing_accepted_aggr_offers(
-# eic = NULL,
-# period_start = lubridate::ymd(
-# x = "2020-02-01",
-# tz = "CET"
-# ),
-# period_end = lubridate::ymd(
-# x = "2020-03-01",
-# tz = "CET"
-# ),
-# reserve_type = "A96",
-# tidy_output = TRUE
-# ),
-# info = "One control area EIC should be provided!"
-# )
-# testthat::expect_error(
-# object = balancing_accepted_aggr_offers(
-# eic = c("10YHU-MAVIR----U", "10Y1001A1001A83F"),
-# period_start = lubridate::ymd(
-# x = "2020-02-01",
-# tz = "CET"
-# ),
-# period_end = lubridate::ymd(
-# x = "2020-03-01",
-# tz = "CET"
-# ),
-# reserve_type = "A96",
-# tidy_output = TRUE
-# ),
-# info = "This wrapper only supports one control area EIC per request!"
-# )
-# testthat::expect_error(
-# object = balancing_accepted_aggr_offers(
-# eic = "10YHU-MAVIR----U",
-# period_start = lubridate::ymd(
-# x = "2020-02-01",
-# tz = "CET"
-# ),
-# period_end = lubridate::ymd(
-# x = "2021-03-01",
-# tz = "CET"
-# ),
-# reserve_type = "A96",
-# tidy_output = TRUE
-# ),
-# info = "One year range limit should be applied!"
-# )
-# testthat::expect_error(
-# object = balancing_accepted_aggr_offers(
-# eic = "10YHU-MAVIR----U",
-# period_start = lubridate::ymd(
-# x = "2020-02-01",
-# tz = "CET"
-# ),
-# period_end = lubridate::ymd(
-# x = "2020-03-01",
-# tz = "CET"
-# ),
-# reserve_type = "A96",
-# tidy_output = TRUE,
-# security_token = ""
-# ),
-# info = "Valid security token should be provided!"
-# )
-# }
-# )
+testthat::test_that(
+ desc = "exchanged_volumes_per_border() works",
+ code = {
+ testthat::expect_no_error(
+ object = exchanged_volumes_per_border(
+ acquiring_eic = "10YCZ-CEPS-----N",
+ connecting_eic = "10YSK-SEPS-----K",
+ process_type = "A51",
+ period_start = lubridate::ymd(x = "2024-01-01", tz = "CET"),
+ period_end = lubridate::ymd(x = "2024-01-02", tz = "CET"),
+ tidy_output = TRUE
+ )
+ )
+ testthat::expect_error(
+ object = exchanged_volumes_per_border(
+ acquiring_eic = NULL,
+ connecting_eic = "10YSK-SEPS-----K",
+ process_type = "A51",
+ period_start = lubridate::ymd(x = "2024-01-01", tz = "CET"),
+ period_end = lubridate::ymd(x = "2024-01-02", tz = "CET"),
+ tidy_output = TRUE
+ ),
+ regexp = "One acquiring EIC should be provided"
+ )
+ testthat::expect_error(
+ object = exchanged_volumes_per_border(
+ acquiring_eic = c("10YCZ-CEPS-----N", "10YDE-VE-------2"),
+ connecting_eic = "10YSK-SEPS-----K",
+ process_type = "A51",
+ period_start = lubridate::ymd(x = "2024-01-01", tz = "CET"),
+ period_end = lubridate::ymd(x = "2024-01-02", tz = "CET"),
+ tidy_output = TRUE
+ ),
+ regexp = "This wrapper only supports one acquiring EIC per request"
+ )
+ testthat::expect_error(
+ object = exchanged_volumes_per_border(
+ acquiring_eic = "10YCZ-CEPS-----N",
+ connecting_eic = "10YSK-SEPS-----K",
+ process_type = "INVALID",
+ period_start = lubridate::ymd(x = "2024-01-01", tz = "CET"),
+ period_end = lubridate::ymd(x = "2024-01-02", tz = "CET"),
+ tidy_output = TRUE
+ ),
+ info = "The 'process_type' should be 'A51', 'A60' or 'A61'."
+ )
+ testthat::expect_error(
+ object = exchanged_volumes_per_border(
+ acquiring_eic = "10YCZ-CEPS-----N",
+ connecting_eic = "10YSK-SEPS-----K",
+ process_type = "A51",
+ period_start = lubridate::ymd(x = "2024-01-01", tz = "CET"),
+ period_end = lubridate::ymd(x = "2024-01-05", tz = "CET"),
+ tidy_output = TRUE
+ ),
+ regexp = "One day range limit should be applied"
+ )
+ testthat::expect_error(
+ object = exchanged_volumes_per_border(
+ acquiring_eic = "10YCZ-CEPS-----N",
+ connecting_eic = "10YSK-SEPS-----K",
+ process_type = "A51",
+ period_start = lubridate::ymd(x = "2024-01-01", tz = "CET"),
+ period_end = lubridate::ymd(x = "2024-01-02", tz = "CET"),
+ tidy_output = TRUE,
+ security_token = ""
+ ),
+ info = "Valid security token should be provided."
+ )
+ testthat::expect_error(
+ object = exchanged_volumes_per_border(
+ acquiring_eic = "10YCZ-CEPS-----N",
+ connecting_eic = NULL,
+ process_type = "A51",
+ period_start = lubridate::ymd(x = "2024-01-01", tz = "CET"),
+ period_end = lubridate::ymd(x = "2024-01-02", tz = "CET"),
+ tidy_output = TRUE
+ ),
+ regexp = "One connecting EIC should be provided"
+ )
+ testthat::expect_error(
+ object = exchanged_volumes_per_border(
+ acquiring_eic = "10YCZ-CEPS-----N",
+ connecting_eic = c("10YSK-SEPS-----K", "10YDE-VE-------2"),
+ process_type = "A51",
+ period_start = lubridate::ymd(x = "2024-01-01", tz = "CET"),
+ period_end = lubridate::ymd(x = "2024-01-02", tz = "CET"),
+ tidy_output = TRUE
+ ),
+ regexp = "This wrapper only supports one connecting EIC per request"
+ )
+ }
+)
-# testthat::test_that(
-# desc = "balancing_activated_reserves() works",
-# code = {
-# testthat::expect_no_error(
-# object = balancing_activated_reserves(
-# eic = "10YHU-MAVIR----U",
-# period_start = lubridate::ymd(
-# x = "2020-02-01",
-# tz = "CET"
-# ),
-# period_end = lubridate::ymd(
-# x = "2020-03-01",
-# tz = "CET"
-# ),
-# reserve_type = "A96",
-# tidy_output = TRUE
-# )
-# )
-# testthat::expect_error(
-# object = balancing_activated_reserves(
-# eic = NULL,
-# period_start = lubridate::ymd(
-# x = "2020-02-01",
-# tz = "CET"
-# ),
-# period_end = lubridate::ymd(
-# x = "2020-03-01",
-# tz = "CET"
-# ),
-# reserve_type = "A96",
-# tidy_output = TRUE
-# ),
-# info = "One control area EIC should be provided!"
+testthat::test_that(
+ desc = "hvdc_link_constrains() works",
+ code = {
+ testthat::expect_no_error(
+ object = hvdc_link_constrains(
+ eic_in = "10YDK-1--------W",
+ eic_out = "10YNL----------L",
+ period_start = lubridate::ymd(x = "2021-01-01", tz = "CET"),
+ period_end = lubridate::ymd(x = "2021-01-02", tz = "CET"),
+ tidy_output = TRUE
+ )
+ )
+ testthat::expect_error(
+ object = hvdc_link_constrains(
+ eic_in = NULL,
+ eic_out = "10YDE-RWENET---I",
+ period_start = lubridate::ymd(x = "2022-01-01", tz = "CET"),
+ period_end = lubridate::ymd(x = "2022-01-02", tz = "CET"),
+ tidy_output = TRUE
+ ),
+ regexp = "One 'in' domain EIC should be provided"
+ )
+ testthat::expect_error(
+ object = hvdc_link_constrains(
+ eic_in = "10YAT-APG------L",
+ eic_out = NULL,
+ period_start = lubridate::ymd(x = "2022-01-01", tz = "CET"),
+ period_end = lubridate::ymd(x = "2022-01-02", tz = "CET"),
+ tidy_output = TRUE
+ ),
+ regexp = "One 'out' domain EIC should be provided"
+ )
+ testthat::expect_error(
+ object = hvdc_link_constrains(
+ eic_in = c("10YAT-APG------L", "10YDE-VE-------2"),
+ eic_out = "10YDE-RWENET---I",
+ period_start = lubridate::ymd(x = "2022-01-01", tz = "CET"),
+ period_end = lubridate::ymd(x = "2022-01-02", tz = "CET"),
+ tidy_output = TRUE
+ ),
+ regexp = "This wrapper only supports one in and one out EIC per request"
+ )
+ testthat::expect_error(
+ object = hvdc_link_constrains(
+ eic_in = "10YAT-APG------L",
+ eic_out = "10YDE-RWENET---I",
+ period_start = lubridate::ymd(x = "2022-01-01", tz = "CET"),
+ period_end = lubridate::ymd(x = "2023-05-01", tz = "CET"),
+ tidy_output = TRUE
+ ),
+ regexp = "One year range limit should be applied"
+ )
+ testthat::expect_error(
+ object = hvdc_link_constrains(
+ eic_in = "10YAT-APG------L",
+ eic_out = "10YDE-RWENET---I",
+ period_start = lubridate::ymd(x = "2022-01-01", tz = "CET"),
+ period_end = lubridate::ymd(x = "2022-01-02", tz = "CET"),
+ tidy_output = TRUE,
+ security_token = ""
+ ),
+ regexp = "Valid security token should be provided"
+ )
+ testthat::expect_error(
+ object = hvdc_link_constrains(
+ eic_in = "10YAT-APG------L",
+ eic_out = "10YDE-RWENET---I",
+ eic_ic = c("AAAA", "BBBB"),
+ period_start = lubridate::ymd(x = "2022-01-01", tz = "CET"),
+ period_end = lubridate::ymd(x = "2022-01-02", tz = "CET"),
+ tidy_output = TRUE
+ ),
+ regexp = "This wrapper only supports one interconnector EIC per request"
+ )
+ testthat::expect_error(
+ object = hvdc_link_constrains(
+ eic_in = "10YAT-APG------L",
+ eic_out = "10YDE-RWENET---I",
+ process_type = "INVALID",
+ period_start = lubridate::ymd(x = "2022-01-01", tz = "CET"),
+ period_end = lubridate::ymd(x = "2022-01-02", tz = "CET"),
+ tidy_output = TRUE
+ ),
+ regexp = "The 'process_type' should be 'A47', 'A51' or 'A63'"
+ )
+ }
+)
+
+
+
+testthat::test_that(
+ desc = "changes_to_bid_availability() works",
+ code = {
+ for (bt in paste0("C", 40L:46L)) {
+ testthat::expect_no_error(
+ object = changes_to_bid_availability(
+ eic = "10YCZ-CEPS-----N",
+ business_type = bt,
+ period_start = lubridate::ymd(x = "2023-09-24", tz = "CET"),
+ period_end = lubridate::ymd(x = "2023-09-25", tz = "CET"),
+ tidy_output = TRUE
+ ),
+ message = bt
+ )
+ }
+ testthat::expect_no_error(
+ object = changes_to_bid_availability(
+ eic = "10YCZ-CEPS-----N",
+ period_start = lubridate::ymd(x = "2023-09-24", tz = "CET"),
+ period_end = lubridate::ymd(x = "2023-09-25", tz = "CET"),
+ tidy_output = TRUE
+ )
+ )
+ testthat::expect_error(
+ object = changes_to_bid_availability(
+ eic = NULL,
+ period_start = lubridate::ymd(x = "2024-01-01", tz = "CET"),
+ period_end = lubridate::ymd(x = "2024-01-02", tz = "CET"),
+ tidy_output = TRUE
+ ),
+ regexp = "One control area EIC should be provided"
+ )
+ testthat::expect_error(
+ object = changes_to_bid_availability(
+ eic = c("10YCZ-CEPS-----N", "10YDE-VE-------2"),
+ period_start = lubridate::ymd(x = "2024-01-01", tz = "CET"),
+ period_end = lubridate::ymd(x = "2024-01-02", tz = "CET"),
+ tidy_output = TRUE
+ ),
+ regexp = "This wrapper only supports one control area EIC per request"
+ )
+ testthat::expect_error(
+ object = changes_to_bid_availability(
+ eic = "10YCZ-CEPS-----N",
+ business_type = "INVALID",
+ period_start = lubridate::ymd(x = "2024-01-01", tz = "CET"),
+ period_end = lubridate::ymd(x = "2024-01-02", tz = "CET"),
+ tidy_output = TRUE
+ ),
+ regexp = paste(
+ "The 'business_type' should be 'C40', 'C41', 'C42',",
+ "'C43', 'C44', 'C45', 'C46'"
+ )
+ )
+ testthat::expect_error(
+ object = changes_to_bid_availability(
+ eic = "10YCZ-CEPS-----N",
+ period_start = lubridate::ymd(x = "2024-01-01", tz = "CET"),
+ period_end = lubridate::ymd(x = "2024-01-02", tz = "CET"),
+ tidy_output = TRUE,
+ security_token = ""
+ ),
+ regexp = "Valid security token should be provided"
+ )
+ testthat::expect_error(
+ object = changes_to_bid_availability(
+ eic = "10YCZ-CEPS-----N",
+ period_start = lubridate::ymd(x = "2024-01-01", tz = "CET"),
+ period_end = lubridate::ymd(x = "2025-05-01", tz = "CET"),
+ tidy_output = TRUE
+ ),
+ regexp = "One year range limit should be applied"
+ )
+ }
+)
+
+
+
+testthat::test_that(
+ desc = "current_balancing_state() works",
+ code = {
+ testthat::expect_no_error(
+ object = current_balancing_state(
+ eic = "10YCZ-CEPS-----N",
+ period_start = lubridate::ymd(x = "2024-01-01", tz = "CET"),
+ period_end = lubridate::ymd(x = "2024-01-02", tz = "CET"),
+ tidy_output = TRUE
+ )
+ )
+ testthat::expect_error(
+ object = current_balancing_state(
+ eic = NULL,
+ period_start = lubridate::ymd(x = "2024-01-01", tz = "CET"),
+ period_end = lubridate::ymd(x = "2024-01-02", tz = "CET"),
+ tidy_output = TRUE
+ ),
+ info = "One control area EIC should be provided."
+ )
+ testthat::expect_error(
+ object = current_balancing_state(
+ eic = c("10YCZ-CEPS-----N", "10YDE-VE-------2"),
+ period_start = lubridate::ymd(x = "2024-01-01", tz = "CET"),
+ period_end = lubridate::ymd(x = "2024-01-02", tz = "CET"),
+ tidy_output = TRUE
+ ),
+ info = "This wrapper only supports one control area EIC per request."
+ )
+ testthat::expect_error(
+ object = current_balancing_state(
+ eic = "10YCZ-CEPS-----N",
+ period_start = lubridate::ymd(x = "2024-01-01", tz = "CET"),
+ period_end = lubridate::ymd(x = "2024-06-01", tz = "CET"),
+ tidy_output = TRUE
+ ),
+ info = "100 day range limit should be applied!"
+ )
+ testthat::expect_error(
+ object = current_balancing_state(
+ eic = "10YCZ-CEPS-----N",
+ period_start = lubridate::ymd(x = "2024-01-01", tz = "CET"),
+ period_end = lubridate::ymd(x = "2024-01-02", tz = "CET"),
+ tidy_output = TRUE,
+ security_token = ""
+ ),
+ info = "Valid security token should be provided."
+ )
+ }
+)
+
+
+
+testthat::test_that(
+ desc = "balancing_energy_bids() works",
+ code = {
+ testthat::expect_no_error(
+ object = balancing_energy_bids(
+ eic = "10YCZ-CEPS-----N",
+ period_start = lubridate::ymd(x = "2024-01-01", tz = "CET"),
+ period_end = lubridate::ymd(x = "2025-01-01", tz = "CET"),
+ tidy_output = TRUE
+ )
+ )
+ testthat::expect_error(
+ object = balancing_energy_bids(
+ eic = NULL,
+ period_start = lubridate::ymd(x = "2024-01-01", tz = "CET"),
+ period_end = lubridate::ymd(x = "2024-01-02", tz = "CET"),
+ tidy_output = TRUE
+ ),
+ info = "One connecting domain EIC should be provided."
+ )
+ testthat::expect_error(
+ object = balancing_energy_bids(
+ eic = c("10YCZ-CEPS-----N", "10YDE-VE-------2"),
+ period_start = lubridate::ymd(x = "2024-01-01", tz = "CET"),
+ period_end = lubridate::ymd(x = "2024-01-02", tz = "CET"),
+ tidy_output = TRUE
+ ),
+ info = "This wrapper only supports one connecting domain EIC per request."
+ )
+ testthat::expect_error(
+ object = balancing_energy_bids(
+ eic = "10YCZ-CEPS-----N",
+ period_start = lubridate::ymd(x = "2024-01-01", tz = "CET"),
+ period_end = lubridate::ymd(x = "2024-01-02", tz = "CET"),
+ tidy_output = TRUE,
+ security_token = ""
+ ),
+ info = "Valid security token should be provided."
+ )
+ }
+)
+
+
+
+testthat::test_that(
+ desc = "aggregated_balancing_energy_bids() works",
+ code = {
+ testthat::expect_no_error(
+ object = aggregated_balancing_energy_bids(
+ eic = "10YCZ-CEPS-----N",
+ process_type = "A51",
+ period_start = lubridate::ymd(x = "2024-01-01", tz = "CET"),
+ period_end = lubridate::ymd(x = "2024-01-02", tz = "CET"),
+ tidy_output = TRUE
+ )
+ )
+ testthat::expect_error(
+ object = aggregated_balancing_energy_bids(
+ eic = NULL,
+ process_type = "A51",
+ period_start = lubridate::ymd(x = "2024-01-01", tz = "CET"),
+ period_end = lubridate::ymd(x = "2024-01-02", tz = "CET"),
+ tidy_output = TRUE
+ ),
+ info = "One control area EIC should be provided."
+ )
+ testthat::expect_error(
+ object = aggregated_balancing_energy_bids(
+ eic = c("10YCZ-CEPS-----N", "10YDE-VE-------2"),
+ process_type = "A51",
+ period_start = lubridate::ymd(x = "2024-01-01", tz = "CET"),
+ period_end = lubridate::ymd(x = "2024-01-02", tz = "CET"),
+ tidy_output = TRUE
+ ),
+ info = "This wrapper only supports one control area EIC per request."
+ )
+ testthat::expect_error(
+ object = aggregated_balancing_energy_bids(
+ eic = "10YCZ-CEPS-----N",
+ process_type = "INVALID",
+ period_start = lubridate::ymd(x = "2024-01-01", tz = "CET"),
+ period_end = lubridate::ymd(x = "2024-01-02", tz = "CET"),
+ tidy_output = TRUE
+ ),
+ info = "The 'process_type' should be 'A51', 'A46', 'A47', 'A60' or 'A61'."
+ )
+ testthat::expect_error(
+ object = aggregated_balancing_energy_bids(
+ eic = "10YCZ-CEPS-----N",
+ process_type = "A51",
+ period_start = lubridate::ymd(x = "2024-01-01", tz = "CET"),
+ period_end = lubridate::ymd(x = "2025-05-01", tz = "CET"),
+ tidy_output = TRUE
+ ),
+ info = "One year range limit should be applied!"
+ )
+ testthat::expect_error(
+ object = aggregated_balancing_energy_bids(
+ eic = "10YCZ-CEPS-----N",
+ process_type = "A51",
+ period_start = lubridate::ymd(x = "2024-01-01", tz = "CET"),
+ period_end = lubridate::ymd(x = "2024-01-02", tz = "CET"),
+ tidy_output = TRUE,
+ security_token = ""
+ ),
+ info = "Valid security token should be provided."
+ )
+ }
+)
+
+
+
+testthat::test_that(
+ desc = "procured_balancing_capacity() works",
+ code = {
+ testthat::expect_no_error(
+ object = procured_balancing_capacity(
+ eic = "10YCZ-CEPS-----N",
+ process_type = "A51",
+ period_start = lubridate::ymd(x = "2024-01-01", tz = "CET"),
+ period_end = lubridate::ymd(x = "2024-01-02", tz = "CET"),
+ tidy_output = TRUE
+ )
+ )
+ testthat::expect_error(
+ object = procured_balancing_capacity(
+ eic = NULL,
+ process_type = "A51",
+ period_start = lubridate::ymd(x = "2024-01-01", tz = "CET"),
+ period_end = lubridate::ymd(x = "2024-01-02", tz = "CET"),
+ tidy_output = TRUE
+ ),
+ info = "One control area EIC should be provided."
+ )
+ testthat::expect_error(
+ object = procured_balancing_capacity(
+ eic = c("10YCZ-CEPS-----N", "10YDE-VE-------2"),
+ process_type = "A51",
+ period_start = lubridate::ymd(x = "2024-01-01", tz = "CET"),
+ period_end = lubridate::ymd(x = "2024-01-02", tz = "CET"),
+ tidy_output = TRUE
+ ),
+ info = "This wrapper only supports one control area EIC per request."
+ )
+ testthat::expect_error(
+ object = procured_balancing_capacity(
+ eic = "10YCZ-CEPS-----N",
+ process_type = "INVALID",
+ period_start = lubridate::ymd(x = "2024-01-01", tz = "CET"),
+ period_end = lubridate::ymd(x = "2024-01-02", tz = "CET"),
+ tidy_output = TRUE
+ ),
+ info = "The 'process_type' should be 'A51', 'A52' or 'A47'."
+ )
+ testthat::expect_error(
+ object = procured_balancing_capacity(
+ eic = "10YCZ-CEPS-----N",
+ process_type = "A51",
+ type_market_agreement = c("A01", "A13"),
+ period_start = lubridate::ymd(x = "2024-01-01", tz = "CET"),
+ period_end = lubridate::ymd(x = "2024-01-02", tz = "CET"),
+ tidy_output = TRUE
+ ),
+ info = "None or one 'type_market_agreement' should be provided."
+ )
+ testthat::expect_error(
+ object = procured_balancing_capacity(
+ eic = "10YCZ-CEPS-----N",
+ process_type = "A51",
+ period_start = lubridate::ymd(x = "2024-01-01", tz = "CET"),
+ period_end = lubridate::ymd(x = "2024-01-02", tz = "CET"),
+ tidy_output = TRUE,
+ security_token = ""
+ ),
+ info = "Valid security token should be provided."
+ )
+ testthat::expect_no_error(
+ object = procured_balancing_capacity(
+ eic = "10YCZ-CEPS-----N",
+ process_type = "A51",
+ type_market_agreement = "A01",
+ period_start = lubridate::ymd(x = "2024-01-01", tz = "CET"),
+ period_end = lubridate::ymd(x = "2024-01-02", tz = "CET"),
+ tidy_output = TRUE
+ )
+ )
+ }
+)
+
+
+
+testthat::test_that(
+ desc = "allocation_of_cross_zonal_balancing_cap() works",
+ code = {
+ testthat::expect_no_error(
+ object = allocation_of_cross_zonal_balancing_cap(
+ eic_acquiring = "10YAT-APG------L",
+ eic_connecting = "10YCH-SWISSGRIDZ",
+ period_start = lubridate::ymd(x = "2024-01-01", tz = "CET"),
+ period_end = lubridate::ymd(x = "2024-01-02", tz = "CET"),
+ tidy_output = TRUE
+ )
+ )
+ testthat::expect_error(
+ object = allocation_of_cross_zonal_balancing_cap(
+ eic_acquiring = NULL,
+ eic_connecting = "10YCH-SWISSGRIDZ",
+ period_start = lubridate::ymd(x = "2024-01-01", tz = "CET"),
+ period_end = lubridate::ymd(x = "2024-01-02", tz = "CET"),
+ tidy_output = TRUE
+ ),
+ info = "One acquiring domain EIC should be provided."
+ )
+ testthat::expect_error(
+ object = allocation_of_cross_zonal_balancing_cap(
+ eic_acquiring = "10YAT-APG------L",
+ eic_connecting = NULL,
+ period_start = lubridate::ymd(x = "2024-01-01", tz = "CET"),
+ period_end = lubridate::ymd(x = "2024-01-02", tz = "CET"),
+ tidy_output = TRUE
+ ),
+ info = "One connecting domain EIC should be provided."
+ )
+ testthat::expect_error(
+ object = allocation_of_cross_zonal_balancing_cap(
+ eic_acquiring = c("10YAT-APG------L", "10YDE-VE-------2"),
+ eic_connecting = "10YCH-SWISSGRIDZ",
+ period_start = lubridate::ymd(x = "2024-01-01", tz = "CET"),
+ period_end = lubridate::ymd(x = "2024-01-02", tz = "CET"),
+ tidy_output = TRUE
+ ),
+ info = paste(
+ "This wrapper only supports one acquiring and",
+ "one connecting EIC per request."
+ )
+ )
+ testthat::expect_error(
+ object = allocation_of_cross_zonal_balancing_cap(
+ eic_acquiring = "10YAT-APG------L",
+ eic_connecting = "10YCH-SWISSGRIDZ",
+ type_market_agreement = c("A01", "A13"),
+ period_start = lubridate::ymd(x = "2024-01-01", tz = "CET"),
+ period_end = lubridate::ymd(x = "2024-01-02", tz = "CET"),
+ tidy_output = TRUE
+ ),
+ info = "None or one 'type_market_agreement' should be provided."
+ )
+ testthat::expect_error(
+ object = allocation_of_cross_zonal_balancing_cap(
+ eic_acquiring = "10YAT-APG------L",
+ eic_connecting = "10YCH-SWISSGRIDZ",
+ period_start = lubridate::ymd(x = "2024-01-01", tz = "CET"),
+ period_end = lubridate::ymd(x = "2024-01-02", tz = "CET"),
+ tidy_output = TRUE,
+ security_token = ""
+ ),
+ info = "Valid security token should be provided."
+ )
+ testthat::expect_no_error(
+ object = allocation_of_cross_zonal_balancing_cap(
+ eic_acquiring = "10YAT-APG------L",
+ eic_connecting = "10YCH-SWISSGRIDZ",
+ type_market_agreement = "A01",
+ period_start = lubridate::ymd(x = "2024-01-01", tz = "CET"),
+ period_end = lubridate::ymd(x = "2024-01-02", tz = "CET"),
+ tidy_output = TRUE
+ )
+ )
+ }
+)
+
+
+
+testthat::test_that(
+ desc = "contracted_reserves() works",
+ code = {
+ testthat::expect_no_error(
+ object = contracted_reserves(
+ eic = "10YCZ-CEPS-----N",
+ type_market_agreement = "A13",
+ period_start = lubridate::ymd(x = "2022-01-01", tz = "CET"),
+ period_end = lubridate::ymd(x = "2022-01-02", tz = "CET"),
+ tidy_output = TRUE
+ )
+ )
+ testthat::expect_error(
+ object = contracted_reserves(
+ eic = NULL,
+ type_market_agreement = "A13",
+ period_start = lubridate::ymd(x = "2022-01-01", tz = "CET"),
+ period_end = lubridate::ymd(x = "2022-01-02", tz = "CET"),
+ tidy_output = TRUE
+ ),
+ info = "One control area EIC should be provided."
+ )
+ testthat::expect_error(
+ object = contracted_reserves(
+ eic = c("10YCZ-CEPS-----N", "10YDE-VE-------2"),
+ type_market_agreement = "A13",
+ period_start = lubridate::ymd(x = "2022-01-01", tz = "CET"),
+ period_end = lubridate::ymd(x = "2022-01-02", tz = "CET"),
+ tidy_output = TRUE
+ ),
+ info = "This wrapper only supports one control area EIC per request."
+ )
+ testthat::expect_error(
+ object = contracted_reserves(
+ eic = "10YCZ-CEPS-----N",
+ type_market_agreement = NULL,
+ period_start = lubridate::ymd(x = "2022-01-01", tz = "CET"),
+ period_end = lubridate::ymd(x = "2022-01-02", tz = "CET"),
+ tidy_output = TRUE
+ ),
+ info = "A 'type_market_agreement' value should be provided."
+ )
+ testthat::expect_error(
+ object = contracted_reserves(
+ eic = "10YCZ-CEPS-----N",
+ type_market_agreement = c("A01", "A13"),
+ period_start = lubridate::ymd(x = "2022-01-01", tz = "CET"),
+ period_end = lubridate::ymd(x = "2022-01-02", tz = "CET"),
+ tidy_output = TRUE
+ ),
+ info = "Only one 'type_market_agreement' value should be provided."
+ )
+ testthat::expect_error(
+ object = contracted_reserves(
+ eic = "10YCZ-CEPS-----N",
+ type_market_agreement = "A13",
+ period_start = lubridate::ymd(x = "2022-01-01", tz = "CET"),
+ period_end = lubridate::ymd(x = "2022-01-02", tz = "CET"),
+ tidy_output = TRUE,
+ security_token = ""
+ ),
+ info = "Valid security token should be provided."
+ )
+ testthat::expect_no_error(
+ object = contracted_reserves(
+ eic = "10YCZ-CEPS-----N",
+ type_market_agreement = "A13",
+ process_type = "A51",
+ period_start = lubridate::ymd(x = "2022-01-01", tz = "CET"),
+ period_end = lubridate::ymd(x = "2022-01-02", tz = "CET"),
+ tidy_output = TRUE
+ )
+ )
+ testthat::expect_no_error(
+ object = contracted_reserves(
+ eic = "10YCZ-CEPS-----N",
+ type_market_agreement = "A13",
+ psr_type = "A04",
+ period_start = lubridate::ymd(x = "2022-01-01", tz = "CET"),
+ period_end = lubridate::ymd(x = "2022-01-02", tz = "CET"),
+ tidy_output = TRUE
+ )
+ )
+ }
+)
+
+
+
+testthat::test_that(
+ desc = "activated_balancing_prices() works",
+ code = {
+ testthat::expect_no_error(
+ object = activated_balancing_prices(
+ eic = "10YCZ-CEPS-----N",
+ period_start = lubridate::ymd(x = "2024-01-01", tz = "CET"),
+ period_end = lubridate::ymd(x = "2024-01-02", tz = "CET"),
+ tidy_output = TRUE
+ )
+ )
+ testthat::expect_error(
+ object = activated_balancing_prices(
+ eic = NULL,
+ period_start = lubridate::ymd(x = "2024-01-01", tz = "CET"),
+ period_end = lubridate::ymd(x = "2024-01-02", tz = "CET"),
+ tidy_output = TRUE
+ ),
+ info = "One control area EIC should be provided."
+ )
+ testthat::expect_error(
+ object = activated_balancing_prices(
+ eic = c("10YCZ-CEPS-----N", "10YDE-VE-------2"),
+ period_start = lubridate::ymd(x = "2024-01-01", tz = "CET"),
+ period_end = lubridate::ymd(x = "2024-01-02", tz = "CET"),
+ tidy_output = TRUE
+ ),
+ info = "This wrapper only supports one control area EIC per request."
+ )
+ testthat::expect_error(
+ object = activated_balancing_prices(
+ eic = "10YCZ-CEPS-----N",
+ period_start = lubridate::ymd(x = "2024-01-01", tz = "CET"),
+ period_end = lubridate::ymd(x = "2025-05-01", tz = "CET"),
+ tidy_output = TRUE
+ ),
+ info = "One year range limit should be applied!"
+ )
+ testthat::expect_error(
+ object = activated_balancing_prices(
+ eic = "10YCZ-CEPS-----N",
+ period_start = lubridate::ymd(x = "2024-01-01", tz = "CET"),
+ period_end = lubridate::ymd(x = "2024-01-02", tz = "CET"),
+ tidy_output = TRUE,
+ security_token = ""
+ ),
+ info = "Valid security token should be provided."
+ )
+ }
+)
+
+
+
+testthat::test_that(
+ desc = "imbalance_prices() works",
+ code = {
+ testthat::expect_no_error(
+ object = imbalance_prices(
+ eic = "10YCZ-CEPS-----N",
+ period_start = lubridate::ymd(x = "2024-01-01", tz = "CET"),
+ period_end = lubridate::ymd(x = "2024-01-02", tz = "CET"),
+ tidy_output = TRUE
+ )
+ )
+ testthat::expect_error(
+ object = imbalance_prices(
+ eic = NULL,
+ period_start = lubridate::ymd(x = "2024-01-01", tz = "CET"),
+ period_end = lubridate::ymd(x = "2024-01-02", tz = "CET"),
+ tidy_output = TRUE
+ ),
+ info = "One control area EIC should be provided."
+ )
+ testthat::expect_error(
+ object = imbalance_prices(
+ eic = c("10YCZ-CEPS-----N", "10YDE-VE-------2"),
+ period_start = lubridate::ymd(x = "2024-01-01", tz = "CET"),
+ period_end = lubridate::ymd(x = "2024-01-02", tz = "CET"),
+ tidy_output = TRUE
+ ),
+ info = "This wrapper only supports one control area EIC per request."
+ )
+ testthat::expect_error(
+ object = imbalance_prices(
+ eic = "10YCZ-CEPS-----N",
+ period_start = lubridate::ymd(x = "2024-01-01", tz = "CET"),
+ period_end = lubridate::ymd(x = "2025-05-01", tz = "CET"),
+ tidy_output = TRUE
+ ),
+ info = "One year range limit should be applied!"
+ )
+ testthat::expect_error(
+ object = imbalance_prices(
+ eic = "10YCZ-CEPS-----N",
+ period_start = lubridate::ymd(x = "2024-01-01", tz = "CET"),
+ period_end = lubridate::ymd(x = "2024-01-02", tz = "CET"),
+ tidy_output = TRUE,
+ security_token = ""
+ ),
+ info = "Valid security token should be provided."
+ )
+ }
+)
+
+
+
+testthat::test_that(
+ desc = "imbalance_volumes() works",
+ code = {
+ testthat::expect_no_error(
+ object = imbalance_volumes(
+ eic = "10YCZ-CEPS-----N",
+ period_start = lubridate::ymd(x = "2024-01-01", tz = "CET"),
+ period_end = lubridate::ymd(x = "2024-01-02", tz = "CET"),
+ tidy_output = TRUE
+ )
+ )
+ testthat::expect_error(
+ object = imbalance_volumes(
+ eic = NULL,
+ period_start = lubridate::ymd(x = "2024-01-01", tz = "CET"),
+ period_end = lubridate::ymd(x = "2024-01-02", tz = "CET"),
+ tidy_output = TRUE
+ ),
+ info = "One control area EIC should be provided."
+ )
+ testthat::expect_error(
+ object = imbalance_volumes(
+ eic = c("10YCZ-CEPS-----N", "10YDE-VE-------2"),
+ period_start = lubridate::ymd(x = "2024-01-01", tz = "CET"),
+ period_end = lubridate::ymd(x = "2024-01-02", tz = "CET"),
+ tidy_output = TRUE
+ ),
+ info = "This wrapper only supports one control area EIC per request."
+ )
+ testthat::expect_error(
+ object = imbalance_volumes(
+ eic = "10YCZ-CEPS-----N",
+ period_start = lubridate::ymd(x = "2024-01-01", tz = "CET"),
+ period_end = lubridate::ymd(x = "2025-05-01", tz = "CET"),
+ tidy_output = TRUE
+ ),
+ info = "One year range limit should be applied!"
+ )
+ testthat::expect_error(
+ object = imbalance_volumes(
+ eic = "10YCZ-CEPS-----N",
+ period_start = lubridate::ymd(x = "2024-01-01", tz = "CET"),
+ period_end = lubridate::ymd(x = "2024-01-02", tz = "CET"),
+ tidy_output = TRUE,
+ security_token = ""
+ ),
+ info = "Valid security token should be provided."
+ )
+ }
+)
+
+
+
+testthat::test_that(
+ desc = "financial_expenses_and_income_for_balancing() works",
+ code = {
+ testthat::expect_no_error(
+ object = financial_expenses_and_income_for_balancing(
+ eic = "10YCZ-CEPS-----N",
+ period_start = lubridate::ymd(x = "2022-01-01", tz = "CET"),
+ period_end = lubridate::ymd(x = "2022-01-02", tz = "CET"),
+ tidy_output = TRUE
+ )
+ )
+ testthat::expect_error(
+ object = financial_expenses_and_income_for_balancing(
+ eic = NULL,
+ period_start = lubridate::ymd(x = "2022-01-01", tz = "CET"),
+ period_end = lubridate::ymd(x = "2022-01-02", tz = "CET"),
+ tidy_output = TRUE
+ ),
+ info = "One control area EIC should be provided."
+ )
+ testthat::expect_error(
+ object = financial_expenses_and_income_for_balancing(
+ eic = c("10YCZ-CEPS-----N", "10YDE-VE-------2"),
+ period_start = lubridate::ymd(x = "2022-01-01", tz = "CET"),
+ period_end = lubridate::ymd(x = "2022-01-02", tz = "CET"),
+ tidy_output = TRUE
+ ),
+ info = "This wrapper only supports one control area EIC per request."
+ )
+ testthat::expect_error(
+ object = financial_expenses_and_income_for_balancing(
+ eic = "10YCZ-CEPS-----N",
+ period_start = lubridate::ymd(x = "2022-01-01", tz = "CET"),
+ period_end = lubridate::ymd(x = "2023-05-01", tz = "CET"),
+ tidy_output = TRUE
+ ),
+ info = "One year range limit should be applied!"
+ )
+ testthat::expect_error(
+ object = financial_expenses_and_income_for_balancing(
+ eic = "10YCZ-CEPS-----N",
+ period_start = lubridate::ymd(x = "2022-01-01", tz = "CET"),
+ period_end = lubridate::ymd(x = "2022-01-02", tz = "CET"),
+ tidy_output = TRUE,
+ security_token = ""
+ ),
+ info = "Valid security token should be provided."
+ )
+ }
+)
+
+
+
+testthat::test_that(
+ desc = "fcr_total_capacity() works",
+ code = {
+ testthat::expect_no_error(
+ object = fcr_total_capacity(
+ eic = "10YEU-CONT-SYNC0",
+ period_start = lubridate::ymd(x = "2023-01-01", tz = "CET"),
+ period_end = lubridate::ymd(x = "2024-01-01", tz = "CET"),
+ tidy_output = TRUE
+ )
+ )
+ testthat::expect_error(
+ object = fcr_total_capacity(
+ eic = NULL,
+ period_start = lubridate::ymd(x = "2022-01-01", tz = "CET"),
+ period_end = lubridate::ymd(x = "2022-01-02", tz = "CET"),
+ tidy_output = TRUE
+ ),
+ regexp = "One area EIC should be provided"
+ )
+ testthat::expect_error(
+ object = fcr_total_capacity(
+ eic = c("10YEU-CONT-SYNC0", "10YDE-VE-------2"),
+ period_start = lubridate::ymd(x = "2022-01-01", tz = "CET"),
+ period_end = lubridate::ymd(x = "2022-01-02", tz = "CET"),
+ tidy_output = TRUE
+ ),
+ regexp = "This wrapper only supports one area EIC per request"
+ )
+ testthat::expect_error(
+ object = fcr_total_capacity(
+ eic = "10YEU-CONT-SYNC0",
+ period_start = lubridate::ymd(x = "2022-01-01", tz = "CET"),
+ period_end = lubridate::ymd(x = "2023-05-01", tz = "CET"),
+ tidy_output = TRUE
+ ),
+ regexp = "One year range limit should be applied"
+ )
+ testthat::expect_error(
+ object = fcr_total_capacity(
+ eic = "10YEU-CONT-SYNC0",
+ period_start = lubridate::ymd(x = "2022-01-01", tz = "CET"),
+ period_end = lubridate::ymd(x = "2022-01-02", tz = "CET"),
+ tidy_output = TRUE,
+ security_token = ""
+ ),
+ regexp = "Valid security token should be provided"
+ )
+ }
+)
+
+
+
+testthat::test_that(
+ desc = "shares_of_fcr_capacity() works",
+ code = {
+ testthat::expect_no_error(
+ object = shares_of_fcr_capacity(
+ eic = "10YDE-VE-------2",
+ business_type = "C23",
+ period_start = lubridate::ymd(x = "2022-01-01", tz = "CET"),
+ period_end = lubridate::ymd(x = "2023-01-01", tz = "CET"),
+ tidy_output = TRUE
+ )
+ )
+ testthat::expect_error(
+ object = shares_of_fcr_capacity(
+ eic = NULL,
+ business_type = "C23",
+ period_start = lubridate::ymd(x = "2022-01-01", tz = "CET"),
+ period_end = lubridate::ymd(x = "2022-01-02", tz = "CET"),
+ tidy_output = TRUE
+ ),
+ info = "One area EIC should be provided."
+ )
+ testthat::expect_error(
+ object = shares_of_fcr_capacity(
+ eic = c("10YDE-VE-------2", "10YDE-RWENET---I"),
+ business_type = "C23",
+ period_start = lubridate::ymd(x = "2022-01-01", tz = "CET"),
+ period_end = lubridate::ymd(x = "2022-01-02", tz = "CET"),
+ tidy_output = TRUE
+ ),
+ info = "This wrapper only supports one area EIC per request."
+ )
+ testthat::expect_error(
+ object = shares_of_fcr_capacity(
+ eic = "10YDE-VE-------2",
+ business_type = "INVALID",
+ period_start = lubridate::ymd(x = "2022-01-01", tz = "CET"),
+ period_end = lubridate::ymd(x = "2022-01-02", tz = "CET"),
+ tidy_output = TRUE
+ ),
+ info = "The 'business_type' should be 'C23' or 'B95'."
+ )
+ testthat::expect_error(
+ object = shares_of_fcr_capacity(
+ eic = "10YDE-VE-------2",
+ business_type = "C23",
+ period_start = lubridate::ymd(x = "2022-01-01", tz = "CET"),
+ period_end = lubridate::ymd(x = "2023-05-01", tz = "CET"),
+ tidy_output = TRUE
+ ),
+ info = "One year range limit should be applied!"
+ )
+ testthat::expect_error(
+ object = shares_of_fcr_capacity(
+ eic = "10YDE-VE-------2",
+ business_type = "C23",
+ period_start = lubridate::ymd(x = "2022-01-01", tz = "CET"),
+ period_end = lubridate::ymd(x = "2022-01-02", tz = "CET"),
+ tidy_output = TRUE,
+ security_token = ""
+ ),
+ info = "Valid security token should be provided."
+ )
+ }
+)
+
+
+
+testthat::test_that(
+ desc = "rr_and_frr_actual_capacity() works",
+ code = {
+ testthat::expect_no_error(
+ object = rr_and_frr_actual_capacity(
+ eic = "10YAT-APG------L",
+ process_type = "A56",
+ period_start = lubridate::ymd(x = "2022-01-01", tz = "CET"),
+ period_end = lubridate::ymd(x = "2022-04-01", tz = "CET"),
+ tidy_output = TRUE
+ )
+ )
+ testthat::expect_error(
+ object = rr_and_frr_actual_capacity(
+ eic = NULL,
+ process_type = "A56",
+ period_start = lubridate::ymd(x = "2022-01-01", tz = "CET"),
+ period_end = lubridate::ymd(x = "2022-04-01", tz = "CET"),
+ tidy_output = TRUE
+ ),
+ info = "One area EIC should be provided."
+ )
+ testthat::expect_error(
+ object = rr_and_frr_actual_capacity(
+ eic = c("10YAT-APG------L", "10YDE-VE-------2"),
+ process_type = "A56",
+ period_start = lubridate::ymd(x = "2022-01-01", tz = "CET"),
+ period_end = lubridate::ymd(x = "2022-04-01", tz = "CET"),
+ tidy_output = TRUE
+ ),
+ info = "This wrapper only supports one area EIC per request."
+ )
+ testthat::expect_error(
+ object = rr_and_frr_actual_capacity(
+ eic = "10YAT-APG------L",
+ process_type = "INVALID",
+ period_start = lubridate::ymd(x = "2022-01-01", tz = "CET"),
+ period_end = lubridate::ymd(x = "2022-04-01", tz = "CET"),
+ tidy_output = TRUE
+ ),
+ info = "The 'process_type' should be 'A56' (FRR) or 'A46' (RR)."
+ )
+ testthat::expect_error(
+ object = rr_and_frr_actual_capacity(
+ eic = "10YAT-APG------L",
+ process_type = "A56",
+ period_start = lubridate::ymd(x = "2022-01-01", tz = "CET"),
+ period_end = lubridate::ymd(x = "2022-04-01", tz = "CET"),
+ tidy_output = TRUE,
+ security_token = ""
+ ),
+ info = "Valid security token should be provided."
+ )
+ testthat::expect_error(
+ object = rr_and_frr_actual_capacity(
+ eic = "10YAT-APG------L",
+ process_type = "A56",
+ business_type = "INVALID",
+ period_start = lubridate::ymd(x = "2022-01-01", tz = "CET"),
+ period_end = lubridate::ymd(x = "2022-04-01", tz = "CET"),
+ tidy_output = TRUE
+ ),
+ regexp = "The 'business_type' should be 'C77', 'C78' or 'C79'."
+ )
+ }
+)
+
+
+
+testthat::test_that(
+ desc = "rr_actual_capacity() works",
+ code = {
+ testthat::expect_no_error(
+ object = rr_actual_capacity(
+ eic = "10YCZ-CEPS-----N",
+ period_start = lubridate::ymd(x = "2022-01-01", tz = "CET"),
+ period_end = lubridate::ymd(x = "2022-04-01", tz = "CET"),
+ tidy_output = TRUE
+ )
+ )
+ testthat::expect_error(
+ object = rr_actual_capacity(
+ eic = NULL,
+ period_start = lubridate::ymd(x = "2022-01-01", tz = "CET"),
+ period_end = lubridate::ymd(x = "2022-04-01", tz = "CET"),
+ tidy_output = TRUE
+ ),
+ info = "One area EIC should be provided."
+ )
+ testthat::expect_error(
+ object = rr_actual_capacity(
+ eic = c("10YAT-APG------L", "10YDE-VE-------2"),
+ period_start = lubridate::ymd(x = "2022-01-01", tz = "CET"),
+ period_end = lubridate::ymd(x = "2022-04-01", tz = "CET"),
+ tidy_output = TRUE
+ ),
+ info = "This wrapper only supports one area EIC per request."
+ )
+ testthat::expect_error(
+ object = rr_actual_capacity(
+ eic = "10YAT-APG------L",
+ period_start = lubridate::ymd(x = "2022-01-01", tz = "CET"),
+ period_end = lubridate::ymd(x = "2022-04-01", tz = "CET"),
+ tidy_output = TRUE,
+ security_token = ""
+ ),
+ info = "Valid security token should be provided."
+ )
+ }
+)
+
+
+
+# testthat::test_that(
+# desc = "sharing_of_frr_capacity() works",
+# code = {
+# # Note: [A26, A56, C22] combination is not available via the public API.
+# # The happy path for sharing_of_frr_capacity() cannot be exercised
+# # without a mock.
+# testthat::expect_error(
+# object = sharing_of_frr_capacity(
+# eic_acquiring = NULL,
+# eic_connecting = "10YAT-APG------L",
+# process_type = "A56",
+# period_start = lubridate::ymd(x = "2022-01-01", tz = "CET"),
+# period_end = lubridate::ymd(x = "2022-01-02", tz = "CET"),
+# tidy_output = TRUE
+# ),
+# info = "One acquiring domain EIC should be provided."
+# )
+# testthat::expect_error(
+# object = sharing_of_frr_capacity(
+# eic_acquiring = "10YCB-GERMANY--8",
+# eic_connecting = NULL,
+# process_type = "A56",
+# period_start = lubridate::ymd(x = "2022-01-01", tz = "CET"),
+# period_end = lubridate::ymd(x = "2022-01-02", tz = "CET"),
+# tidy_output = TRUE
+# ),
+# info = "One connecting domain EIC should be provided."
+# )
+# testthat::expect_error(
+# object = sharing_of_frr_capacity(
+# eic_acquiring = c("10YCB-GERMANY--8", "10YDE-VE-------2"),
+# eic_connecting = "10YAT-APG------L",
+# process_type = "A56",
+# period_start = lubridate::ymd(x = "2022-01-01", tz = "CET"),
+# period_end = lubridate::ymd(x = "2022-01-02", tz = "CET"),
+# tidy_output = TRUE
+# ),
+# info = paste(
+# "This wrapper only supports one acquiring and",
+# "one connecting EIC per request."
+# )
# )
# testthat::expect_error(
-# object = balancing_activated_reserves(
-# eic = c("10YHU-MAVIR----U", "10Y1001A1001A83F"),
-# period_start = lubridate::ymd(
-# x = "2020-02-01",
-# tz = "CET"
-# ),
-# period_end = lubridate::ymd(
-# x = "2020-03-01",
-# tz = "CET"
-# ),
-# reserve_type = "A96",
+# object = sharing_of_frr_capacity(
+# eic_acquiring = "10YCB-GERMANY--8",
+# eic_connecting = "10YAT-APG------L",
+# process_type = "INVALID",
+# period_start = lubridate::ymd(x = "2022-01-01", tz = "CET"),
+# period_end = lubridate::ymd(x = "2022-01-02", tz = "CET"),
# tidy_output = TRUE
# ),
-# info = "This wrapper only supports one control area EIC per request!"
+# info = "The 'process_type' should be 'A56' (FRR) or 'A46' (RR)."
# )
# testthat::expect_error(
-# object = balancing_activated_reserves(
-# eic = "10YHU-MAVIR----U",
-# period_start = lubridate::ymd(
-# x = "2020-02-01",
-# tz = "CET"
-# ),
-# period_end = lubridate::ymd(
-# x = "2021-03-01",
-# tz = "CET"
-# ),
-# reserve_type = "A96",
+# object = sharing_of_frr_capacity(
+# eic_acquiring = "10YCB-GERMANY--8",
+# eic_connecting = "10YAT-APG------L",
+# process_type = "A56",
+# period_start = lubridate::ymd(x = "2022-01-01", tz = "CET"),
+# period_end = lubridate::ymd(x = "2023-05-01", tz = "CET"),
# tidy_output = TRUE
# ),
# info = "One year range limit should be applied!"
# )
# testthat::expect_error(
-# object = balancing_activated_reserves(
-# eic = "10YHU-MAVIR----U",
-# period_start = lubridate::ymd(
-# x = "2020-02-01",
-# tz = "CET"
-# ),
-# period_end = lubridate::ymd(
-# x = "2020-03-01",
-# tz = "CET"
-# ),
-# reserve_type = "A96",
+# object = sharing_of_frr_capacity(
+# eic_acquiring = "10YCB-GERMANY--8",
+# eic_connecting = "10YAT-APG------L",
+# process_type = "A56",
+# period_start = lubridate::ymd(x = "2022-01-01", tz = "CET"),
+# period_end = lubridate::ymd(x = "2022-01-02", tz = "CET"),
# tidy_output = TRUE,
# security_token = ""
# ),
-# info = "Valid security token should be provided!"
+# info = "Valid security token should be provided."
# )
# }
# )
diff --git a/tests/testthat/test-en_generation.R b/tests/testthat/test-en_generation.R
index f38d0780..506f1307 100644
--- a/tests/testthat/test-en_generation.R
+++ b/tests/testthat/test-en_generation.R
@@ -105,9 +105,7 @@ testthat::test_that(
year = 1492,
psr_type = NULL
)
- ) |>
- testthat::expect_warning() |>
- testthat::expect_warning()
+ )
testthat::expect_error(
object = gen_installed_capacity_per_pu(
eic = "10YFR-RTE------C",
@@ -414,7 +412,7 @@ testthat::test_that(
tidy_output = TRUE
)
)
- testthat::expect_warning(
+ testthat::expect_no_error(
object = gen_per_gen_unit(
eic = "10YDE-VE-------2",
period_start = lubridate::ymd(
@@ -427,12 +425,8 @@ testthat::test_that(
),
gen_type = c("B03"),
tidy_output = TRUE
- ),
- info = "No additional type names added!"
- ) |>
- testthat::expect_warning(info = "No additional eic names added!") |>
- testthat::expect_warning(info = "No additional type names added!") |>
- testthat::expect_warning(info = "No additional eic names added!")
+ )
+ )
testthat::expect_error(
object = gen_per_gen_unit(
eic = "10YDE-VE-------2",
diff --git a/tests/testthat/test-en_helpers.R b/tests/testthat/test-en_helpers.R
index c305f26c..f30cbd85 100644
--- a/tests/testthat/test-en_helpers.R
+++ b/tests/testthat/test-en_helpers.R
@@ -1,9 +1,9 @@
testthat::test_that(
desc = "all_approved_eic() works",
code = {
- entsoeapi:::mh$reset()
- testthat::expect_no_error(object = all_approved_eic())
- tbl <- all_approved_eic()
+ testthat::expect_no_error(
+ object = tbl <- all_approved_eic()
+ )
testthat::expect_s3_class(
object = tbl,
class = "tbl_df",
@@ -19,7 +19,7 @@ testthat::test_that(
)
testthat::expect_error(
object = all_approved_eic("foo"),
- info = "Error in all_approved_eic('foo') : unused argument ('foo')"
+ regexp = 'unused argument \\("foo"\\)'
)
}
)
@@ -29,19 +29,28 @@ testthat::test_that(
testthat::test_that(
desc = "party_eic() works",
code = {
- entsoeapi:::mh$reset()
- testthat::expect_no_error(object = party_eic())
- tbl <- party_eic()
- testthat::expect_s3_class(object = tbl, class = "tbl_df", exact = FALSE)
- testthat::expect_gt(object = nrow(tbl), expected = 0L)
+ testthat::expect_no_error(
+ object = tbl <- party_eic()
+ )
+ testthat::expect_s3_class(
+ object = tbl,
+ class = "tbl_df",
+ exact = FALSE
+ )
+ testthat::expect_gt(
+ object = nrow(tbl),
+ expected = 0L
+ )
testthat::expect_contains(
object = names(tbl),
expected = c("EicCode", "EicLongName", "type")
)
- testthat::expect_true(object = all(tbl$type == "X"))
+ testthat::expect_true(
+ object = all(tbl$type == "X")
+ )
testthat::expect_error(
object = party_eic("foo"),
- info = "Error in party_eic('foo') : unused argument ('foo')"
+ regexp = 'unused argument \\("foo"\\)'
)
}
)
@@ -51,19 +60,28 @@ testthat::test_that(
testthat::test_that(
desc = "area_eic() works",
code = {
- entsoeapi:::mh$reset()
- testthat::expect_no_error(object = area_eic())
- tbl <- area_eic()
- testthat::expect_s3_class(object = tbl, class = "tbl_df", exact = FALSE)
- testthat::expect_gt(object = nrow(tbl), expected = 0L)
+ testthat::expect_no_error(
+ object = tbl <- area_eic()
+ )
+ testthat::expect_s3_class(
+ object = tbl,
+ class = "tbl_df",
+ exact = FALSE
+ )
+ testthat::expect_gt(
+ object = nrow(tbl),
+ expected = 0L
+ )
testthat::expect_contains(
object = names(tbl),
expected = c("EicCode", "EicLongName", "type")
)
- testthat::expect_true(object = all(tbl$type == "Y"))
+ testthat::expect_true(
+ object = all(tbl$type == "Y")
+ )
testthat::expect_error(
object = area_eic("foo"),
- info = "Error in area_eic('foo') : unused argument ('foo')"
+ regexp = 'unused argument \\("foo"\\)'
)
}
)
@@ -73,19 +91,28 @@ testthat::test_that(
testthat::test_that(
desc = "accounting_point_eic() works",
code = {
- entsoeapi:::mh$reset()
- testthat::expect_no_error(object = accounting_point_eic())
- tbl <- accounting_point_eic()
- testthat::expect_s3_class(object = tbl, class = "tbl_df", exact = FALSE)
- testthat::expect_gt(object = nrow(tbl), expected = 0L)
+ testthat::expect_no_error(
+ object = tbl <- accounting_point_eic()
+ )
+ testthat::expect_s3_class(
+ object = tbl,
+ class = "tbl_df",
+ exact = FALSE
+ )
+ testthat::expect_gt(
+ object = nrow(tbl),
+ expected = 0L
+ )
testthat::expect_contains(
object = names(tbl),
expected = c("EicCode", "EicLongName", "type")
)
- testthat::expect_true(object = all(tbl$type == "Z"))
+ testthat::expect_true(
+ object = all(tbl$type == "Z")
+ )
testthat::expect_error(
object = accounting_point_eic("foo"),
- info = "Error in accounting_point_eic('foo') : unused argument ('foo')"
+ regexp = 'unused argument \\("foo"\\)'
)
}
)
@@ -95,19 +122,28 @@ testthat::test_that(
testthat::test_that(
desc = "tie_line_eic() works",
code = {
- entsoeapi:::mh$reset()
- testthat::expect_no_error(object = tie_line_eic())
- tbl <- tie_line_eic()
- testthat::expect_s3_class(object = tbl, class = "tbl_df", exact = FALSE)
- testthat::expect_gt(object = nrow(tbl), expected = 0L)
+ testthat::expect_no_error(
+ object = tbl <- tie_line_eic()
+ )
+ testthat::expect_s3_class(
+ object = tbl,
+ class = "tbl_df",
+ exact = FALSE
+ )
+ testthat::expect_gt(
+ object = nrow(tbl),
+ expected = 0L
+ )
testthat::expect_contains(
object = names(tbl),
expected = c("EicCode", "EicLongName", "type")
)
- testthat::expect_true(object = all(tbl$type == "T"))
+ testthat::expect_true(
+ object = all(tbl$type == "T")
+ )
testthat::expect_error(
object = tie_line_eic("foo"),
- info = "Error in tie_line_eic('foo') : unused argument ('foo')"
+ regexp = 'unused argument \\("foo"\\)'
)
}
)
@@ -117,19 +153,28 @@ testthat::test_that(
testthat::test_that(
desc = "location_eic() works",
code = {
- entsoeapi:::mh$reset()
- testthat::expect_no_error(object = location_eic())
- tbl <- location_eic()
- testthat::expect_s3_class(object = tbl, class = "tbl_df", exact = FALSE)
- testthat::expect_gt(object = nrow(tbl), expected = 0L)
+ testthat::expect_no_error(
+ object = tbl <- location_eic()
+ )
+ testthat::expect_s3_class(
+ object = tbl,
+ class = "tbl_df",
+ exact = FALSE
+ )
+ testthat::expect_gt(
+ object = nrow(tbl),
+ expected = 0L
+ )
testthat::expect_contains(
object = names(tbl),
expected = c("EicCode", "EicLongName", "type")
)
- testthat::expect_true(object = all(tbl$type == "V"))
+ testthat::expect_true(
+ object = all(tbl$type == "V")
+ )
testthat::expect_error(
object = location_eic("foo"),
- info = "Error in location_eic('foo') : unused argument ('foo')"
+ regexp = 'unused argument \\("foo"\\)'
)
}
)
@@ -139,19 +184,28 @@ testthat::test_that(
testthat::test_that(
desc = "resource_object_eic() works",
code = {
- entsoeapi:::mh$reset()
- testthat::expect_no_error(object = resource_object_eic())
- tbl <- resource_object_eic()
- testthat::expect_s3_class(object = tbl, class = "tbl_df", exact = FALSE)
- testthat::expect_gt(object = nrow(tbl), expected = 0L)
+ testthat::expect_no_error(
+ object = tbl <- resource_object_eic()
+ )
+ testthat::expect_s3_class(
+ object = tbl,
+ class = "tbl_df",
+ exact = FALSE
+ )
+ testthat::expect_gt(
+ object = nrow(tbl),
+ expected = 0L
+ )
testthat::expect_contains(
object = names(tbl),
expected = c("EicCode", "EicLongName", "type")
)
- testthat::expect_true(object = all(tbl$type == "W"))
+ testthat::expect_true(
+ object = all(tbl$type == "W")
+ )
testthat::expect_error(
object = resource_object_eic("foo"),
- info = "Error in resource_object_eic('foo') : unused argument ('foo')"
+ regexp = 'unused argument \\("foo"\\)'
)
}
)
@@ -161,19 +215,28 @@ testthat::test_that(
testthat::test_that(
desc = "substation_eic() works",
code = {
- entsoeapi:::mh$reset()
- testthat::expect_no_error(object = substation_eic())
- tbl <- substation_eic()
- testthat::expect_s3_class(object = tbl, class = "tbl_df", exact = FALSE)
- testthat::expect_gt(object = nrow(tbl), expected = 0L)
+ testthat::expect_no_error(
+ object = tbl <- substation_eic()
+ )
+ testthat::expect_s3_class(
+ object = tbl,
+ class = "tbl_df",
+ exact = FALSE
+ )
+ testthat::expect_gt(
+ object = nrow(tbl),
+ expected = 0L
+ )
testthat::expect_contains(
object = names(tbl),
expected = c("EicCode", "EicLongName", "type")
)
- testthat::expect_true(object = all(tbl$type == "A"))
+ testthat::expect_true(
+ object = all(tbl$type == "A")
+ )
testthat::expect_error(
object = substation_eic("foo"),
- info = "Error in substation_eic('foo') : unused argument ('foo')"
+ regexp = 'unused argument \\("foo"\\)'
)
}
)
@@ -183,9 +246,10 @@ testthat::test_that(
testthat::test_that(
desc = "all_allocated_eic() responses got and appended into a tibble",
code = {
- entsoeapi:::mh$reset()
- testthat::expect_no_error(object = all_allocated_eic())
- tbl <- all_allocated_eic()
+ mh$reset()
+ testthat::expect_no_error(
+ object = tbl <- all_allocated_eic()
+ )
testthat::expect_s3_class(
object = tbl,
class = "tbl_df",
@@ -205,7 +269,7 @@ testthat::test_that(
)
testthat::expect_error(
object = all_allocated_eic("foo"),
- info = "Error in all_allocated_eic('foo') : unused argument ('foo')"
+ regexp = 'unused argument \\("foo"\\)'
)
}
)
@@ -213,22 +277,29 @@ testthat::test_that(
testthat::test_that(
- desc = "all_allocated_eic() errors with unknown content-type",
+ desc = "all_allocated_eic() errors with empty response body",
code = {
- entsoeapi:::mh$reset()
- httr2::local_mocked_responses(
- mock = function(req) {
- httr2::response(
- status_code = 200L,
- headers = list("content-type" = "text/csv"),
- body = raw(0L)
+ req_url <- paste0(
+ "https://eepublicdownloads.blob.core.windows.net/",
+ "cio-lio/xml/allocated-eic-codes.xml"
+ )
+ mock_list <- list()
+ mock_list[[req_url]] <- httr2::response(
+ status_code = 200L,
+ url = req_url,
+ headers = list("content-type" = "application/xml"),
+ body = raw(0L)
+ )
+ httr2::with_mocked_responses(
+ mock = mock_list,
+ code = {
+ mh$reset()
+ testthat::expect_error(
+ object = all_allocated_eic(),
+ regexp = "Can't retrieve empty body"
)
}
)
- testthat::expect_error(
- object = all_allocated_eic(),
- regexp = "Can't retrieve empty body"
- )
}
)
@@ -237,15 +308,17 @@ testthat::test_that(
testthat::test_that(
desc = "all_allocated_eic() errors on HTTP error response",
code = {
- entsoeapi:::mh$reset()
- xml_error_body <- charToRaw(paste0(
+ mh$reset()
+ xml_error_body <- paste0(
'',
"Service Unavailable"
- ))
+ ) |>
+ charToRaw()
httr2::local_mocked_responses(
mock = function(req) {
httr2::response(
status_code = 503L,
+ url = req$url,
headers = list("content-type" = "application/xml"),
body = xml_error_body
)
@@ -263,7 +336,7 @@ testthat::test_that(
testthat::test_that(
desc = "all_allocated_eic() parses XML content-type response",
code = {
- entsoeapi:::mh$reset()
+ mh$reset()
xml_fixture <- readLines(
con = testthat::test_path("fixtures", "allocated_eic_min.xml"),
encoding = "UTF-8"
@@ -274,14 +347,21 @@ testthat::test_that(
mock = function(req) {
httr2::response(
status_code = 200L,
+ url = req$url,
headers = list("content-type" = "application/xml"),
body = xml_fixture
)
}
)
- tbl <- all_allocated_eic()
- testthat::expect_s3_class(object = tbl, class = "tbl_df", exact = FALSE)
- testthat::expect_gt(object = nrow(tbl), expected = 0L)
+ testthat::expect_s3_class(
+ object = tbl <- all_allocated_eic(),
+ class = "tbl_df",
+ exact = FALSE
+ )
+ testthat::expect_gt(
+ object = nrow(tbl),
+ expected = 0L
+ )
testthat::expect_contains(
object = names(tbl),
expected = c(
@@ -303,7 +383,7 @@ testthat::test_that(
testthat::test_that(
desc = "all_allocated_eic() parses ZIP/octet-stream content-type response",
code = {
- entsoeapi:::mh$reset()
+ mh$reset()
xml_fixture <- readLines(
con = testthat::test_path("fixtures", "allocated_eic_min.xml"),
encoding = "UTF-8"
@@ -314,14 +394,21 @@ testthat::test_that(
mock = function(req) {
httr2::response(
status_code = 200L,
+ url = req$url,
headers = list("content-type" = "application/zip"),
body = xml_fixture
)
}
)
- tbl <- all_allocated_eic()
- testthat::expect_s3_class(object = tbl, class = "tbl_df", exact = FALSE)
- testthat::expect_gt(object = nrow(tbl), expected = 0L)
+ testthat::expect_s3_class(
+ object = tbl <- all_allocated_eic(),
+ class = "tbl_df",
+ exact = FALSE
+ )
+ testthat::expect_gt(
+ object = nrow(tbl),
+ expected = 0L
+ )
}
)
@@ -330,29 +417,36 @@ testthat::test_that(
testthat::test_that(
desc = "all_allocated_eic() stops on XML with unexpected structure",
code = {
- entsoeapi:::mh$reset()
- # Minimal XML with no EICCode_MarketDocument second-level nodes; the
- # setnames() call then fails because the expected EIC column names are
- # absent, exercising the error path after XML parsing.
- minimal_xml <- charToRaw(x = paste0(
- '',
- "",
- " A05",
- " value",
- ""
- ))
- httr2::local_mocked_responses(
- mock = function(req) {
- httr2::response(
- status_code = 200L,
- headers = list("content-type" = "application/xml"),
- body = minimal_xml
+ req_url <- paste0(
+ "https://eepublicdownloads.blob.core.windows.net/",
+ "cio-lio/xml/allocated-eic-codes.xml"
+ )
+ mock_list <- list()
+ mock_list[[req_url]] <- httr2::response(
+ status_code = 200L,
+ url = req_url,
+ headers = list("content-type" = "application/xml"),
+ # Minimal XML with no EICCode_MarketDocument second-level nodes; the
+ # setnames() call then fails because the expected EIC column names are
+ # absent, exercising the error path after XML parsing.
+ body = paste0(
+ '',
+ "",
+ " A05",
+ " value",
+ ""
+ ) |>
+ charToRaw()
+ )
+ httr2::with_mocked_responses(
+ mock = mock_list,
+ code = {
+ mh$reset()
+ testthat::expect_error(
+ object = all_allocated_eic(),
+ regexp = "The XML document has an unexpected tree structure"
)
}
)
- testthat::expect_error(
- object = all_allocated_eic(),
- regexp = "The XML document has an unexpected tree structure"
- )
}
)
diff --git a/tests/testthat/test-en_load.R b/tests/testthat/test-en_load.R
index 593aabff..5022da83 100644
--- a/tests/testthat/test-en_load.R
+++ b/tests/testthat/test-en_load.R
@@ -1,7 +1,7 @@
testthat::test_that(
- desc = "load_actual_total() works",
+ desc = "load_actual_total() works and returns valid output structure",
code = {
- testthat::expect_no_error(
+ result <- testthat::expect_no_error(
object = load_actual_total(
eic = "10Y1001A1001A83F",
period_start = lubridate::ymd(
@@ -15,6 +15,9 @@ testthat::test_that(
tidy_output = TRUE
)
)
+ testthat::expect_s3_class(object = result, class = "tbl_df", exact = FALSE)
+ testthat::expect_gt(object = nrow(result), expected = 0L)
+ testthat::expect_gt(object = ncol(result), expected = 0L)
testthat::expect_error(
object = load_actual_total(
eic = NULL,
@@ -84,7 +87,7 @@ testthat::test_that(
testthat::test_that(
desc = "load_day_ahead_total_forecast() works",
code = {
- testthat::expect_no_error(
+ result <- testthat::expect_no_error(
object = load_day_ahead_total_forecast(
eic = "10Y1001A1001A83F",
period_start = lubridate::ymd(
@@ -98,6 +101,9 @@ testthat::test_that(
tidy_output = TRUE
)
)
+ testthat::expect_s3_class(object = result, class = "tbl_df", exact = FALSE)
+ testthat::expect_gt(object = nrow(result), expected = 0L)
+ testthat::expect_gt(object = ncol(result), expected = 0L)
testthat::expect_error(
object = load_day_ahead_total_forecast(
eic = NULL,
@@ -167,7 +173,7 @@ testthat::test_that(
testthat::test_that(
desc = "load_week_ahead_total_forecast() works",
code = {
- testthat::expect_no_error(
+ result <- testthat::expect_no_error(
object = load_week_ahead_total_forecast(
eic = "10Y1001A1001A83F",
period_start = lubridate::ymd(
@@ -181,6 +187,9 @@ testthat::test_that(
tidy_output = TRUE
)
)
+ testthat::expect_s3_class(object = result, class = "tbl_df", exact = FALSE)
+ testthat::expect_gt(object = nrow(result), expected = 0L)
+ testthat::expect_gt(object = ncol(result), expected = 0L)
testthat::expect_error(
object = load_week_ahead_total_forecast(
eic = NULL,
@@ -250,7 +259,7 @@ testthat::test_that(
testthat::test_that(
desc = "load_month_ahead_total_forecast() works",
code = {
- testthat::expect_no_error(
+ result <- testthat::expect_no_error(
object = load_month_ahead_total_forecast(
eic = "10Y1001A1001A82H",
period_start = lubridate::ymd(
@@ -264,6 +273,9 @@ testthat::test_that(
tidy_output = TRUE
)
)
+ testthat::expect_s3_class(object = result, class = "tbl_df", exact = FALSE)
+ testthat::expect_gt(object = nrow(result), expected = 0L)
+ testthat::expect_gt(object = ncol(result), expected = 0L)
testthat::expect_error(
object = load_month_ahead_total_forecast(
eic = NULL,
@@ -333,7 +345,7 @@ testthat::test_that(
testthat::test_that(
desc = "load_year_ahead_total_forecast() works",
code = {
- testthat::expect_no_error(
+ result <- testthat::expect_no_error(
object = load_year_ahead_total_forecast(
eic = "10Y1001A1001A83F",
period_start = lubridate::ymd(
@@ -347,6 +359,9 @@ testthat::test_that(
tidy_output = TRUE
)
)
+ testthat::expect_s3_class(object = result, class = "tbl_df", exact = FALSE)
+ testthat::expect_gt(object = nrow(result), expected = 0L)
+ testthat::expect_gt(object = ncol(result), expected = 0L)
testthat::expect_error(
object = load_year_ahead_total_forecast(
eic = NULL,
@@ -413,125 +428,10 @@ testthat::test_that(
-testthat::test_that(
- desc = "load_actual_total() returns valid output structure",
- code = {
- result <- load_actual_total(
- eic = "10Y1001A1001A83F",
- period_start = lubridate::ymd(
- x = Sys.Date() - lubridate::days(x = 30),
- tz = "CET"
- ),
- period_end = lubridate::ymd(
- x = Sys.Date(),
- tz = "CET"
- ),
- tidy_output = TRUE
- )
- testthat::expect_s3_class(object = result, class = "tbl_df", exact = FALSE)
- testthat::expect_gt(object = nrow(result), expected = 0L)
- testthat::expect_gt(object = ncol(result), expected = 0L)
- }
-)
-
-
-
-testthat::test_that(
- desc = "load_day_ahead_total_forecast() returns valid output structure",
- code = {
- result <- load_day_ahead_total_forecast(
- eic = "10Y1001A1001A83F",
- period_start = lubridate::ymd(
- x = Sys.Date() - lubridate::days(x = 30),
- tz = "CET"
- ),
- period_end = lubridate::ymd(
- x = Sys.Date(),
- tz = "CET"
- ),
- tidy_output = TRUE
- )
- testthat::expect_s3_class(object = result, class = "tbl_df", exact = FALSE)
- testthat::expect_gt(object = nrow(result), expected = 0L)
- testthat::expect_gt(object = ncol(result), expected = 0L)
- }
-)
-
-
-
-testthat::test_that(
- desc = "load_week_ahead_total_forecast() returns valid output structure",
- code = {
- result <- load_week_ahead_total_forecast(
- eic = "10Y1001A1001A83F",
- period_start = lubridate::ymd(
- x = "2019-11-01",
- tz = "CET"
- ),
- period_end = lubridate::ymd(
- x = "2019-11-30",
- tz = "CET"
- ),
- tidy_output = TRUE
- )
- testthat::expect_s3_class(object = result, class = "tbl_df", exact = FALSE)
- testthat::expect_gt(object = nrow(result), expected = 0L)
- testthat::expect_gt(object = ncol(result), expected = 0L)
- }
-)
-
-
-
-testthat::test_that(
- desc = "load_month_ahead_total_forecast() returns valid output structure",
- code = {
- result <- load_month_ahead_total_forecast(
- eic = "10Y1001A1001A82H",
- period_start = lubridate::ymd(
- x = "2019-11-01",
- tz = "CET"
- ),
- period_end = lubridate::ymd(
- x = "2019-11-30",
- tz = "CET"
- ),
- tidy_output = TRUE
- )
- testthat::expect_s3_class(object = result, class = "tbl_df", exact = FALSE)
- testthat::expect_gt(object = nrow(result), expected = 0L)
- testthat::expect_gt(object = ncol(result), expected = 0L)
- }
-)
-
-
-
-testthat::test_that(
- desc = "load_year_ahead_total_forecast() returns valid output structure",
- code = {
- result <- load_year_ahead_total_forecast(
- eic = "10Y1001A1001A83F",
- period_start = lubridate::ymd(
- x = "2024-11-01",
- tz = "CET"
- ),
- period_end = lubridate::ymd(
- x = "2024-11-30",
- tz = "CET"
- ),
- tidy_output = TRUE
- )
- testthat::expect_s3_class(object = result, class = "tbl_df", exact = FALSE)
- testthat::expect_gt(object = nrow(result), expected = 0L)
- testthat::expect_gt(object = ncol(result), expected = 0L)
- }
-)
-
-
-
testthat::test_that(
desc = "load_year_ahead_forecast_margin() works",
code = {
- testthat::expect_no_error(
+ result <- testthat::expect_no_error(
object = load_year_ahead_forecast_margin(
eic = "10Y1001A1001A83F",
period_start = lubridate::ymd(
@@ -545,6 +445,9 @@ testthat::test_that(
tidy_output = TRUE
)
)
+ testthat::expect_s3_class(object = result, class = "tbl_df", exact = FALSE)
+ testthat::expect_gt(object = nrow(result), expected = 0L)
+ testthat::expect_gt(object = ncol(result), expected = 0L)
testthat::expect_error(
object = load_year_ahead_forecast_margin(
eic = NULL,
@@ -608,26 +511,3 @@ testthat::test_that(
)
}
)
-
-
-
-testthat::test_that(
- desc = "load_year_ahead_forecast_margin() returns valid output structure",
- code = {
- result <- load_year_ahead_forecast_margin(
- eic = "10Y1001A1001A83F",
- period_start = lubridate::ymd(
- x = "2019-01-01",
- tz = "CET"
- ),
- period_end = lubridate::ymd(
- x = "2019-12-31",
- tz = "CET"
- ),
- tidy_output = TRUE
- )
- testthat::expect_s3_class(object = result, class = "tbl_df", exact = FALSE)
- testthat::expect_gt(object = nrow(result), expected = 0L)
- testthat::expect_gt(object = ncol(result), expected = 0L)
- }
-)
diff --git a/tests/testthat/test-en_market.R b/tests/testthat/test-en_market.R
index ce9b34bb..9324852e 100644
--- a/tests/testthat/test-en_market.R
+++ b/tests/testthat/test-en_market.R
@@ -14,8 +14,7 @@ testthat::test_that(
),
tidy_output = FALSE
)
- ) |>
- testthat::expect_warning()
+ )
testthat::expect_error(
object = day_ahead_prices(
eic = NULL,
@@ -99,8 +98,7 @@ testthat::test_that(
),
tidy_output = TRUE
)
- ) |>
- testthat::expect_warning()
+ )
testthat::expect_error(
object = total_nominated_capacity(
eic_in = "10YDE-VE-------2",
@@ -321,8 +319,7 @@ testthat::test_that(
contract_type = "A01",
tidy_output = FALSE
)
- ) |>
- testthat::expect_warning()
+ )
testthat::expect_error(
object = implicit_offered_transfer_capacity(
eic_in = NULL,
@@ -602,8 +599,7 @@ testthat::test_that(
),
tidy_output = FALSE
)
- ) |>
- testthat::expect_warning()
+ )
testthat::expect_error(
object = continuous_offered_transfer_capacity(
eic_in = NULL,
@@ -726,7 +722,6 @@ testthat::test_that(
tidy_output = FALSE
)
) |>
- testthat::expect_warning() |>
testthat::expect_warning()
testthat::expect_error(
object = flow_based_allocations(
@@ -848,8 +843,7 @@ testthat::test_that(
contract_type = "A01",
tidy_output = FALSE
)
- ) |>
- testthat::expect_warning()
+ )
testthat::expect_error(
object = auction_revenue(
eic_in = NULL,
@@ -990,8 +984,7 @@ testthat::test_that(
contract_type = "A01",
tidy_output = FALSE
)
- ) |>
- testthat::expect_warning()
+ )
testthat::expect_error(
object = net_positions(
eic = NULL,
@@ -1107,8 +1100,7 @@ testthat::test_that(
contract_type = "A01",
tidy_output = FALSE
)
- ) |>
- testthat::expect_warning()
+ )
testthat::expect_error(
object = congestion_income(
eic = "10YDOM-1001A083J",
@@ -1214,6 +1206,22 @@ testthat::test_that(
testthat::test_that(
desc = "allocated_transfer_capacities_3rd_countries() works",
code = {
+ df <- allocated_transfer_capacities_3rd_countries(
+ eic_in = "10YSK-SEPS-----K",
+ eic_out = "10YUA-WEPS-----0",
+ period_start = lubridate::ymd(
+ x = "2016-01-01",
+ tz = "CET"
+ ),
+ period_end = lubridate::ymd(
+ x = "2016-01-01",
+ tz = "CET"
+ ),
+ contract_type = "A01",
+ auction_category = "A04",
+ position = 2L,
+ tidy_output = FALSE
+ )
cts <- c("A01", "A02", "A03", "A04", "A06", "A07", "A08")
ats <- c("A01", "A02", "A03", "A04")
for (ct in cts) {
@@ -1235,30 +1243,9 @@ testthat::test_that(
position = 1L,
tidy_output = FALSE
)
- ) |>
- testthat::expect_warning() |>
- testthat::expect_warning()
+ )
}
}
- testthat::expect_warning(
- object = df <- allocated_transfer_capacities_3rd_countries(
- eic_in = "10YSK-SEPS-----K",
- eic_out = "10YUA-WEPS-----0",
- period_start = lubridate::ymd(
- x = "2016-01-01",
- tz = "CET"
- ),
- period_end = lubridate::ymd(
- x = "2016-01-01",
- tz = "CET"
- ),
- contract_type = "A01",
- auction_category = "A04",
- position = 2L,
- tidy_output = FALSE
- )
- ) |>
- testthat::expect_warning()
testthat::expect_match(
object = df$reason_code,
regexp = "999"
diff --git a/tests/testthat/test-en_outages.R b/tests/testthat/test-en_outages.R
index 236d38cb..385ce0d6 100644
--- a/tests/testthat/test-en_outages.R
+++ b/tests/testthat/test-en_outages.R
@@ -28,11 +28,7 @@ testthat::test_that(
),
tidy_output = TRUE
)
- ) |>
- testthat::expect_warning() |>
- testthat::expect_warning() |>
- testthat::expect_warning() |>
- testthat::expect_warning()
+ )
testthat::expect_error(
object = outages_both(
eic = "10YFR-RTE------C",
@@ -375,9 +371,7 @@ testthat::test_that(
),
tidy_output = TRUE
)
- ) |>
- testthat::expect_warning() |>
- testthat::expect_warning()
+ )
testthat::expect_error(
object = outages_offshore_grid(
eic = "10Y1001A1001A82H",
@@ -742,9 +736,7 @@ testthat::test_that(
),
tidy_output = FALSE
)
- ) |>
- testthat::expect_warning() |>
- testthat::expect_warning()
+ )
testthat::expect_error(
object = outages_transmission_grid(
eic_in = "10YFR-RTE------C",
@@ -1018,9 +1010,7 @@ testthat::test_that(
),
tidy_output = FALSE
)
- ) |>
- testthat::expect_warning() |>
- testthat::expect_warning()
+ )
testthat::expect_error(
object = outages_fallbacks(
eic = "10YBE----------2",
diff --git a/tests/testthat/test-en_transmission.R b/tests/testthat/test-en_transmission.R
index f33215fe..c81c7b28 100644
--- a/tests/testthat/test-en_transmission.R
+++ b/tests/testthat/test-en_transmission.R
@@ -15,8 +15,7 @@ testthat::test_that(
),
tidy_output = FALSE
)
- ) |>
- testthat::expect_warning()
+ )
testthat::expect_error(
object = cross_border_physical_flows(
eic_in = c("10Y1001A1001A83F", "10YCZ-CEPS-----N"),
@@ -135,8 +134,7 @@ testthat::test_that(
),
tidy_output = FALSE
)
- ) |>
- testthat::expect_warning()
+ )
testthat::expect_error(
object = day_ahead_commercial_sched(
eic_out = "10YSK-SEPS-----K",
@@ -255,8 +253,7 @@ testthat::test_that(
),
tidy_output = FALSE
)
- ) |>
- testthat::expect_warning()
+ )
testthat::expect_error(
object = total_commercial_sched(
eic_in = "10YCZ-CEPS-----N",
@@ -375,8 +372,7 @@ testthat::test_that(
),
tidy_output = FALSE
)
- ) |>
- testthat::expect_warning()
+ )
testthat::expect_error(
object = forecasted_transfer_capacities(
eic_in = "10YCZ-CEPS-----N",
@@ -509,9 +505,7 @@ testthat::test_that(
tz = "CET"
),
tidy_output = TRUE
- ) |>
- expect_warning() |>
- expect_warning()
+ )
)
testthat::expect_error(
object = redispatching_cross_border(
@@ -828,8 +822,7 @@ testthat::test_that(
period_end = lubridate::ymd(x = "2016-12-31", tz = "CET"),
tidy_output = TRUE
)
- ) |>
- testthat::expect_warning()
+ )
testthat::expect_no_error(
object = costs_of_congestion_management(
eic = "10YBE----------2",
@@ -838,8 +831,7 @@ testthat::test_that(
event_nature = "A46",
tidy_output = TRUE
)
- ) |>
- testthat::expect_warning()
+ )
testthat::expect_error(
object = costs_of_congestion_management(
eic = "10YCZ-CEPS-----N",
@@ -866,8 +858,7 @@ testthat::test_that(
),
tidy_output = TRUE
)
- ) |>
- testthat::expect_warning()
+ )
testthat::expect_no_error(
object = costs_of_congestion_management(
eic = "10YNO-0--------C",
@@ -881,8 +872,7 @@ testthat::test_that(
),
tidy_output = TRUE
)
- ) |>
- testthat::expect_warning()
+ )
testthat::expect_error(
object = costs_of_congestion_management(
eic = NULL,
@@ -962,9 +952,7 @@ testthat::test_that(
doc_status = "A05",
tidy_output = FALSE
)
- ) |>
- testthat::expect_warning() |>
- testthat::expect_warning()
+ )
testthat::expect_error(
object = expansion_and_dismantling_project(
eic_in = NULL,
@@ -1099,8 +1087,7 @@ testthat::test_that(
),
tidy_output = FALSE
)
- ) |>
- testthat::expect_warning()
+ )
testthat::expect_error(
object = intraday_cross_border_transfer_limits(
eic_in = NULL,
diff --git a/tests/testthat/test-utils.R b/tests/testthat/test-utils.R
index 4664ba02..31e3703f 100644
--- a/tests/testthat/test-utils.R
+++ b/tests/testthat/test-utils.R
@@ -523,11 +523,10 @@ testthat::test_that(
sep = "&"
)
url_sample_5 <- paste(
- "documentType=A63",
- "businessType=A85",
- "in_Domain=10YNO-0--------C",
- "out_Domain=10YNO-0--------C",
- "periodStart=202402292300",
+ "documentType=A75",
+ "processType=A16",
+ "in_Domain=10YFR-RTE------C",
+ "periodStart=202202292300",
"periodEnd=202403312200",
sep = "&"
)
@@ -542,73 +541,62 @@ testthat::test_that(
query_string = url_sample_5,
security_token = Sys.getenv("ENTSOE_PAT")
),
- info = "The number of instances exceeds the allowed maximum."
+ regexp = "is larger than maximum allowed period"
)
testthat::expect_error(
object = api_req(
query_string = "https://web-api.tp.entsoe.eu/api",
security_token = Sys.getenv("ENTSOE_PAT")
),
- label = "Unable to parse URI. Its format is not valid"
+ regexp = "Unable to parse URI. Its format is not valid"
)
testthat::expect_error(
object = api_req(
query_string = NULL,
security_token = Sys.getenv("ENTSOE_PAT")
),
- info = "The argument 'query_string' is missing!"
+ regexp = "The argument 'query_string' is missing!"
)
testthat::expect_error(
object = api_req(),
- info = "The argument 'query_string' is missing!"
+ regexp = "The argument 'query_string' is missing!"
)
testthat::expect_error(
object = api_req(
query_string = NA,
security_token = Sys.getenv("ENTSOE_PAT")
),
- info = paste(
- "The argument 'query_string' has not got",
- "an acceptable timestamp format!"
- )
+ regexp = "Input parameter does not exist: NA"
)
testthat::expect_error(
object = api_req(
query_string = "https://google.com/",
security_token = Sys.getenv("ENTSOE_PAT")
),
- info = "Unable to parse URI."
+ regexp = "Unable to parse URI."
)
testthat::expect_error(
object = api_req(
query_string = "",
security_token = Sys.getenv("ENTSOE_PAT")
),
- info = paste(
- "The combination of [] is not valid, or the requested data is not ",
- "allowed to be fetched via this service!"
+ regexp = paste(
+ "The combination of \\[\\] is not valid, or the requested data is not",
+ "allowed to be fetched via this service"
)
)
- testthat::expect_message(
- object = api_req(
- query_string = url_sample_1,
- security_token = Sys.getenv("ENTSOE_PAT")
- ),
- info = "The url value should be printed in console!"
- )
testthat::expect_error(
object = api_req(
query_string = url_sample_1
),
- info = "The argument 'security_token' is not provided!"
+ regexp = "The argument 'security_token' is not provided"
)
- testthat::expect_true(
+ testthat::expect_s3_class(
object = api_req(
query_string = url_sample_1,
security_token = Sys.getenv("ENTSOE_PAT")
- ) |>
- inherits(what = "xml_document"),
- info = "The url value should be printed in console!"
+ ),
+ class = "xml_document"
)
testthat::expect_true(
object = api_req(
@@ -636,11 +624,7 @@ testthat::test_that(
"in_Domain=10YDE-VE-------2",
sep = "&"
)
- url_sample_2 <- paste(
- "",
- "",
- sep = "&"
- )
+ url_sample_2 <- NULL
testthat::expect_no_error(
object = content_1 <- api_req_safe(
query_string = url_sample_1,
@@ -717,7 +701,7 @@ testthat::test_that(
)
testthat::expect_warning(
object = url_posixct_format(x = "20240722210000"),
- info = "The 'x' value has interpreted as UTC!"
+ info = "The 'x' value has been interpreted as UTC!"
)
}
)
@@ -822,6 +806,14 @@ testthat::test_that(
unpack_xml(parent_name = "foo"),
info = "Names must be unique!"
)
+ # NULL result_vector path (empty XML element)
+ testthat::expect_equal(
+ object = xml2::read_xml("") |>
+ xml2::xml_contents() |>
+ (\(ns) ns[[1L]])() |>
+ unpack_xml(parent_name = "foo"),
+ expected = tibble::tibble()
+ )
}
)
@@ -869,6 +861,54 @@ testthat::test_that(
"ts_point"
)
)
+ # bid_ts_ columns with ts_point_ cols: covers rename-to-ts_ and rename-back
+ test_df_3 <- tibble::tibble(
+ bid_ts_mrid = rep(x = "TS001", 4L),
+ bid_ts_resolution = rep(x = "PT15M", 4L),
+ bid_ts_time_interval_start = as.POSIXct(
+ x = "2023-10-01 23:00:00",
+ tz = "UTC"
+ ),
+ bid_ts_point_position = 1L:4L,
+ bid_ts_point_price = c(10, 20, 30, 40)
+ )
+ result_3_tidy <- tidy_or_not(tbl = test_df_3, tidy_output = TRUE)
+ testthat::expect_contains(
+ object = names(result_3_tidy),
+ expected = c("bid_ts_point_price", "bid_ts_point_dt_start")
+ )
+ testthat::expect_false(object = "ts_point_price" %in% names(result_3_tidy))
+ # bid_ts_ columns without ts_point_ cols:
+ # covers rename-back-early-return path
+ test_df_4 <- tibble::tibble(
+ bid_ts_resolution = "PT15M",
+ bid_ts_mrid = "TS001"
+ )
+ result_4 <- tidy_or_not(tbl = test_df_4, tidy_output = FALSE)
+ testthat::expect_contains(
+ object = names(result_4),
+ expected = c("bid_ts_resolution", "bid_ts_mrid")
+ )
+ # A03 curve type with missing positions: covers the fill-missing-values path
+ test_df_5 <- tibble::tibble(
+ ts_mrid = rep(x = "TS001", 3L),
+ ts_curve_type = rep(x = "A03", 3L),
+ ts_resolution = rep(x = "PT60M", 3L),
+ ts_time_interval_start = rep(
+ x = as.POSIXct(x = "2023-10-01 22:00:00", tz = "UTC"), 3L
+ ),
+ ts_time_interval_end = rep(
+ x = as.POSIXct(x = "2023-10-02 04:00:00", tz = "UTC"), 3L
+ ),
+ ts_point_position = c(1L, 2L, 4L),
+ ts_point_quantity = c(100.0, 200.0, 400.0)
+ )
+ result_5 <- tidy_or_not(tbl = test_df_5, tidy_output = TRUE)
+ testthat::expect_contains(
+ object = names(result_5),
+ expected = c("ts_point_dt_start", "ts_point_quantity")
+ )
+ testthat::expect_equal(object = nrow(result_5), expected = 6L)
}
)
@@ -995,13 +1035,33 @@ testthat::test_that(
)
)
)
- testthat::expect_warning(
+ testthat::expect_no_warning(
object = add_type_names(tbl = iris),
- info = "No additional definitions added!"
+ message = "No additional definitions added!"
)
- testthat::expect_warning(
+ testthat::expect_no_warning(
object = add_type_names(tbl = NULL),
- info = "No additional definitions added!"
+ message = "No additional definitions added!"
+ )
+ # ts_product branch
+ df_product <- data.frame(ts_product = c("A03", "A04", "A05"))
+ testthat::expect_contains(
+ object = add_type_names(tbl = df_product) |> names(),
+ expected = "ts_product_def"
+ )
+ # subject_market_participant_market_role_type
+ # and bid_ts_flow_direction branches
+ df_role_dir <- data.frame(
+ subject_market_participant_market_role_type = c("A01", "A07", "A32"),
+ bid_ts_flow_direction = c("A01", "A02", "A01")
+ )
+ result_role_dir <- add_type_names(tbl = df_role_dir)
+ testthat::expect_contains(
+ object = names(result_role_dir),
+ expected = c(
+ "subject_market_participant_market_role_type_def",
+ "bid_ts_flow_direction_def"
+ )
)
}
)
@@ -1069,13 +1129,13 @@ testthat::test_that(
"control_area_domain_name"
)
)
- testthat::expect_warning(
+ testthat::expect_s3_class(
object = add_eic_names(tbl = iris),
- info = "No additional definitions added!"
+ class = "data.table"
)
- testthat::expect_warning(
+ testthat::expect_equal(
object = add_eic_names(tbl = NULL),
- info = "No additional definitions added!"
+ expected = data.table::data.table()
)
}
)
@@ -1138,13 +1198,13 @@ testthat::test_that(
)
)
)
- testthat::expect_warning(
+ testthat::expect_s3_class(
object = add_definitions(tbl = iris),
- info = "No additional definitions added!"
+ class = "data.table"
)
- testthat::expect_warning(
+ testthat::expect_equal(
object = add_definitions(tbl = NULL),
- info = "No additional definitions added!"
+ expected = data.table::data.table()
)
}
)
@@ -1191,7 +1251,7 @@ testthat::test_that(
url_sample_5 <- paste(
"documentType=A65",
"businessType=A85",
- "in_Domain=10YNO-0--------C", #
+ "in_Domain=10YNO-0--------C",
"out_Domain=10YNO-0--------C",
"periodStart=202402292300",
"periodEnd=202403102300",
@@ -1229,8 +1289,7 @@ testthat::test_that(
xml_content = content_2$result,
tidy_output = TRUE
)
- ) |>
- testthat::expect_warning()
+ )
testthat::expect_no_error(
object = xml_to_table(
xml_content = content_3$result,
@@ -1248,7 +1307,7 @@ testthat::test_that(
xml_content = content_5$result,
tidy_output = TRUE
),
- info = "The 'xml_content' should be an xml document!"
+ regexp = "The 'xml_content' should be an xml document"
)
testthat::expect_true(
object = xml_to_table(xml_content = content_1$result) |>
@@ -1270,10 +1329,7 @@ testthat::test_that(
xml2::read_xml() |>
xml_to_table(tidy_output = FALSE),
info = "There is no interesting columns in the result table!"
- ) |>
- testthat::expect_warning() |>
- testthat::expect_warning() |>
- testthat::expect_warning()
+ )
testthat::expect_error(
object = xml_to_table(xml_content = iris),
info = "The 'xml_content' should be an xml document!"
@@ -1360,10 +1416,7 @@ testthat::test_that(
testthat::expect_error(
object = extract_response(content = content_1),
info = "There is no interesting columns in the result table!"
- ) |>
- testthat::expect_warning() |>
- testthat::expect_warning() |>
- testthat::expect_warning()
+ )
testthat::expect_error(
object = extract_response(content = iris),
info = "The content is not in the required list format!"
@@ -1400,16 +1453,22 @@ testthat::test_that(
mock = function(req) {
httr2::response(
status_code = 200L,
- headers = list("content-type" = "application/xml"),
- body = xml_fixture
+ headers = list("content-type" = "application/xml"),
+ body = xml_fixture
)
}
)
- tbl <- entsoeapi:::get_all_allocated_eic()
- testthat::expect_s3_class(object = tbl, class = "tbl_df", exact = FALSE)
- testthat::expect_gt(object = nrow(tbl), expected = 0L)
+ testthat::expect_s3_class(
+ object = tbl <- get_all_allocated_eic(),
+ class = "tbl_df",
+ exact = FALSE
+ )
+ testthat::expect_gt(
+ object = nrow(tbl),
+ expected = 0L
+ )
testthat::expect_contains(
- object = names(tbl),
+ object = names(tbl),
expected = c(
"eic_code",
"doc_status_value",
@@ -1441,16 +1500,16 @@ testthat::test_that(
mock = function(req) {
httr2::response(
status_code = 200L,
- headers = list("content-type" = "application/xml"),
- body = xml_fixture
+ headers = list("content-type" = "application/xml"),
+ body = xml_fixture
)
}
)
- tbl <- entsoeapi:::get_all_allocated_eic()
+ tbl <- get_all_allocated_eic()
# A05 is in the fixture; its title in message_types
# is "Control block area schedule"
testthat::expect_equal(
- object = tbl$doc_status[[1L]],
+ object = tbl$doc_status[[1L]],
expected = "Control block area schedule"
)
}
@@ -1466,8 +1525,8 @@ testthat::test_that(
mock = function(req) {
httr2::response(
status_code = 503L,
- headers = list("content-type" = "application/xml"),
- body = charToRaw(
+ headers = list("content-type" = "application/xml"),
+ body = charToRaw(
paste0(
'',
"Unavailable"
@@ -1477,11 +1536,11 @@ testthat::test_that(
}
)
testthat::expect_error(
- object = entsoeapi:::get_all_allocated_eic(),
+ object = get_all_allocated_eic(),
regexp = "HTTP 503"
)
testthat::expect_error(
- object = entsoeapi:::get_all_allocated_eic(),
+ object = get_all_allocated_eic(),
regexp = "eepublicdownloads\\.blob\\.core\\.windows\\.net"
)
}
@@ -1496,12 +1555,12 @@ testthat::test_that(
mock = function(req) {
httr2::response(
status_code = 200L,
- headers = list("content-type" = "application/xml"),
- body = raw(0L)
+ headers = list("content-type" = "application/xml"),
+ body = raw(0L)
)
}
)
- testthat::expect_error(object = entsoeapi:::get_all_allocated_eic())
+ testthat::expect_error(object = get_all_allocated_eic())
}
)
@@ -1521,13 +1580,13 @@ testthat::test_that(
mock = function(req) {
httr2::response(
status_code = 200L,
- headers = list("content-type" = "application/xml"),
- body = minimal_xml
+ headers = list("content-type" = "application/xml"),
+ body = minimal_xml
)
}
)
testthat::expect_error(
- object = entsoeapi:::get_all_allocated_eic(),
+ object = get_all_allocated_eic(),
regexp = "unexpected tree structure"
)
}
@@ -1549,15 +1608,15 @@ testthat::test_that(
mock = function(req) {
httr2::response(
status_code = 200L,
- headers = list("content-type" = "application/xml"),
- body = multi_eic_xml
+ headers = list("content-type" = "application/xml"),
+ body = multi_eic_xml
)
}
)
- tbl <- entsoeapi:::get_all_allocated_eic()
+ tbl <- get_all_allocated_eic()
testthat::expect_equal(object = nrow(tbl), expected = 2L)
testthat::expect_setequal(
- object = tbl$eic_code,
+ object = tbl$eic_code,
expected = c("10X-TEST--EIC--1", "10X-TEST--EIC--2")
)
}
@@ -1579,12 +1638,12 @@ testthat::test_that(
mock = function(req) {
httr2::response(
status_code = 200L,
- headers = list("content-type" = "application/xml"),
- body = dupl_fn_xml
+ headers = list("content-type" = "application/xml"),
+ body = dupl_fn_xml
)
}
)
- tbl <- entsoeapi:::get_all_allocated_eic()
+ tbl <- get_all_allocated_eic()
testthat::expect_equal(object = nrow(tbl), expected = 2L)
testthat::expect_true(
object = grepl(
@@ -1595,3 +1654,380 @@ testthat::test_that(
)
}
)
+
+
+
+testthat::test_that(
+ desc = paste(
+ "get_all_allocated_eic() stops with error message",
+ "and URL on no internet connection"
+ ),
+ code = {
+ curl_err <- structure(
+ class = c("curl_error", "error", "condition"),
+ list(message = paste(
+ "Could not resolve host:",
+ "eepublicdownloads.blob.core.windows.net"
+ )
+ )
+ )
+ httr2_err <- structure(
+ class = c("httr2_failure", "httr2_error", "error", "condition"),
+ list(
+ message = "Failed to perform HTTP request.",
+ resp = NULL,
+ parent = curl_err
+ )
+ )
+ httr2::local_mocked_responses(
+ mock = function(req) stop(httr2_err)
+ )
+ testthat::expect_error(
+ object = get_all_allocated_eic(),
+ regexp = "Failed to perform HTTP request\\."
+ )
+ testthat::expect_error(
+ object = get_all_allocated_eic(),
+ regexp = "eepublicdownloads\\.blob\\.core\\.windows\\.net"
+ )
+ }
+)
+
+
+
+testthat::test_that(
+ desc = "tidy_or_not() stops on unknown curve_type",
+ code = {
+ df <- tibble::tibble(
+ ts_resolution = "PT60M",
+ ts_curve_type = "A99",
+ ts_time_interval_start = as.POSIXct("2023-01-01 00:00:00", tz = "UTC"),
+ ts_point_position = 1L,
+ ts_point_price = 50.0
+ )
+ testthat::expect_error(
+ object = tidy_or_not(tbl = df, tidy_output = TRUE),
+ regexp = "The curve type is not defined, but A99!"
+ )
+ }
+)
+
+
+
+testthat::test_that(
+ desc = paste(
+ "get_all_allocated_eic() collapses actual duplicate",
+ "Function_Names elements with ' - '"
+ ),
+ code = {
+ xml_fixture <- readLines(
+ con = testthat::test_path("fixtures", "get_allocated_eic_dupl.xml"),
+ encoding = "UTF-8"
+ ) |>
+ paste(collapse = "\n") |>
+ charToRaw()
+ httr2::local_mocked_responses(
+ mock = function(req) {
+ httr2::response(
+ status_code = 200L,
+ url = req$url,
+ headers = list("content-type" = "application/xml"),
+ body = xml_fixture
+ )
+ }
+ )
+ tbl <- get_all_allocated_eic()
+ testthat::expect_equal(object = nrow(tbl), expected = 1L)
+ testthat::expect_true(
+ object = grepl(
+ pattern = "GENERATION - LOAD",
+ x = tbl$function_names[[1L]],
+ fixed = TRUE
+ )
+ )
+ }
+)
+
+
+
+testthat::test_that(
+ desc = "add_eic_names() adds names for additional domain mrid columns",
+ code = {
+ eic_val <- "16YAOGUADIANA--T"
+ df <- data.frame(
+ area_domain_mrid = eic_val,
+ ts_acquiring_domain_mrid = eic_val,
+ ts_connecting_domain_mrid = eic_val,
+ bid_ts_acquiring_domain_mrid = eic_val,
+ bid_ts_connecting_domain_mrid = eic_val,
+ domain_mrid = eic_val,
+ constraint_ts_monitored_ptdf_domain_mrid = eic_val,
+ stringsAsFactors = FALSE
+ )
+ result <- add_eic_names(tbl = df)
+ testthat::expect_contains(
+ object = names(result),
+ expected = c(
+ "area_domain_mrid",
+ "area_domain_name",
+ "ts_acquiring_domain_mrid",
+ "ts_acquiring_domain_name",
+ "ts_connecting_domain_mrid",
+ "ts_connecting_domain_name",
+ "bid_ts_acquiring_domain_mrid",
+ "bid_ts_acquiring_domain_name",
+ "bid_ts_connecting_domain_mrid",
+ "bid_ts_connecting_domain_name",
+ "domain_mrid",
+ "domain_name",
+ "constraint_ts_monitored_ptdf_domain_mrid",
+ "constraint_ts_monitored_ptdf_domain_name"
+ )
+ )
+ }
+)
+
+
+
+testthat::test_that(
+ desc = "add_definitions() unites multiple ts_reason_code columns",
+ code = {
+ df <- data.frame(
+ ts_reason_code = c("A01", "A02"),
+ ts_reason_code_1 = c("A03", "A04"),
+ stringsAsFactors = FALSE
+ )
+ result <- add_definitions(tbl = df)
+ testthat::expect_contains(
+ object = names(result),
+ expected = c("ts_reason_code", "ts_reason_text")
+ )
+ testthat::expect_true(
+ object = all(grepl(" - ", result$ts_reason_text, fixed = TRUE))
+ )
+ }
+)
+
+
+
+testthat::test_that(
+ desc = "xml_to_table() tryCatch handler fires on unequal-group XML",
+ code = {
+ conflict_xml <- xml2::read_xml(
+ paste0(
+ '',
+ "",
+ "- 1
",
+ "- 2
",
+ "- 3
",
+ "- x
",
+ "- y
",
+ "
"
+ )
+ )
+ testthat::expect_error(
+ object = xml_to_table(xml_content = conflict_xml),
+ regexp = "The XML document has an unexpected tree structure"
+ )
+ }
+)
+
+
+
+testthat::test_that(
+ desc = "extract_response() returns empty tibble for NULL result element",
+ code = {
+ content_null <- list(result = list(NULL), error = NULL)
+ result <- extract_response(content = content_null)
+ testthat::expect_s3_class(object = result, class = "tbl_df", exact = FALSE)
+ testthat::expect_equal(object = nrow(result), expected = 0L)
+ }
+)
+
+
+
+testthat::test_that(
+ desc = "extract_response() processes a list-of-xml_documents element",
+ code = {
+ xml_doc <- xml2::xml2_example(path = "order-schema.xml") |>
+ xml2::read_xml()
+ content_alldoc <- list(result = list(list(xml_doc)), error = NULL)
+ # xml_to_table on order-schema.xml fails because it has no ENTSO-E columns;
+ # the important thing is the all_doc branch is entered (lines 2037-2041)
+ testthat::expect_error(
+ object = extract_response(content = content_alldoc)
+ )
+ }
+)
+
+
+
+testthat::test_that(
+ desc = "extract_response() returns empty tibble for list of non-documents",
+ code = {
+ content_nondoc <- list(result = list(list(1L, 2L, 3L)), error = NULL)
+ result <- extract_response(content = content_nondoc)
+ testthat::expect_s3_class(object = result, class = "tbl_df", exact = FALSE)
+ testthat::expect_equal(object = nrow(result), expected = 0L)
+ }
+)
+
+
+
+testthat::test_that(
+ desc = "api_req() stops on unknown 200 response content-type",
+ code = {
+ httr2::local_mocked_responses(
+ mock = function(req) {
+ httr2::response(
+ status_code = 200L,
+ url = req$url,
+ headers = list("content-type" = "text/plain"),
+ body = charToRaw("some plain text")
+ )
+ }
+ )
+ testthat::expect_error(
+ object = api_req(
+ query_string = "documentType=A73",
+ security_token = "dummy_token"
+ ),
+ regexp = "Not known response content-type: text/plain"
+ )
+ }
+)
+
+
+
+testthat::test_that(
+ desc = "api_req() stops on HTML error response",
+ code = {
+ httr2::local_mocked_responses(
+ mock = function(req) {
+ httr2::response(
+ status_code = 403L,
+ url = req$url,
+ headers = list("content-type" = "text/html"),
+ body = charToRaw(
+ "Access Denied"
+ )
+ )
+ }
+ )
+ # The stop() message may be empty when xmlconvert::xml_to_list()|>pluck()
+ # returns NULL for the HTML body; what matters is that the HTML error branch
+ # (lines 721-730) is reached and an error is thrown.
+ testthat::expect_error(
+ object = api_req(
+ query_string = "documentType=A73",
+ security_token = "dummy_token"
+ )
+ )
+ }
+)
+
+
+
+testthat::test_that(
+ desc = "api_req() stops on XML error with unexpected Reason structure",
+ code = {
+ xml_body <- paste0(
+ '',
+ "",
+ "test",
+ "Something went wrong",
+ ""
+ ) |>
+ charToRaw()
+ httr2::local_mocked_responses(
+ mock = function(req) {
+ httr2::response(
+ status_code = 500L,
+ url = req$url,
+ headers = list("content-type" = "application/xml"),
+ body = xml_body
+ )
+ }
+ )
+ testthat::expect_error(
+ object = api_req(
+ query_string = "documentType=A73",
+ security_token = "dummy_token"
+ ),
+ regexp = "^500"
+ )
+ }
+)
+
+
+
+testthat::test_that(
+ desc = "api_req() stops with code:text message on non-999 XML error code",
+ code = {
+ xml_body <- paste0(
+ '',
+ "",
+ "test",
+ "",
+ "B11",
+ "Requested data is not available",
+ "",
+ ""
+ ) |>
+ charToRaw()
+ httr2::local_mocked_responses(
+ mock = function(req) {
+ httr2::response(
+ status_code = 400L,
+ url = req$url,
+ headers = list("content-type" = "application/xml"),
+ body = xml_body
+ )
+ }
+ )
+ testthat::expect_error(
+ object = api_req(
+ query_string = "documentType=A73",
+ security_token = "dummy_token"
+ ),
+ regexp = "B11"
+ )
+ }
+)
+
+
+
+testthat::test_that(
+ desc = "api_req() stops with curl error message on no internet connection",
+ code = {
+ curl_err <- structure(
+ class = c("curl_error", "error", "condition"),
+ list(message = "Could not resolve host: web-api.tp.entsoe.eu")
+ )
+ httr2_err <- structure(
+ class = c("httr2_failure", "httr2_error", "error", "condition"),
+ list(
+ message = "Failed to perform HTTP request.",
+ resp = NULL,
+ parent = curl_err
+ )
+ )
+ httr2::local_mocked_responses(
+ mock = function(req) stop(httr2_err)
+ )
+ testthat::expect_error(
+ object = api_req(
+ query_string = paste(
+ "documentType=A73",
+ "processType=A16",
+ "periodStart=202001302300",
+ "periodEnd=202001312300",
+ "in_Domain=10YDE-VE-------2",
+ sep = "&"
+ ),
+ security_token = "dummy_token"
+ ),
+ regexp = "Could not resolve host: web-api\\.tp\\.entsoe\\.eu"
+ )
+ }
+)