#' @title clean_endpoints
#' @description Trims the series of endpoints so that it can be used with various models.
#' @param rets_xts an xts of asset returns
#' @param offset numeric, the number of periods to lag/lead the endpoints
#' @return A numeric of endpoint values.
#' @export
#' @importFrom xts endpoints last
clean_endpoints <- function(rets_xts, offset = 0)
{
ep <- xts::endpoints(rets_xts) + offset
ep[ep < 1] <- 1
ep[ep > nrow(rets_xts)] <- nrow(rets_xts)
ep <- unique(ep)
epDiff <- diff(ep)
if(xts::last(epDiff)==1) ep <- ep[-length(ep)]
ep
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.