How can I calculate the stock volatility in

percentage?

Do i have to use sd() function without any other calculation ?Thanks

**Answer**

You’re looking for the standard deviation of log returns, appropriately annualized and converted to percentage (i.e. multiplied by 100).

Here is an example of computing annual vol from daily prices:

```
library(tseries)
data <- get.hist.quote('VOD.L')
price <- data$Close
ret <- log(lag(price)) - log(price)
vol <- sd(ret) * sqrt(250) * 100
```

Notes:

- The above code should really be using prices adjusted for corporate actions (dividends, splits etc).
`250`

is the (approximate) number of trading days in a year.

**Attribution***Source : Link , Question Author : ECOtime , Answer Author : NPE*