Let x be the closeBid price of EUR/USD, sampled every 5 minutes during year 2015 (historical data). This is the variation (is it correct to call it 5-minutes returns?) for each 5-minutes period:

r = x[1:] / x[:-1] - 1

What's the formula to have the (moving) volatility over 1 year?

I tried this way:

rolling_stddev(r, 288*10)     # 10 days, since 288 periods of 5 minutes in 1 day

The results is:

enter image description here

Is it a correct measure of volatility? (i.e. standard deviation of the returns)


First I thought about voting to close this question as it deals with Matlab synthax a lot. I ignore the Matlab stuff.

You have 5-minutes data. So an estmator of volatility over any sample of size $N$ (e.g. 100) will be an estimator of the vol of your 5-min returns. Usually volatility is quotes as "per annum" or "pa". This means that using the square root of time rule you can multiply your estimate by the number of 5-minute intervals in a year. Thus if you want to quote vola pa then $$ T = 12*24*260 = 288*260 $$ assuming 260 banking days and you multiply your estimate by $\sqrt{T}$. If you do the calculation for 10 days then $T=288*10$.

The $T$, the holding period, is independent from the number of returns that you use in order to estimate the 5-minutes vol.

Doing the things rolling does not change anything of the things above. You just push a window forward by 1 return each time.

  • $\begingroup$ This assumes sampling for the entire day (12 * 24). Would that be more accurate to do it just for the trading hours? $\endgroup$ – SmallChess Jan 8 '16 at 0:40

It's better to use an exponentially weighted moving average.

There's a nice tutorial video by the Bionic Turtle here

  • $\begingroup$ Ok for EMA, right. But more generally, is it mostly correct (to use standard deviation of returns) ? Would you multiply by some constant? $\endgroup$ – Basj Jan 7 '16 at 16:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.