I am having trouble pulling in data from Excel into T and calculating OHLC volatility using TTR. I am using the following code (I have also attached the code for your review).
The output generated by volatility(ohlc, calc="gk.yz") is downward sloping... almost like a decay function. It looks completely wrong when I compare it to the data pulled from Yahoo Finance. Am I doing something wrong with how I am pulling the data? Appreciate any help or advice you could offer.
Best,
Stephen
Using the following packages: quantmod, xlsx, xts, zoo.
##R Code to pull data from Bloomberg/Excel & use quantmod/TTR
x=read.xlsx("Test OHLC Data.xlsx",sheetIndex=1)
x
x[1:756,1:5]
X=x[1:756,1:5]
X
summary(X)
typeof(X)
typeof(X$Open)
is.numeric(X$Open)
is.na(X)
str(X)
xts(X[,-1],order.by=X$NA.)
NewX=xts(X[,-1],order.by=X$NA.)
chartSeries(NewX)
is.OHLC(NewX)
has.Vo(NewX)
OHLC(NewX)
Op(NewX) ##Test - brings open data
Cl(NewX) ##Test - brings close data
HiCl(NewX) ##Test - brings in % change from Hi Low
plot(HiCl(NewX),type='l')
mean(HiCl(NewX))
ohlc = OHLC(NewX)
ohlc
volatility(ohlc,calc="garman")
IntraVol1=volatility(ohlc,calc="garman")
volatility(ohlc,calc="gk.yz")
IntraVol2=volatility(ohlc,calc="gk.yz")
I am having trouble pulling in data from Excel into T and calculating OHLC volatility using TTR. I am using the following code (I have also attached the code for your review).
The output generated by
volatility(ohlc, calc="gk.yz")
is downward sloping... almost like a decay function. It looks completely wrong when I compare it to the data pulled from Yahoo Finance. Am I doing something wrong with how I am pulling the data? Appreciate any help or advice you could offer.Best, Stephen
Using the following packages: quantmod, xlsx, xts, zoo.