BardParticipant
Master
Which is the correct formula (or approximation) for Daily, 30 Day Historical Volatility (HV)?:
ivolatility uses the second formula: https://www.ivolatility.com/help/2.html#hv
I found the first set of code on PRC.
annualVol = 252
HVPeriod = 30
periods = 7// 1 = intraday chart 7 = daily chart
Returns = log(close / close[1])
StdDev = std[HVPeriod](Returns)
HVol = (StdDev * sqrt(annualVol / periods)) * 100
or:
annualVol = 252
HVPeriod = 30
//periods = 7// 1 = intraday chart 7 = daily chart
Returns = log(close / close[1])
StdDev = std[HVPeriod](Returns)
HVol = StdDev * sqrt(annualVol) * 100
Also shouldn’t it be:
Returns = log(close [HVPeriod] / close[HVPeriod-1])
because it’s the sample std deviation we’re calculating?
Thanks, it’d be good to clear this up as I see it has been discussed in these forums.
I don’t think so, because in this case, in real time, you are calculation a standard deviation offset HVPeriod in the past.
BardParticipant
Master
“Offset?”
Why do ivolatility state for HV calculations: https://www.ivolatility.com/help/2.html#hv
Note: In denominator we use n-1 instead of n to receive unbiased estimate of general dispersion (a square of a standard deviation). This adjustment is essential if we estimate standard deviation on the basis of a small number of observations.
Same with this quant site in Step #1: https://www.macroption.com/historical-volatility-calculation/
So wouldn’t n-1 be more appropriate if we’re attempting to calculate small samples of 10, 30 and 30 day returns from 252 periods?
Also why is there a divide by “periods” in the first formula – what is that doing, is it needed?
Cheers!