<div dir="ltr">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.<br><br>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. <br><br>For instance, here's an obligatory minimum reproducible example:<div><br><div>posRets <- rep(.003, 63)<br></div><div>posRets <- cbind(posRets, 0)</div><div>posRets <- xts(posRets, <a href="http://order.by">order.by</a>=as.Date(c(1:63)))<br></div><div>wts <- rbind(c(0,1), c(1,0), c(0,1), c(1,0))<br></div><div>tmp <- endpoints(posRets)<br></div><div>tmp[1] <- 1</div><div>wts <- xts(wts, <a href="http://order.by">order.by</a>=index(posRets)[tmp])</div><div>out <- Return.portfolio(R = posRets, weights = wts)</div><div><br></div><div>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.  <br><br>This is not the case.<br><br></div><div><div><img src="cid:ii_k3qa79lq0" alt="image.png" width="325" height="265"><br></div></div><div><br></div><div>Is there a lag setting in Return.portfolio to account for this, or should I write the function myself?</div></div></div>