R
RK
I'm new to Visual Basic. By trial and error, I keyed in the following code
to determine the price of a Call Option, given stock price, exercise price,
current yield, dividend yield, std. deviation & days to maturity.
Although the function works, I want to create an additional function for Put
Option Price. Many of the same intermediate calculations are used again (eg.
d1, d2, Nd1 and Nd2). How do I code so that I don't have to repeat all this?
Thanks for your help!
Function CallPrice(PS, PE, YTM, DIV, SD, DAYS)
d1 = (Log(PS / PE) + (YTM - DIV + 0.5 * SD ^ 2) * DAYS / 365) / SD /
Sqr(DAYS / 365): d2 = d1 - SD * Sqr(DAYS / 365): Nd1 =
WorksheetFunction.NormSDist(d1): Nd2 = WorksheetFunction.NormSDist(d2):
CallPrice = PS * Nd1 * Exp(-DIV * DAYS / 365) - PE * Nd2 * Exp(-YTM * DAYS /
365)
End Function
to determine the price of a Call Option, given stock price, exercise price,
current yield, dividend yield, std. deviation & days to maturity.
Although the function works, I want to create an additional function for Put
Option Price. Many of the same intermediate calculations are used again (eg.
d1, d2, Nd1 and Nd2). How do I code so that I don't have to repeat all this?
Thanks for your help!
Function CallPrice(PS, PE, YTM, DIV, SD, DAYS)
d1 = (Log(PS / PE) + (YTM - DIV + 0.5 * SD ^ 2) * DAYS / 365) / SD /
Sqr(DAYS / 365): d2 = d1 - SD * Sqr(DAYS / 365): Nd1 =
WorksheetFunction.NormSDist(d1): Nd2 = WorksheetFunction.NormSDist(d2):
CallPrice = PS * Nd1 * Exp(-DIV * DAYS / 365) - PE * Nd2 * Exp(-YTM * DAYS /
365)
End Function