|
Options UDFs
Function dOne(Stock, Exercise, time, Interest, sigma)
dOne = (Log(Stock / Exercise) + Interest * time) / (sigma * Sqr(time)) + 0.5 * sigma * Sqr(time)
End Function
'---------------------------------------------------
Function optionCall(Stock, Exercise, time, Interest, sigma)
optionCall = Stock * Application.NormSDist(dOne(Stock, Exercise, time, Interest, sigma)) - Exercise * Exp(-time * Interest) * Application.NormSDist(dOne(Stock, Exercise, time, Interest, sigma) - sigma * Sqr(time))
End Function
'---------------------------------------------------
Function optionPut(Stock, Exercise, time, Interest, sigma)
optionPut = optionCall(Stock, Exercise, time, Interest, sigma) + Exercise * Exp(-Interest * time) - Stock
End Function
'---------------------------------------------------
Function optionIvolCall(Premium, Stock, Strike, time, rate)
Dim i As Integer
s = Stock
x = Strike
t = time
r = rate
op = Premium
i = 0
lowValue = 0
hiValue = 2
c = 0.25
comp = optionCall(s, x, t, r, c)
Do While (Abs(op - comp) > 0.001)
c = (lowValue + hiValue) / 2
comp = optionCall(s, x, t, r, c)
If (op > comp) Then
lowValue = c
Else
hiValue = c
End If
i = i + 1
If (i > 100) Then
Exit Function
End If
Loop
optionIvolCall = c
End Function
'---------------------------------------------------
Function optionIvolPut(Premium, Stock, Strike, time, rate)
Dim i As Integer
s = Stock
x = Strike
t = time
r = rate
i = 0
lowValue = 0
hiValue = 2
c = 0.25
op = Premium + s - x * Exp(-r * t)
comp = optionCall(s, x, t, r, c)
Do While (Abs(op - comp) > 0.001)
c = (lowValue + hiValue) / 2
comp = optionCall(s, x, t, r, c)
If (op > comp) Then
lowValue = c
Else
hiValue = c
End If
i = i + 1
If (i > 100) Then
Exit Function
End If
Loop
optionIvolPut = c
End Function
|