How to lag Return.portfolio a day?

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

How to lag Return.portfolio a day?

Ilya Kipnis
So, quick question in case this is already implemented in Return.portfolio, but this is something that's been bugging me for a while now.

Say you're backtesting a momentum strategy, with your rebalance dates being monthly endpoints. While in a perfect world, you'd get your closing data at the close and have time to rebalance the strategy right then and there, in the real world, you might not have closing data until the next morning--or you're a large fund that takes a day to move capital into position, or whatever other real-world constraint. 

For instance, here's an obligatory minimum reproducible example:

posRets <- rep(.003, 63)
posRets <- cbind(posRets, 0)
posRets <- xts(posRets, order.by=as.Date(c(1:63)))
wts <- rbind(c(0,1), c(1,0), c(0,1), c(1,0))
tmp <- endpoints(posRets)
tmp[1] <- 1
wts <- xts(wts, order.by=index(posRets)[tmp])
out <- Return.portfolio(R = posRets, weights = wts)

Now, given that the weights are allocated at the end of every month, if we have a 1-day lag to account for execution, I'd expect the first day of each new month to be identical to the day before it. That is, if the previous month had a zero return because it was invested in the second asset, then the first day of the new month should also have a zero return, and vice versa.  

This is not the case.

image.png

Is there a lag setting in Return.portfolio to account for this, or should I write the function myself?

_______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-finance
-- Subscriber-posting only. If you want to post, subscribe first.
-- Also note that this is not the r-help list where general R questions should go.