Skip to content
Prev 7975 / 15274 Next

Excessive data needed for volatility{TTR} calculation?

Hi James,
On Sat, May 28, 2011 at 9:44 AM, J Toll <jctoll at gmail.com> wrote:
<snip>
My last email wasn't very clear; I apologize.

I still agree with your suggestion and plan to use it as a patch.  The
first line in my prior email was to illustrate (and convince myself)
that your solution matched the formula here:
http://web.archive.org/web/20081224134043/http://www.sitmo.com/eq/172

And it only matches when NROW(OHLC) == n because your solution
operates on a rolling window and my first line operates on everything.
 Try something like this:

n <- 5
R <- cumprod(1+r)
FUN <- function(x) {
  r <- ROC(x); n <- NROW(x)
  sqrt(252/(n-2)*sum((r-mean(r, na.rm=TRUE))^2, na.rm=TRUE))
}
head(sqrt(N) * runSD(ROC(R), n-1),15)
head(rollapply(R, n, FUN, align="right", fill=NA),15)
n <- 10
head(sqrt(N) * runSD(ROC(R), n-1),15)
head(rollapply(R, n, FUN, align="right", fill=NA),15)

Sorry for the confusion.

Best,
--
Joshua Ulrich  |  FOSS Trading: www.fosstrading.com