Skip to content

Commit

Permalink
Filter so only portfolios with expected asset class are included (#112)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexAxthelm authored Oct 31, 2024
1 parent 8a2c3c8 commit 37c30e4
Showing 1 changed file with 26 additions and 5 deletions.
31 changes: 26 additions & 5 deletions main.R
Original file line number Diff line number Diff line change
Expand Up @@ -248,11 +248,32 @@ for (portfolio_name in portfolio_names) {

# -------------------------------------------------------------------------

output_files <- list.files(
temporary_directory,
pattern = "*_portfolio[.]rds$",
full.names = TRUE
)
output_files <- tibble::tibble(
path = list.files(
temporary_directory,
pattern = "*_portfolio[.]rds$",
full.names = TRUE
)
) %>%
dplyr::mutate(
port_type = dplyr::case_when(
grepl(pattern = "_Bonds_", x = path, fixed = TRUE) ~ "Bonds",
grepl(pattern = "_Equity_", x = path, fixed = TRUE) ~ "Equity",
TRUE ~ NA_character_
)
) %>%
dplyr::mutate(
expected_port_type = dplyr::if_else(
condition = grepl(pattern = "Global Corp Bond", x = path, fixed = TRUE),
true = "Bonds",
false = "Equity"
)
) %>%
dplyr::filter(
port_type == expected_port_type
) %>%
dplyr::pull(path)


logger::log_info("Combining results files.")
combined <-
Expand Down

0 comments on commit 37c30e4

Please sign in to comment.