bug: filter financial data unusable in ownership_weight
methodology
#33
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
current_shares_outstanding_all_classes
–a value that is synonymous with theshares_all_classes
value– is used downstream to calculateownership_weight
.This value is unusable by the
ownership_weight
calculation if it is 0, as it will cause divide by 0 problems and yield Inf results: (https://github.com/RMI-PACTA/pacta.portfolio.allocate/blob/4c96adb9856788d97293e41c0cd68b8951c3c56b/R/calculate_ownership_weight.R#L5).There is already a filter in
prepare_financial_data
to remove this case, however it filters a wrong (but similar) column.An edge case was found by @Antoine-Lalechere in which ADR holdings with no similar EQ holdings pass through and yield a 0 value for
shares_all_classes
, which identified this bug.This PR adjusts the filter to ensure that the correct value is filtered and usable in the downstream analysis.
See the reprex below for more information:
Created on 2024-07-17 with reprex v2.1.1