// Looping over the timeseries LR = Math.log(currentPrice / oldPrice); LRsq.push(LR*LR); ... sum up etc ... vol = 100 * Math.sqrt( ( annualisation/noPoints ) * sumLogReturnsSquared )
I'm pretending that there are 260 trading days (annualisation) in the year and given that this is intra-day stuff, the number of points obviously gets increased accordingly based on the fixing frequency (noPoints).
So far so good. However, I want to turn the application into something a little more real-time, without storing historical data every second in my application.
I want to continue to keep my fixings at every minute on the minute, but want to show changes to the realized vol every second. My approach would be to use my fixings as normal to calculate all but the last log return. Then, I would calculate a last and final log return for the window. This last and final log could be calculated after only 17 seconds (instead of 60). Accordingly, I was thinking of using some special weighting by elapsed that reduces its overall contribution to the sum of the Log Returns Squared.
This way I can update realized vol every second, without storing more than minutely data.
Does this approach make sense? If so, how would you weight the last log return?