Open nagbalae opened 5 months ago
The problem is with the following lines:
Rft = cbind(R, Rf)
Rft = na.locf(Rft[, make.names(coln.Rf)])
If the two objects share the same name, the Rf gets ".1" at the end, and gets filtered out
A check should be added, for example:
if (colnames(R) == colnames(Rf)){
colnames(Rf) = "Rf"
coln.Rf = colnames(Rf)
}
or simply at the if function before the cbind
if (is.null(coln.Rf) | colnames(R) == colnames(Rf)) {
colnames(Rf) = "Rf"
coln.Rf = colnames(Rf)
}
or in case this renaming to Rf is unwanted this should fix it as well
if (colnames(R) == colnames(Rf)){
colnames(Rf) = paste0(coln.Rf,".1")
coln.Rf = colnames(Rf)
}
Description
Return.excess, and other functions that use it, like Sharpe return 0-s only, if the R and Rf argument xts objects have the same column name.
Expected behavior
Return.excess returns the correct returns no mater the names of the passed objects
Minimal, reproducible example
Session Info