#' assets_mani
#'
#' @description Take asset from other classes than cryptocurrencies, transform them to xts object and restrict to look at only non-na's and
#' between 2014 and 2018-09-27. Using closing prices except for currencies where opening are used.
#'
#' @param assetList List of assets
#' @param currency Logical type of asset used
#'
#' @return xts object with closing prices and columns
#' @export
#'
assets_mani <- function(assetList, AssetType = c("other", "currency", "ZCB")) {
if(AssetType == "ZCB") {
AssetNames <- character(length(assetList))
for(i in 1:length(assetList)) {
AssetNames[i] <- colnames(assetList[[i]])
}
out <- do.call(cbind, lapply(assetList, function(x){
xts::xts(x = x[,1], order.by = zoo::index(x))
}))
out <- zoo::na.locf(out)
colnames(out) <- AssetNames
if(length(unique(which(is.na(out), arr.ind = TRUE)[,1])) > 0){
out <- out[-unique(which(is.na(out), arr.ind = TRUE)[,1]),]
}
out <- out["2014/2018-09-27"]
} else {
colUsed <- ifelse(AssetType == "currency", "Open", "Close")
out <- do.call(cbind, lapply(assetList, function(x){
xts::xts(x = x[,colUsed], order.by = x$`Exchange Date`)
}))
out <- zoo::na.locf(out)
colnames(out) <- names(assetList)
if(length(unique(which(is.na(out), arr.ind = TRUE)[,1])) > 0){
out <- out[-unique(which(is.na(out), arr.ind = TRUE)[,1]),]
}
out <- out["2014/2018-09-27"]
}
return(out)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.