Skip to content

Commit

Permalink
replace with lag.xts to decrease bad behavior by the tidyverse
Browse files Browse the repository at this point in the history
  • Loading branch information
braverock committed Dec 9, 2024
1 parent 7ae051f commit 3d4f210
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion R/to.period.contributions.R
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ to.period.contributions <- function(Contributions, period = c("years", "quarters
# Calculate period return of portfolio from contributions
pret = rowSums(C)
pret = xts(pret, order.by=index(C))
lag.cum.ret = na.fill(lag(cumprod(1+pret),1),1)
lag.cum.ret = na.fill(xts::lag.xts(cumprod(1+pret),1),1)
wgt.contrib = C * rep(lag.cum.ret, NCOL(C))

# Calculate aggregation periods
Expand Down

0 comments on commit 3d4f210

Please sign in to comment.