#converts OHLC.. data into the format needed for function f
#' Title
#'
#' @param data OHLC data
#' @param fun function which uses time series data
#'
#' @return select.OHLC
#' @import quantmod
#' @export select.OHLC
#'
#'
#' @examples select.OHLC(msci_world, TTR:CCI)
select.OHLC <- function (data, fun) {
#if fun is not a function create an OHLC object
if (is.function(fun) == FALSE) {
input_obj <- NA
data_correct <- OHLC(data)
} else {
#get formal argument of function for condition
input_obj <- names(formals(fun))[1]
}
#reformat OHLC object as needed for the function fun
if (grepl("HLC", input_obj) == TRUE) {
data_correct <- HLC(data)
}
if (grepl("x", input_obj) == TRUE) {
data_correct <- Cl(data)
}
return(data_correct)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.