# How to calculate the standard deviation of stock returns?

I'm trying to learn the the Black–Scholes option pricing formula and one of the elements of that formula (according to http://bradley.bradley.edu/~arr/bsm/pg04.html) is the "standard deviation of stock returns".

I know if I download a CSV file of historical prices from Yahoo! and open up Excel and execute STDDEV(column with prices), I can get the "standard deviation of stock PRICES". But that is not what I need. I need the "standard deviation of stock RETURNS".

Does anyone know how I can calculate this in Excel? Or even better yet, if someone can provide a implementation in code showing how to do it?

Some of the questions that came up in my head when thinking about how to approach this include "how much historical data to use? (how far back to we go when downloading the CSV file from Yahoo!)" and "what kind of stock returns are we supposed to be calculating? Annual stock returns? Daily returns?"

-

This link does it ok: http://investexcel.net/1979/calculate-historical-volatility-excel/

Basically, you calculate percentage return by doing stock price now / stock price before. You're not calculating the rate of return hence no subtraction of 100%. The standard is to do this on a daily basis: stock price today / stock price yesterday.

The most important and most misunderstood part is that you now have to analyze the data geometrically not arithmetically. To easily do this, convert all percentage returns with the natural log, `ln()`.

Next, you take the standard deviation of all of those results, and apply `exp()`. This answers the title of your question.

For convenience's sake, it's best to annualize since volatility (implied or statistical) is now almost always quoted annualized. There are ~240 trading days each year. You multiply your `stdev()` result by (240 / # of trading days per return) ^ 0.5, so if you're doing this for daily returns, multiply the `stdev()` result by 240^0.5; if you were doing it weekly, you'd want to multiply by (240 / ~5)^0.5; etc. This is your number for sigma. This answers the intent of your question.

For black-scholes, you do not convert anything back with `exp()`; BS is already set up for geometric analysis, so you need to stay there.

The reason why analysis is done geometrically is because the distribution of stock returns is assumed to be lognormal (even though it's really more like logLaplace).

-

For implied volatility it is okey to use Black and scholes but what to do with the historical volatility which carry the effect of past prices as a predictor of future prices.And then precisely the conditional historical volatility.i suggest that you must go with the process like, for stock returns 1) first download stock prices into excel sheet 2) take the natural log of (P1/po) 3) calculate average of the sample 4) calculate square of (X-Xbar) 5) take square root of this and you will get the standard deviation of your required data.

-