Search code examples
rquantmod

unable to get the highest price using runMax


The runMax does not work . It shows the column High not there


library(quantmod)

data <- getSymbols("GOOG",auto.assign=TRUE)

runMax(Hi(data), 30)

Error in Hi(data): subscript out of bounds: no column name containing "High"

Traceback:

1. runMax(Hi(data), 30)

2. try.xts(x, error = as.matrix)

3. is.xts(x)

4. Hi(data)

5. stop("subscript out of bounds: no column name containing \"High\"")

the error shows "High" not there


Solution

  • The problem is not "runMax" but auto.assign. Here is the suggestion. Using auto.assign=TRUE, the variable chosen is an R-legal name derived from the symbol being loaded (see https://www.rdocumentation.org/packages/quantmod/versions/0.4.20/topics/getSymbols)

    library(quantmod)
    data <- getSymbols("GOOG",auto.assign=FALSE)
    runMax(Hi(data), 30)
    

    or

    library(quantmod)
    getSymbols("GOOG",auto.assign=TRUE)
    runMax(Hi(GOOG), 30)