Closed joshuaulrich closed 9 years ago
Contents of TTR_CLV_Inf.R
:
require(quantmod)
Data <- getSymbols("SPY", auto.assign=FALSE)
colnames(Data) <- sub("SPY\\.","",colnames(Data))
adjRatio <- (Data$Adjusted/Data$Close)
Data$adjOpen <- Data$Open * adjRatio
Data$adjHigh <- Data$High * adjRatio
Data$adjLow <- Data$Low * adjRatio
Data$adjVolume <- Data$Volume / adjRatio
# this includes Inf (HLC includes multiple columns)
range(CLV(HLC(Data)))
# [1] -Inf 0.9634922
# this works as expected
range(CLV(Data[,c("adjHigh","adjLow","Adjusted")]))
# [1] -1 1
Submitted by: Sarvesh S G Assigned to: Joshua Ulrich R-Forge link
add line
clv[is.infinite(clv)] <- 0 in CLV function
Followups:
Date: 2014-09-19 11:32 Sender: Joshua Ulrich Changing to accepted. Fixed in r178. Issue arose when H == L, but H != C and L != C due to machine precision. In that case, division of a non-zero number by zero occurs, which results in +/-Inf.
Date: 2014-09-17 23:58 Sender: Joshua Ulrich Reproducible example given by Sarvesh via email is attached in TTR_CLV_Inf.R. Issue that creates Inf values only occurs when you pass more than the 3 HLC columns to CLV. Closing/rejecting as an unnecessary change.