Skip to content

Commit

Permalink
Allow missing EQ or CB results (#56)
Browse files Browse the repository at this point in the history
* Increment version number to 0.0.0.9010

* add more logging

* add bonds-only portfolio

ISIN from https://www.shell.com/investors/debt-information/outstanding-bonds.html

* add equity-only portfolio

ISIN from https://www.shell.com/investors/information-for-shareholders/share-information.html

* Add testing configs to CI tests

* Check for file existence before reading
  • Loading branch information
AlexAxthelm authored Jan 6, 2025
1 parent df295d0 commit 940f429
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 5 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ jobs:
- default_2023Q4
- full_params_2022Q4
- full_params_2023Q4
- only-cb_2023Q4
- only-eq_2023Q4
with:
full-image-name: ${{ needs.docker.outputs.full-image-name }}
config-name: ${{ matrix.config-name }}
Expand Down
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: workflow.pacta.dashboard
Title: Run PACTA dashboard JSON generation
Version: 0.0.0.9009
Version: 0.0.0.9010
Authors@R:
c(person(given = "Alex",
family = "Axthelm",
Expand Down
30 changes: 26 additions & 4 deletions R/prepare_pacta_dashboard_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,35 @@ scen_geo_levels <- unlist(manifest$params$analysis$scenarioGeographiesList)
# load results from input directory --------------------------------------------
log_debug("Loading results from input directory.")

log_trace("Loading audit_file.rds")
audit_file <- readRDS(file.path(analysis_output_dir, "audit_file.rds"))

log_trace("Loading emissions.rds")
emissions <- readRDS(file.path(analysis_output_dir, "emissions.rds"))
equity_results_portfolio <- readRDS(file.path(analysis_output_dir, "Equity_results_portfolio.rds"))
bonds_results_portfolio <- readRDS(file.path(analysis_output_dir, "Bonds_results_portfolio.rds"))
equity_results_company <- readRDS(file.path(analysis_output_dir, "Equity_results_company.rds"))
bonds_results_company <- readRDS(file.path(analysis_output_dir, "Bonds_results_company.rds"))

equity_results_portfolio_path <- file.path(analysis_output_dir, "Equity_results_portfolio.rds")
if (file.exists(equity_results_portfolio_path)) {
log_trace("Loading Equity_results_portfolio.rds")
equity_results_portfolio <- readRDS(equity_results_portfolio_path)
log_trace("Loading Equity_results_company.rds")
equity_results_company <- readRDS(file.path(analysis_output_dir, "Equity_results_company.rds"))
} else {
log_warn("Equity_results_portfolio.rds not found. Creating empty data frame.")
equity_results_portfolio <- pacta.portfolio.utils::empty_portfolio_results()
equity_results_company <- pacta.portfolio.utils::empty_company_results()
}

bonds_results_portfolio_path <- file.path(analysis_output_dir, "Bonds_results_portfolio.rds")
if (file.exists(bonds_results_portfolio_path)) {
log_trace("Loading Bonds_results_portfolio.rds")
bonds_results_portfolio <- readRDS(bonds_results_portfolio_path)
log_trace("Loading Bonds_results_company.rds")
bonds_results_company <- readRDS(file.path(analysis_output_dir, "Bonds_results_company.rds"))
} else {
log_warn("Bonds_results_portfolio.rds not found. Creating empty data frame.")
bonds_results_portfolio <- pacta.portfolio.utils::empty_portfolio_results()
bonds_results_company <- pacta.portfolio.utils::empty_company_results()
}

# data from PACTA inputs used to generate the results --------------------------
log_debug("Loading benchmark results.")
Expand Down
15 changes: 15 additions & 0 deletions tests/config/only-cb_2023Q4.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"holdingsDate": "2023Q4",
"pactaDataURL": "https://pactadatadev.blob.core.windows.net/pacta-data-webapp/2023Q4/2023Q4_20240424T120055Z",
"benchmarksURL": "https://pactadatadev.blob.core.windows.net/benchmarks-webapp/2023Q4/2023Q4_20240529T002355Z",
"parameters": {
"portfolio": {
"holdingsDate": "2023-12-31",
"files": [
"bonds_portfolio.csv"
],
"name": "Default Portfolio"
},
"inherit": "GENERAL_2023Q4"
}
}
15 changes: 15 additions & 0 deletions tests/config/only-eq_2023Q4.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"holdingsDate": "2023Q4",
"pactaDataURL": "https://pactadatadev.blob.core.windows.net/pacta-data-webapp/2023Q4/2023Q4_20240424T120055Z",
"benchmarksURL": "https://pactadatadev.blob.core.windows.net/benchmarks-webapp/2023Q4/2023Q4_20240529T002355Z",
"parameters": {
"portfolio": {
"holdingsDate": "2023-12-31",
"files": [
"equity_portfolio.csv"
],
"name": "Default Portfolio"
},
"inherit": "GENERAL_2023Q4"
}
}
2 changes: 2 additions & 0 deletions tests/portfolios/bonds_portfolio.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
isin,market_value,currency
US822582AD40,1000000,USD
2 changes: 2 additions & 0 deletions tests/portfolios/equity_portfolio.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
isin,market_value,currency
GB00BP6MXD84,1000000,USD

0 comments on commit 940f429

Please sign in to comment.