Skip to content

Commit

Permalink
utilize new pacta.data.preparation::prepare_fund_data() function (#193
Browse files Browse the repository at this point in the history
)

- [x] depends on
https://github.com/RMI-PACTA/pacta.data.preparation/pull/351

Note: currently `threshold = 0` is used to maintain current behavior,
though a more strict threshold is probably desirable

Co-authored-by: CJ Yetman - RMI <[email protected]>
  • Loading branch information
cjyetman and CJ Yetman - RMI authored Mar 15, 2024
1 parent dc8adb2 commit 9068d4f
Showing 1 changed file with 5 additions and 24 deletions.
29 changes: 5 additions & 24 deletions run_pacta_data_preparation.R
Original file line number Diff line number Diff line change
Expand Up @@ -486,33 +486,15 @@ logger::log_info("ABCD flags prepared.")

logger::log_info("Preparing fund data.")

fund_data <- readRDS(factset_fund_data_path)

# remove funds above the threshold
fund_data <-
fund_data %>%
group_by(factset_fund_id, fund_reported_mv) %>%
filter((fund_reported_mv[[1]] - sum(holding_reported_mv)) / fund_reported_mv[[1]] > -1e-5) %>%
ungroup()

# build MISSINGWEIGHT for under and over
fund_missing_mv <-
fund_data %>%
group_by(factset_fund_id, fund_reported_mv) %>%
summarise(
holding_isin = "MISSINGWEIGHT",
holding_reported_mv = fund_reported_mv[[1]] - sum(holding_reported_mv),
.groups = "drop"
) %>%
ungroup() %>%
filter(holding_reported_mv != 0)

bind_rows(fund_data, fund_missing_mv) %>%
readRDS(factset_fund_data_path) %>%
pacta.data.preparation::prepare_fund_data(threshold = 0) %>%
saveRDS(file.path(config[["data_prep_outputs_path"]], "fund_data.rds"))


logger::log_info("Saving file: \"total_fund_list.rds\".")
pacta.data.preparation::prepare_total_fund_list(fund_data) %>%

readRDS(file.path(config[["data_prep_outputs_path"]], "fund_data.rds")) %>%
pacta.data.preparation::prepare_total_fund_list() %>%
saveRDS(file.path(config[["data_prep_outputs_path"]], "total_fund_list.rds"))


Expand Down Expand Up @@ -544,7 +526,6 @@ isin_to_fund_table %>%
saveRDS(file.path(config[["data_prep_outputs_path"]], "isin_to_fund_table.rds"))


rm(fund_data)
rm(isin_to_fund_table)
invisible(gc())

Expand Down

0 comments on commit 9068d4f

Please sign in to comment.