I am trying to do a standard realized volatility calculation in python using daily log returns, like so:

window = 21
trd_days = 252
ann_factor = window/trd_days

rlz_var = underlying_df['log_ret'].rolling(window).var() * ann_factor
rlz_vol = np.sqrt(rlz_var)

I am essentially getting a realized vol value for each day in my dataset, hence the rolling window over roughly the past month (21 days), and then multiplying the var of this by the annualization factor.

Output with some SPY data:

enter image description here

Is this a sensible and industry way of going about calculating realized vol? If not, what would be a more appropriate calculation be?

  • 1
    $\begingroup$ IMO, there is generally no "industry" preferred way of calculating realized vol. Volatility is a latent process and there exists many different schemes trying to get the most accurate estimate out of the information you have available. If you are working with OHLC the Garman-Klass estimator (or slight modifications) seems "popular". If you have access to high-frequency data then you can utilize the increased informational gain to your advantage and produce better estimates using the realized variance estimator or eg. the Subsampled approach (ie. more information = better estimates). [1/2] $\endgroup$
    – Pleb
    Commented Mar 10, 2022 at 15:47
  • 1
    $\begingroup$ Within the area of financial econometrics, it is still a hot topic trying to find better estimators for realized volatility/variance with applications toward risk management or portfolio construction. If you only have daily log-returns available your method will likely get you some adequate results. You can try and play around with the window-length and see how your end results differ. Alternative suggestions might not get you much further of producing better end results. [2/2] $\endgroup$
    – Pleb
    Commented Mar 10, 2022 at 15:50
  • $\begingroup$ thanks! will definitely look into the GK estimator. However is the rolling window approach a common way to get a daily value for realized vol? i.e. if I implement the GK estimator and calculate realized vol in the same rolling manner to get daily values, is it sensible? $\endgroup$
    – des224
    Commented Mar 10, 2022 at 16:01
  • 1
    $\begingroup$ From a research perspective, this is fine when realized volatility is not your main focus and you're just trying to explain key concepts of your paper. As an example, take a look at this applied paper produced by people from Man AHL. Here, they're plotting the rolling standard deviation in Exhibit 6 & 10. Also, in one of DE Shaws research paper (figure 3) they are using rolling standard deviations. When realized vol has a significant matter, they usually do something different, since they have access to much more data of better quality. $\endgroup$
    – Pleb
    Commented Mar 10, 2022 at 19:20


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.