From 1cd7fc7c4c2952f8f824f7afde22f9d9c9b664b2 Mon Sep 17 00:00:00 2001 From: Alex Axthelm Date: Tue, 13 Aug 2024 17:53:58 +0200 Subject: [PATCH 01/12] Export calc_weights_and_outputs. --- R/calc_weights_and_outputs.R | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/R/calc_weights_and_outputs.R b/R/calc_weights_and_outputs.R index a3b6305..ddf6001 100644 --- a/R/calc_weights_and_outputs.R +++ b/R/calc_weights_and_outputs.R @@ -1,3 +1,26 @@ +#' calc_weights_and_outputs +#' +#' @description This function calculates the weights and outputs for the +#' portfolio. This is the core of running the "PACTA analysis" for a portfolio. +#' +#' @param total_portfolio `data.frame`: PACTA formatted portfolio. +#' @param portfolio_type `character`: Portfolio type. Accepts "Equity" or +#' "Bonds". +#' @param output_dir filepath: Directory to save outputs. +#' @param data_dir filepath: Directory with "pacta-data" +#' @param equity_market_list character vector: List of equity markets to +#' include in analysis. +#' @param scenario_sources_list character vector: List of scenario sources to +#' include in analysis. Note sources must be available in the "pacta-data". +#' @param scenario_geographies_list character vector: List of scenario-defined +#' geographies to include in analysis. Note these geographies must be available +#' in the scenario data. +#' @param sector_list character vector: List of sectors to include in analysis. +#' @param start_year integer: Start year for analysis. +#' @param time_horizon integer: Time horizon after start for analysis (usually +#' 5 years). +#' @return No return value. Saves outputs to output_dir. +#' @export calc_weights_and_outputs <- function( total_portfolio, portfolio_type, From 552aa1a0bb57939db27f2f76d8a958654e95a083 Mon Sep 17 00:00:00 2001 From: Alex Axthelm Date: Tue, 13 Aug 2024 17:56:25 +0200 Subject: [PATCH 02/12] Export run_analysis --- R/run_analysis.R | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/R/run_analysis.R b/R/run_analysis.R index 24ffa14..aadbf95 100644 --- a/R/run_analysis.R +++ b/R/run_analysis.R @@ -1,3 +1,22 @@ +#' @title run_analysis +#' +#' @description This function runs the PACTA analysis for a portfolio. +#' +#' @param pacta_data_dir filepath: Directory with "pacta-data" +#' @param output_dir filepath: Directory to save outputs. +#' @param equity_market_list character vector: List of equity markets to +#' include in analysis. +#' @param scenario_sources_list character vector: List of scenario sources to +#' include in analysis. Note sources must be available in the "pacta-data". +#' @param scenario_geographies_list character vector: List of scenario-defined +#' geographies to include in analysis. Note these geographies must be available +#' in the scenario data. +#' @param sector_list character vector: List of sectors to include in analysis. +#' @param start_year integer: Start year for analysis. +#' @param time_horizon integer: Time horizon after start for analysis (usually +#' 5 years). +#' @return No return value. Saves outputs to output_dir. +#' @export run_analysis <- function( pacta_data_dir, output_dir, From c89b0d06e9df3dece3d56a0b90d6565db0b97328 Mon Sep 17 00:00:00 2001 From: Alex Axthelm Date: Tue, 13 Aug 2024 17:57:33 +0200 Subject: [PATCH 03/12] export run_audit --- R/run_audit.R | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/R/run_audit.R b/R/run_audit.R index 7e4eac6..3bb8457 100644 --- a/R/run_audit.R +++ b/R/run_audit.R @@ -1,3 +1,13 @@ +#' @title run_audit +#' +#' @description This function runs the PACTA audit for a portfolio. +#' +#' @param pacta_data_dir filepath: Directory with "pacta-data" +#' @param portfolio_dir filepath: Directory with portfolio files +#' @param portfolio_files character vector: List of portfolio files to process. +#' @param output_dir filepath: Directory to save outputs. +#' @return No return value. Saves outputs to output_dir. +#' @export run_audit <- function( pacta_data_dir, portfolio_dir, From c42773808876648658d5bcf817193e46e10b51d7 Mon Sep 17 00:00:00 2001 From: Alex Axthelm Date: Tue, 13 Aug 2024 18:01:04 +0200 Subject: [PATCH 04/12] export run_pacta --- R/run_pacta.R | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/R/run_pacta.R b/R/run_pacta.R index 56c17d9..40b1782 100644 --- a/R/run_pacta.R +++ b/R/run_pacta.R @@ -1,3 +1,13 @@ +#' @title Run PACTA +#' +#' @description This function runs the PACTA audit and analysis for a portfolio. +#' +#' @param raw_params character or filepath: JSON string or file with parameters. +#' @param pacta_data_dir filepath: Directory with "pacta-data" +#' @param output_dir filepath: Directory to save outputs. +#' @param portfolio_dir filepath: Directory with portfolio files +#' @return No return value. Saves outputs to output_dir. +#' @export run_pacta <- function( raw_params = commandArgs(trailingOnly = TRUE), pacta_data_dir = Sys.getenv("PACTA_DATA_DIR"), From ba2ef6fa180bca7cfc29c17c4e02cf21737bc2e1 Mon Sep 17 00:00:00 2001 From: Alex Axthelm Date: Tue, 13 Aug 2024 18:01:38 +0200 Subject: [PATCH 05/12] Increment version number to 0.0.0.9006 --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 83781d9..2d0e36a 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: workflow.pacta Title: Run PACTA -Version: 0.0.0.9005 +Version: 0.0.0.9006 Authors@R: c(person(given = "CJ", family = "Yetman", From 6def5e188c191348a57092bdb45dacc931ba6fb2 Mon Sep 17 00:00:00 2001 From: Alex Axthelm Date: Tue, 13 Aug 2024 18:01:54 +0200 Subject: [PATCH 06/12] Render documentation --- NAMESPACE | 4 +++ man/calc_weights_and_outputs.Rd | 53 +++++++++++++++++++++++++++++++++ man/run_analysis.Rd | 45 ++++++++++++++++++++++++++++ man/run_audit.Rd | 23 ++++++++++++++ man/run_pacta.Rd | 28 +++++++++++++++++ 5 files changed, 153 insertions(+) create mode 100644 man/calc_weights_and_outputs.Rd create mode 100644 man/run_analysis.Rd create mode 100644 man/run_audit.Rd create mode 100644 man/run_pacta.Rd diff --git a/NAMESPACE b/NAMESPACE index 422078b..5c22fd8 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,5 +1,9 @@ # Generated by roxygen2: do not edit by hand +export(calc_weights_and_outputs) +export(run_analysis) +export(run_audit) +export(run_pacta) importFrom(logger,log_debug) importFrom(logger,log_error) importFrom(logger,log_info) diff --git a/man/calc_weights_and_outputs.Rd b/man/calc_weights_and_outputs.Rd new file mode 100644 index 0000000..03e4a40 --- /dev/null +++ b/man/calc_weights_and_outputs.Rd @@ -0,0 +1,53 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/calc_weights_and_outputs.R +\name{calc_weights_and_outputs} +\alias{calc_weights_and_outputs} +\title{calc_weights_and_outputs} +\usage{ +calc_weights_and_outputs( + total_portfolio, + portfolio_type, + output_dir, + data_dir, + equity_market_list, + scenario_sources_list, + scenario_geographies_list, + sector_list, + start_year, + time_horizon +) +} +\arguments{ +\item{total_portfolio}{\code{data.frame}: PACTA formatted portfolio.} + +\item{portfolio_type}{\code{character}: Portfolio type. Accepts "Equity" or +"Bonds".} + +\item{output_dir}{filepath: Directory to save outputs.} + +\item{data_dir}{filepath: Directory with "pacta-data"} + +\item{equity_market_list}{character vector: List of equity markets to +include in analysis.} + +\item{scenario_sources_list}{character vector: List of scenario sources to +include in analysis. Note sources must be available in the "pacta-data".} + +\item{scenario_geographies_list}{character vector: List of scenario-defined +geographies to include in analysis. Note these geographies must be available +in the scenario data.} + +\item{sector_list}{character vector: List of sectors to include in analysis.} + +\item{start_year}{integer: Start year for analysis.} + +\item{time_horizon}{integer: Time horizon after start for analysis (usually +5 years).} +} +\value{ +No return value. Saves outputs to output_dir. +} +\description{ +This function calculates the weights and outputs for the +portfolio. This is the core of running the "PACTA analysis" for a portfolio. +} diff --git a/man/run_analysis.Rd b/man/run_analysis.Rd new file mode 100644 index 0000000..602611d --- /dev/null +++ b/man/run_analysis.Rd @@ -0,0 +1,45 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/run_analysis.R +\name{run_analysis} +\alias{run_analysis} +\title{run_analysis} +\usage{ +run_analysis( + pacta_data_dir, + output_dir, + equity_market_list, + scenario_sources_list, + scenario_geographies_list, + sector_list, + start_year, + time_horizon +) +} +\arguments{ +\item{pacta_data_dir}{filepath: Directory with "pacta-data"} + +\item{output_dir}{filepath: Directory to save outputs.} + +\item{equity_market_list}{character vector: List of equity markets to +include in analysis.} + +\item{scenario_sources_list}{character vector: List of scenario sources to +include in analysis. Note sources must be available in the "pacta-data".} + +\item{scenario_geographies_list}{character vector: List of scenario-defined +geographies to include in analysis. Note these geographies must be available +in the scenario data.} + +\item{sector_list}{character vector: List of sectors to include in analysis.} + +\item{start_year}{integer: Start year for analysis.} + +\item{time_horizon}{integer: Time horizon after start for analysis (usually +5 years).} +} +\value{ +No return value. Saves outputs to output_dir. +} +\description{ +This function runs the PACTA analysis for a portfolio. +} diff --git a/man/run_audit.Rd b/man/run_audit.Rd new file mode 100644 index 0000000..eab74a4 --- /dev/null +++ b/man/run_audit.Rd @@ -0,0 +1,23 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/run_audit.R +\name{run_audit} +\alias{run_audit} +\title{run_audit} +\usage{ +run_audit(pacta_data_dir, portfolio_dir, portfolio_files, output_dir) +} +\arguments{ +\item{pacta_data_dir}{filepath: Directory with "pacta-data"} + +\item{portfolio_dir}{filepath: Directory with portfolio files} + +\item{portfolio_files}{character vector: List of portfolio files to process.} + +\item{output_dir}{filepath: Directory to save outputs.} +} +\value{ +No return value. Saves outputs to output_dir. +} +\description{ +This function runs the PACTA audit for a portfolio. +} diff --git a/man/run_pacta.Rd b/man/run_pacta.Rd new file mode 100644 index 0000000..3b3ade1 --- /dev/null +++ b/man/run_pacta.Rd @@ -0,0 +1,28 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/run_pacta.R +\name{run_pacta} +\alias{run_pacta} +\title{Run PACTA} +\usage{ +run_pacta( + raw_params = commandArgs(trailingOnly = TRUE), + pacta_data_dir = Sys.getenv("PACTA_DATA_DIR"), + output_dir = Sys.getenv("ANALYSIS_OUTPUT_DIR"), + portfolio_dir = Sys.getenv("PORTFOLIO_DIR") +) +} +\arguments{ +\item{raw_params}{character or filepath: JSON string or file with parameters.} + +\item{pacta_data_dir}{filepath: Directory with "pacta-data"} + +\item{output_dir}{filepath: Directory to save outputs.} + +\item{portfolio_dir}{filepath: Directory with portfolio files} +} +\value{ +No return value. Saves outputs to output_dir. +} +\description{ +This function runs the PACTA audit and analysis for a portfolio. +} From 8e72e98762e2ef1883fde8e9e16aafd7163cc2e9 Mon Sep 17 00:00:00 2001 From: Alex Axthelm Date: Wed, 14 Aug 2024 14:47:21 +0200 Subject: [PATCH 07/12] Restore dependencies from default branch --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 902efa1..d03bb13 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -40,7 +40,7 @@ Remotes: RMI-PACTA/pacta.portfolio.audit, RMI-PACTA/pacta.portfolio.import, RMI-PACTA/pacta.portfolio.utils, - RMI-PACTA/pacta.workflow.utils@develop + RMI-PACTA/pacta.workflow.utils Suggests: testthat (>= 3.0.0), withr From d45c7810a88d5224d678a496435d864fffabe6af Mon Sep 17 00:00:00 2001 From: Alex Axthelm Date: Wed, 14 Aug 2024 14:50:37 +0200 Subject: [PATCH 08/12] Increment version number to 0.0.0.9007 --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 902efa1..c1af34c 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: workflow.pacta Title: Run PACTA -Version: 0.0.0.9006 +Version: 0.0.0.9007 Authors@R: c(person(given = "CJ", family = "Yetman", From 451583400eeca278b4a9c1d1627fd5f0f390423c Mon Sep 17 00:00:00 2001 From: Alex Axthelm Date: Wed, 14 Aug 2024 14:51:47 +0200 Subject: [PATCH 09/12] Increment version number to 0.0.0.9007 --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index d03bb13..7c109e0 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: workflow.pacta Title: Run PACTA -Version: 0.0.0.9006 +Version: 0.0.0.9007 Authors@R: c(person(given = "CJ", family = "Yetman", From e3eb398ad134b0926d4bf53443216350545fd2d2 Mon Sep 17 00:00:00 2001 From: Alex Axthelm Date: Wed, 14 Aug 2024 14:52:39 +0200 Subject: [PATCH 10/12] use `::` not `:::` now that function is exported --- R/run_pacta.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/run_pacta.R b/R/run_pacta.R index ba1f80c..601d858 100644 --- a/R/run_pacta.R +++ b/R/run_pacta.R @@ -47,7 +47,7 @@ run_pacta <- function( stop("Invalid raw input parameters.") } - params <- pacta.workflow.utils:::parse_params( #nolint + params <- pacta.workflow.utils::parse_params( #nolint json = raw_params, inheritence_search_paths = system.file( "extdata", "parameters", From d3cb2deafe6649510172a2fdcf4ee0506f828f55 Mon Sep 17 00:00:00 2001 From: Alex Axthelm Date: Wed, 14 Aug 2024 15:19:06 +0200 Subject: [PATCH 11/12] Restore main dependencies --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index c1af34c..7c109e0 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -40,7 +40,7 @@ Remotes: RMI-PACTA/pacta.portfolio.audit, RMI-PACTA/pacta.portfolio.import, RMI-PACTA/pacta.portfolio.utils, - RMI-PACTA/pacta.workflow.utils@develop + RMI-PACTA/pacta.workflow.utils Suggests: testthat (>= 3.0.0), withr From aaa04a920d21c5a32d182626d622d3a4c965e45d Mon Sep 17 00:00:00 2001 From: Alex Axthelm Date: Wed, 14 Aug 2024 16:36:31 +0200 Subject: [PATCH 12/12] Increment version number to 0.0.0.9008 --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 7c109e0..be4e79a 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: workflow.pacta Title: Run PACTA -Version: 0.0.0.9007 +Version: 0.0.0.9008 Authors@R: c(person(given = "CJ", family = "Yetman",