29
May
2007
Posted by Tom as Algorithmic Trading System, Excel, Tutorials
Hi there! This is one my most popular posts and I would love it if you became an RSS Reader!
The inspiration for my S&P500 Volatility Timing model came from rereading portions of Mandelbrot’s book, The (Mis)Behavior of Markets, and trolling around the Internet for Nassim Taleb’s research work on risk. I think both guys push the envelope on truly understanding unseen risk and those pesky financial asteroids. Since my model is currently being developed, I thought it would be worth my while to truly learn and understand how historical volatility (HV) is calculated. I first searched the Internet for any free data downloads of HV but came across several pay for data download sites.
One of them, iVolatility.com, seemed to have comprehensive data but it was expensive. One year’s worth of HV for one asset price would’ve cost me $5! So what does any engineering type person do in the face of expensive solutions? He (or she) build’s their own cheaper solution. I decided to calculate HV on my own after reading about it on wikipedia. Now, I’m submitting this analysis for peer review as I’m treading in unfamiliar waters. Please feel free to correct me if my computations or understanding of the material is wrong.
Wikipedia defines HV as:
The annualized volatility σ is the standard deviation σ of the instrument’s logarithmic returns in a year.
Furthermore,
The generalized volatility σT for time horizon T in years is expressed as:
.
Note: There’s a flaw in the Wikipedia’s formula logic after the generalized volatility formula above as pointed out by C++ Trader (thanks for the catch). Please see the related links below for more information on the correct calculation of HV.
Note that the formula used to annualize returns is not deterministic, but is an extrapolation valid for a random walk process whose steps have finite variance.
So the first step is to calculate the S&P500’s logarithmic returns for a year. I’ll be using the weekly time series and I’ll analyze it in a handy Excel spreadsheet here: HV Example.xls
Once again I’ll turn to wikipedia for an explanation of logarithmic returns:
Academics use in their research natural log return called logarithmic return or continuously compounded return. The continuously compounded return is asymmetric thus clearly indicating that positive and negative percent returns are not equal. A 10% return results in 9.53% continuously compounded return while a -10% results in -10.53%. This clearly indicates that the investment will result in a dollar amount loss corresponding to the difference between the absolute values of the two numbers: 1% (this is an approximate equality).
- Vi is the initial investment value
- Vf is the final investment value
.
- ROILog > 0 is profit
- ROILog < 0 is a loss
- Doubling occurs when
- Total loss occurs when
.
This should be straightforward and I will calculate the weekly ROI for the S&P500. Why? Well I’m interested in calculating weekly HV so my Vi will be the week(1)’s closing price and Vf will be week(2)’s closing price. For the next iteration Vi will be the week(2)’s closing price and Vf will be week(3)’s closing price and so forth.
Next I created an Excel Macro that would calculate the natural log and simultaneously calculate the HV for 10, 20, and 30 days using the standard deviation of the daily logarithmic returns multiplied by 252 (see related links below).
There you have it, your very own weekly HV! Feel free to download the Excel macro and play with it. By all means, please critique my analysis and let me know if my logic is flawed! The more I learn about this, the more my ATS takes shape!
Update: The Excel Macro matches the output from iVolatility.com for the 10, 20, and 30 day HV’s. Check!
Related:
11 Responses
Neuro
May 23rd, 2007 at 9:39 am
1I am on the same boat with ATS. Keep up !!!
My tools are Genetic Programming and C++
Tom
May 23rd, 2007 at 12:17 pm
2Neuro: Thanks for stopping by! I’d love to learn C++ but I have no time for it. I end up building macros and programming (limited) in Excel!
Ernst
May 24th, 2007 at 8:29 am
3Hi: I am working on a similar model. I have decided to use the VIX for my volatility. I am also going to add the premium for the VIX ATM put strike.
The VIX is real money (big money) telling you how much movement you can expect in the (near) future.
For instance if you check the VIX of the last two months and project the premium for the ATM put strike. You see that fear is building up. In March and April every time the market went up a couple of day the VIX ATM put strike would cost you around 40/50ct. Telling you that the market expected expiry with a VIX around 11.50. The last couple of weeks after weeks of up days the market the premium does not come back into the put strikes. Telling me the market does not expect the VIX to come down soon.
Tom
May 24th, 2007 at 8:37 am
4Ernst,
Interesting. We should compare notes maybe there’s something we can collaborate on? Would you contact me directly at desertroot -at- gmail dotcom? I’ll pass on some charts I’ve created using my model.
cpptrader
May 25th, 2007 at 3:58 pm
5Unless there is something I am unfamiliar with, Wikipedia has the estimated vol equation wrong. The denominator is not sqrt(1/t), it is simply sqrt(t). A book I am reading (Introduction to High Frequency Finance) explained it using only t, and I found a couple sources online that equate it with only t in the denominator, not 1/t. For example, I found this site at the university of nebraska: http://www.math.unl.edu/~sdunbar1/Teaching/MathematicalFinance/Lessons/BlackScholes/ImpliedVolatility/impliedvolatility.shtml
Like I said, maybe I am missing something but I don’t think so. Just FYI
Tom
May 26th, 2007 at 6:44 am
6Cpptrader: Thanks, I came across something a few minutes ago that corroborates your statement. I’m glad I opened this up to the public for scrutiny.
I’m going to make changes to it and republish!
Daniel
June 3rd, 2007 at 11:50 pm
7Hey dude! Read your post from the blog carnival. check out this post http://israelispeculator.com/blog/estimating-future-volatility-of-a-stock-like-the-pros/
admin
June 4th, 2007 at 6:08 am
8Daniel,
I checked out your blog and I like it. I’m traveling right now so I’ll read it in detail when I get back. Thanks!
Career Advice by Randy
June 18th, 2007 at 2:27 pm
9festival of investing - June 12, 2007…
Welcome to the June 12, 2007 edition of festival of investing.
Tushar Mathur presents Financial Planner: Do I need one ? posted at Life of a Resident Alien….
Thomas Ott presents Calculating Historical Volatility posted at Neural Market Trend…
john
June 5th, 2008 at 3:04 pm
10Tom,
Being a mediocre quantitative finance student, i think that (not sure though) while calculating volatility, the choice of return depends on for what you are going to use it for.
Like, if you are going to use it in a b&s formula (continuous time), you have to calculate the log returns, but if you are going to work in discrete time, then you should calculate volatility from arithmetic returns. However, I dont think there will be a big difference..
Tom
June 6th, 2008 at 5:25 am
11John, for most of my HV calculations I use natural log (LN) to calculate the continuously compounded return and then a standard deviation at some time period for those cc returns. The HV calculations are different than calculating volatility for Implied Volatility.
RSS feed for comments on this post · TrackBack URI
Leave a reply
previous post: Forex Thoughts
next post: Chipotle Mexican Grill, Inc. - (CMG)
to top of page...