joshuaulrich / TTR

Technical analysis and other functions to construct technical trading rules with R
GNU General Public License v2.0
330 stars 103 forks source link

BBands(): problem with tickers containing "LOW" in their name #17

Closed R-Hertel closed 8 years ago

R-Hertel commented 8 years ago

Dear Joshua,

While scanning some stocks I encountered a problem with the TTR::BBands function, which I use in connection with HLC(). The problem occurs with tickers containing the letter sequence LOW (such as NYSE:LOW and NYSE:PLOW). Maybe the code gets confused by the multiple occurrence of "low" in the column names while searching for the low of the price.

Here is an example:

library(quantmod)
library(TTR)
issue <- getSymbols("LOW", src="yahoo", auto.assign=FALSE)
BBands(HLC(issue))

The last command leads to the following error:

"Error in BBands(HLC(issue)) : Price series must be either High-Low-Close, or Close/univariate."

I'm not sure if the problem arises from HLC() or from BBands(), although I suspect that the former might be the culprit. Maybe it helps to point out that, for example,

ADX(HLC(issue))

does not throw any error. I'm using TTR version 0.23-0, quantmod version 0.4-5 and R version 3.2.2 on ubuntu 14.04. Thanks for looking into this.

Cheers, Riccardo

joshuaulrich commented 8 years ago

The problem is with quantmod::Lo and tickers that contain the pattern "LOW". This is a long-standing issue, as reported in quantmod issue 24.

Closing, since this is an issue in quantmod, not TTR.

R-Hertel commented 8 years ago

Thank you for your quick and insightful reply.

joshuaulrich commented 8 years ago

You're welcome. Also note that, though ADX(HLC(issue)) does not throw an error, the results are incorrect. The ADX function assumes the HLC parameter contains High, Low, and Close prices, in that order. In this example, the first three columns of the result of HLC(issue) are High, Open, High.