From becdd7ef293d0c6872b48b0415da0fb53a9cd8f6 Mon Sep 17 00:00:00 2001 From: Alex Axthelm Date: Thu, 15 Aug 2024 10:04:02 +0200 Subject: [PATCH] Export functions (#84) --- DESCRIPTION | 2 +- NAMESPACE | 4 +++ R/calc_weights_and_outputs.R | 23 ++++++++++++++ R/run_analysis.R | 19 ++++++++++++ R/run_audit.R | 10 +++++++ R/run_pacta.R | 10 +++++++ man/calc_weights_and_outputs.Rd | 53 +++++++++++++++++++++++++++++++++ man/run_analysis.Rd | 45 ++++++++++++++++++++++++++++ man/run_audit.Rd | 23 ++++++++++++++ man/run_pacta.Rd | 28 +++++++++++++++++ 10 files changed, 216 insertions(+), 1 deletion(-) 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/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", 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/R/calc_weights_and_outputs.R b/R/calc_weights_and_outputs.R index 93a5b40..af0c197 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, diff --git a/R/run_analysis.R b/R/run_analysis.R index c30e369..963181d 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, diff --git a/R/run_audit.R b/R/run_audit.R index df908f7..4348589 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, diff --git a/R/run_pacta.R b/R/run_pacta.R index 601d858..c843e72 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"), 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. +}