Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Help with Visual Basic
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 |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Visual Basic | Excel Discussion (Misc queries) | |||
Is Visual Basic the same as Visual Studio 2008? | Excel Worksheet Functions | |||
New to Visual Basic | Excel Discussion (Misc queries) | |||
changing the visual basic in office 2003 to visual studio net | Excel Discussion (Misc queries) | |||
Visual Basic | Excel Programming |