For my analysis I need a measure of volatility for government bonds. On Bloomberg I could not find any good measure of volatility - they offer some measures which are based on the close prices of each day (that is, from each day only one number is used), which is not precise enough, since I would like to have a measure of volatility for every day (fluctuations during the day).
However, from Bloomberg I can get open price, close price, high price and low price. The difference between high price and low price could be a simple measure which I could use to distinguish between days with large and small fluctuations. But are there some other ways to use these four numbers to get an estimation of volatility for every day? Thanks!
UPDATE: I can see in the comments that I can use Garman Klass volatility. I have tried to use in the package TTR, but a few things do not make sense to me. If I use the example in the help file:
library(TTR)
data(ttrc)
ohlc <- ttrc[,c("Open","High","Low","Close")]
MyVolatility=volatility(ohlc, calc="garman.klass")
Then MyVolatility will have an estimate for each day. But
How does it know which variables are which? I have tried to change the name of "Close" to another name, and it still gives the calculations. So, should the variables have this exact ordering?
Does it automatically take the right parameters, like N or is there something I need to specify?
In this example the first 9 estimates in the MyVolatility are NA. Does that mean that each day's volatility is based on 9 days and not on single day? I mean, would it make sense to use this estimate to determine whether day t is different from day t+1 in terms of fluctuations?
Finally, is there a way for it to stop giving error if one of the numbers is missing? Like, in other functions one can use na.rm=T.
To sum up, I would like to know the following. Suppose I have a dataframe MyData with many variables including Date, High_Price, Low_Price, Open_Price, Close_Price, and I would like to mutate the volatility estimate for each day like in dplyr. What do I have to write in my code?
And what if I have different bonds in my dataset, is it possible to use dplyr with a group_by?
Thanks a lot!