Implied Volatility - Black Scholes

rogerioct

New Member
Joined
Jan 16, 2006
Messages
8
Dear forum members,

I have been trying (along 3 nights) to implement an algorith to calculate implied volatility.
Calculation of calls and puts prices is OK (follow the code).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Public Function normal(x)
normal = Application.WorksheetFunction.NormSDist(x)
End Function


Public Function precobs(S, sigma, r, strike, T, div, tipo)
Dim d1 As Single
Dim d2 As Single

T = T / 252
r = 1 * Log(1 + r / 1)

d1 = (Log(S / strike) + (r + (sigma ^ 2) / 2) * T) / (sigma * Sqr(T))
d2 = d1 - sigma * Sqr(T)

If tipo = "Call" Then
precobs = S * normal(d1) * Exp(-div * T) - strike * Exp(-r * T) * normal(d2)
Else
precobs = strike * Exp(-r * T) * normal(-d2) - S * normal(-d1) * Exp(-div * T)
End If

End Function

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
legend: precobs=price of option from black scholes formula
tipo=call/put

the rest is intuitive

User gives the inputs and the function calculates the price.

Well done.

But, implied volatility requires such a routine which finds the volatility (sigma) whose lets price from black scholes be equal to market price.

I tryed something like this:

Public Function impv(mktprice,S,r,T,tipo,div,strike)

dim dif as double
dim sigma as double
dim cont as double
dim limit as double
cont=0
dif=abs(mktprice-precobs(S,sigma,strike,r,T,tipo,div))
limit=10^(-2)

Do While dif>limit and cont<2000 and sigma>0

sigma=sigma-0.01
dif=abs(mktprice-precobs(S,sigma,strike,r,T,tipo,div))
cont=cont+1
loop

if cont>2000 or sigma<0 then
impv="fail!"
else
impv=sigma
end if
End Function


It doesn't work.
I tried other codes I found on web but neither works.

Thank You

Regards,
Rogerio.
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
Somebody?

I need help on creating an algorithm which the output is the implied volatility.

The user will enter with S,r,T,tipo,strike and market price (mktprice)

The program has to find the value for "sigma" which makes the difference "mktprice-precobs" be almost zero. [in other words, I need to find sigma which lets the value of the BS equation be equal to the value of market price, the last is given by the user and the BS price is an output from the function "precobs".

Thank you.
 
Upvote 0
Dude, if you can't help, you better stay quiet.

The code for the BS price is working and it is simple, thats what matters, How would you improve it? Creating useless accessories to it?

PS: I didn't knew about code tags.
 
Upvote 0

Forum statistics

Threads
1,223,270
Messages
6,171,102
Members
452,379
Latest member
IainTru

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top