Page 1 of 1

Sum of squared intraday returns - daily realized volatility

Posted: Wed Jun 08, 2011 3:36 pm
by Farid
Hi everybody,

I'm new to RATS and have some difficulties with calculating daily realized volatility. Daily realized volatility is calculated as "sum of squared intraday returns".

My data consist of 15 min interval prices (from 9 am till 14:30 pm - 22 entries a day). In the "Data Transformation" chapter of RATS manuals I wasn't able to find anything about transforming several entries into one in a continuous form (sum of squared 22 returns into one daily return in my particular case).

After tranforsming 15 minute prices into returns as log (P - P{1}) I need to make summation of the squared values of these returns and have only daily return per day.

Could you please give me some instructions?

Thanks,

Farid

Re: Sum of squared intraday returns - daily realized volatil

Posted: Fri Jun 10, 2011 4:20 pm
by moderator
There are probably a few ways to go about that.

One would be to read in the data using a 22 period per day CALENDAR, compute the squared returns, and then write those new series out to a (dated) RATS format file. Then, in a second program or session, set a daily CALENDAR and read in the squared data, using the COMPACT=SUM option on the DATA instruction. This will take advantage of the support in RATS for automatically converting one frequency to another--in this case by taking the sums.

If you want to do it all in one program, another option is to use MVSTATS to compute the means over a moving window of 22 periods, multiply those by 22 to get the sums, and then use SAMPLE with the INTERVAL option to create compressed series containing only the 22nd observation from each moving sum.

Note that the "per day" date scheme set by the CALENDAR will not match up with the observations in the compressed series, so you may want to change the CALENDAR to daily at that point in the program, for any further analysis with the compressed data.

Regards,
Tom Maycock
Estima

Re: Sum of squared intraday returns - daily realized volatil

Posted: Fri Jun 10, 2011 6:16 pm
by Farid
Thanks for response Tom.

The first option looks fine to me. I looked through my dataset, some entries are missing. So it's not always 22 entries per day (on some days it's even 3-4 entries per day). Could suggest any solution for that?

Farid

Re: Sum of squared intraday returns - daily realized volatil

Posted: Mon Jun 13, 2011 4:09 pm
by moderator
If the data file has (or can be made to have) a constant number of periods per day, even though some (many) may be missing/NA, that first approach should work fine. Any missing values are just omitted from the computation.

If it's not easy to get the source data file into a regular form like that, it gets complicated. Details would depend on exactly what you have to work with in the file. If, for example, you can get separate columns of year, month, day information that could be read in as series, you could read it in as an undated set and write some loops to compute the sums based on looking at the year, month, day series.