Rebalance dates via `weights` xts object does not match documentation for `Return.portfolio.arithmetic`
Closed this issue · 1 comments
According to the documentation for Return.portfolio
rebalance_on
parameter:
Ignored [rebalance_on parameter] if weights is an xts object that specifies the rebalancing dates.
However, I observe that the behavior of the code is only consistent with this documentation for Return.portfolio(..., geometric=TRUE)
NOT Return.portfolio(..., geometric=FALSE)
.
Specifically, for geometric=FALSE
, Return.portfolio
re-balances on every observation within the R
asset returns argument regardless of the weights
is specified with a rebalancing dates or if the rebalance_on
argument is used.
Here is a simple reproducible example:
data(edhec)
data <- edhec['199701/199704', 1:2]
ret_geo <- Return.portfolio(data, rebalance_on = 'quarters', verbose = TRUE, geometric = TRUE)
ret_geo$BOP.Weight
## Note that BOP.Weight only re-sets to 50/50 on a quarterly basis
## Convertible Arbitrage CTA Global
## 1997-01-31 0.5000000 0.5000000
## 1997-02-28 0.4933210 0.5066790
## 1997-03-31 0.4890374 0.5109626
## 1997-04-30 0.5000000 0.5000000
ret_ari <- Return.portfolio(data, rebalance_on = 'quarters', verbose = TRUE, geometric = FALSE)
ret_ari$BOP.Weight
## Note that BOP.Weight re-sets to 50/50 at EVERY OBS
## Convertible Arbitrage CTA Global
## 1997-01-31 0.5 0.5
## 1997-02-28 0.5 0.5
## 1997-03-31 0.5 0.5
## 1997-04-30 0.5 0.5
I dug into Return.portfolio.arithmetic
and it looks like the following line should be replaced:
bop_weights[k, ] = weights[i, ]
I believe it should be:
if (j == 1) {
bop_weights[k, ] = weights[i, ]
} else {
bop_weights[k, ] = eop_weights[k - 1, ]
}
Please let me know you think. I can open a PR to fix this if you do indeed agree it is a bug or otherwise needs an update. Thanks in advance.
@jmuhlenkamp Thanks for the reminder. Yes, please open a PR and I'll test it.