Skip to content
Prev 14257 / 15274 Next

Quantstrat - extracting current symbol

Hi Brian,

thanks! Last thing, I believe I had it working prior to the weekend, but
now calling getInstrument(symbol) inside the 'add.indicator' function
results simply in error of "object 'symbol' not found".
Do I understand it correctly, that symbol can be called inside of a
function, which is then called by add.indicator()? If so, what am I doing
wrong?

My function looks as follows, its purpose is to get you flat around
expiration:

FLAT <- function(x, t = '12:00'){
  expires <- as.POSIXct(paste(getInstrument(symbol)$expires, t))
  df <- as.data.frame(index(x) >= expires)
  colnames(df) <- 'FLAT'
  FLAT <- xts(df, index(x))
  return(FLAT)
}

Regards
Oskar

2017-05-12 13:35 GMT+02:00 Brian G. Peterson <brian at braverock.com>: