Keywords - Function groups - @ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

Library: finance
See also: american asset bs1 bitree european mcmillan optstart

Quantlet: volatility
Description: calculates the implied volatility of given options.

Usage: (vol)=volatility(task) or (vol)=volatility(S,K,r,tau,opt,optprice,typeofdiv,div)
Input:
task scalar, if: task = 1, no dividend is paid (default), task = 2, dividend is paid continuously, task = 3, a fixed dividend at the end of each period is assumed. task = 4, an exchange rate is assumed as underlier.
S n x 1 vector, price of the underlying asset,
K n x 1 vector, exercise price
r n x 1 vector, domestic interest rate in [0%,100%]
tau n x 1 vector, time to expiration (in years)
opt n x 1 vector, type of the option: 1 for call, 0 for put
optprice n x 1 vector, price of the option
typeofdiv n x 1 vector, type of the dividend payment, if: typeofdiv = 0, no dividend is paid (default), typeofdiv = 1, dividends are paid continuously, typeofdiv = 2, a fixed dividend is assumed typeofdiv = 3, an exchange rate is assumed as the underlier
div n x 1 vector representing the amount of the dividend paid. According to the type of dividend it is either a zero vector, a vector of dividend rate in (0%-100%), a vector of fixed dividend amounts or of exchange rates (0%-100%)
Output:
vol n x 9 matrix, the first 8 columns contain the input values and the last column the computed implied volatility.

Note:

Example:
library("finance")
volatility(1)       ; no dividends

Result:
Several interactive menus are invoked asking you to specify the
features of your options. The implied volatility is calculated
afterwards.
Example:
library("finance")
S   = #(230,230,220,220,210)
K   = #(210,220,210,220,210)
r   = 5
tau = 0.5
opt = 1
optprice = 30
vol=volatility(S,K,r,tau,opt,optprice)
vol[,9]

Result:
Contents of aus

[ 1,] " "
[ 2,] "-------------------------------------"
[ 3,] " The Implied Volatilities of Your Options "
[ 4,] " on Given Stock: "
[ 5,] " 0.2292"
[ 6,] " 0.3444"
[ 7,] " 0.3620"
[ 8,] " 0.4470"
[ 9,] " 0.4704"
[10,] "-------------------------------------"
[11,] " "

      Contents of _tmp
      [1,]  0.22922
      [2,]  0.34445
      [3,]  0.36203
      [4,]  0.44699
      [5,]  0.47043
Example:
library("finance")
S   = 230
K   = 210
r   = 5
tau = aseq(0.5,4,0.5)
opt = 0
optprice = 30
typeofdiv  = 1
div   = 14
vol=volatility(S,K,r,tau,opt,optprice,typeofdiv,div)
vol

Result:
Contents of aus
[ 1,] " "
[ 2,] "-------------------------------------"
[ 3,] " The Implied Volatilities of Your Options "
[ 4,] " on Given Stock with cont. Dividends: "
[ 5,] " 0.5944"
[ 6,] " 0.3874"
[ 7,] " 0.2859"
[ 8,] " 0.2190"
[ 9,] "-------------------------------------"
[10,] " "

     Contents of vol
     [1,]      230      210  0.04879      0.5        0       30        1       14  0.59445
     [2,]      230      210  0.04879        1        0       30        1       14  0.38742
     [3,]      230      210  0.04879      1.5        0       30        1       14  0.28586
     [4,]      230      210  0.04879        2        0       30        1       14  0.21896



Author: K. Komorad, W. Haerdle, 20020104 license MD*Tech
(C) MD*TECH Method and Data Technologies, 05.02.2006