# Option Trading - Calculating Historical Volatility

 Historical Volatility Implied Volatility CBOE volatility Index Steps For Calculating Historical Volatility C++ Program For Historical Volatility Input Data Output Data

Historical Volatility

Historical Volatility is the volatility occurred in the recent past with the given time, may be 10 days, 20 days, 30 days, etc.

Top

Implied Volatility

Implied volatility of a stock is the future volatility and is calculated using the derivatives of the underlying stock. The factors used in calculating implied volatility is Risk Free Rate, strike price of the option, time to maturity and option's price.

Top

CBOE volatility Index

The ticker symbol for CBOE volatility index is VIX. It represents the implied options volatility of S&P 500. It includes the out of the money options also for calculation. VXO is another ticker symbol and it does include only at the money options.

Top

Steps For Calculating Historical Volatility

1. Get the historical closing the price of a stock for your desired time range. In this example, we have taken the last 31 days as of today 21st May 2010.

2. Calculate % gain or loss using logarithmic price scale, that is log of end price divided by start price for each day. For 31 days, we will get a list of 30 days of % gain or loss. Lets call this collection as arrPercentage.

3. Then calculate the standard deviation for arrPercentage for 10 days. If we need a different range, we can calculate standard deviation for 20 days or 30 days.

4. Then multiply the resultant with square root of 252. This number 252 represents the number of trading days in a year. That is 365 - (52 week-ends = 104 days) - (9 public holidays).

Top

C++ Program For Historical Volatility

Here is the C++ program to calculate historical Volatility.

int _tmain(int argc, _TCHAR* argv[])
{
double arrClosingPrice_GOOG[] =
{ // Latest close at the begining of the array, as of Friday May 21
472.67, 475.01, 494.43, 498.37, 507.97, 507.53, 510.88, 505.39, 509.05, 521.65,
493.14, 498.67, 509.76, 506.37, 530.60, 525.70, 532.00, 529.19, 529.06, 531.64,
544.99, 547.06, 554.30, 555.04, 550.10, 550.14, 595.30, 589.00, 586.77, 572.73,
566.22, 567.49
};

double arrClosingPrice_AAPL[] =
{
242.32, 237.76, 248.34, 252.36, 254.22, 253.82, 258.36, 262.09, 256.52, 253.99,
235.86, 246.25, 255.99, 258.68, 266.35, 261.09, 268.64, 261.60, 262.04, 269.50,
270.83, 266.47, 259.22, 244.59, 247.07, 247.40, 248.92, 245.69, 242.43, 242.29,
241.79, 239.95
};

double arrClosingPrice_FAZ[] =
{
15.17, 16.94, 14.94, 14.99, 13.77, 13.75, 12.67, 12.14, 12.59, 12.48,
14.81, 14.29, 12.74, 12.52, 11.65, 12.24, 11.42, 12.25, 12.72, 11.64,
11.09, 11.22, 11.50, 11.36, 11.84, 12.18, 11.04, 10.90, 11.80, 11.84,
11.98, 12.16
};

static double arrPercentage;

double *parrCP[] =
{
arrClosingPrice_GOOG,
arrClosingPrice_AAPL,
arrClosingPrice_FAZ,
};

char *arrTicker[] = { "GOOG", "AAPL", "FAZ", };

for(int j = 0; j < sizeof(parrCP) / sizeof(parrCP); j++)
{
double *pCP = parrCP[j];
for(int i = 0; i < 31; i++)
arrPercentage[i] = log(pCP[i] / pCP[i+1]) * 100;

StdDeviation sd; sd.SetValues(arrPercentage, 10);
double v10 = sd.GetStandardDeviation();

sd.SetValues(arrPercentage, 20);
double v20 = sd.GetStandardDeviation();

sd.SetValues(arrPercentage, 30);
double v30 = sd.GetStandardDeviation();

std::cout << "Historical Volatility for " << arrTicker[j] << "\n";
std::cout << "Volatility for 10 days is: " << v10 * sqrt(252.0) << "\n";
std::cout << "Volatility for 20 days is: " << v20 * sqrt(252.0) << "\n";
std::cout << "Volatility for 30 days is: " << v30 * sqrt(252.0) << "\n\n";
}
return 0;
}

Top

Input Data

Input data is hard coded for 3 stocks GOOD, AAPL and FAZ. You can update your input by modifying the C++ program. You can get the historical prices for any ticker symbol using http://finance.google.com or http://finance.yahoo.com or any of your favorite sites.

Top

Output Data

Historical Volatility for GOOG
Volatility for 10 days is: 40.4688
Volatility for 20 days is: 34.0628
Volatility for 30 days is: 37.2999

Historical Volatility for AAPL
Volatility for 10 days is: 50.3732
Volatility for 20 days is: 45.4496
Volatility for 30 days is: 42.8045

Historical Volatility for FAZ
Volatility for 10 days is: 144.281
Volatility for 20 days is: 122.566
Volatility for 30 days is: 108.7

You can cross check the results using CBOE volatility free service.