Option Explicit
Sub drv()
MsgBox FIN(100, 50, 4, 0.1, 2, "dONE")
MsgBox FIN(100, 50, 4, 0.1, 2, "dTwo")
MsgBox FIN(100, 50, 4, 0.1, 2, "BSCall")
MsgBox FIN(100, 50, 4, 0.1, 2, "BSPut")
MsgBox FIN(100, 50, 4, 0.1, 2, "Deltaput")
MsgBox FIN(100, 50, 4, 0.1, 2, "BadInput")
End Sub
Function FIN(stock, exercise, time, interest, sigma, keyword) As Variant
Dim tempOne As Double, tempTwo As Double, tempBS As Double
Select Case LCase(keyword)
Case "done"
FIN = (Log(stock / exercise) + interest * time) / (sigma * Sqr(time)) + 0.5 * sigma * Sqr(time)
Case "dtwo"
tempOne = FIN(stock, exercise, time, interest, sigma, "dONE")
FIN = tempOne - sigma * Sqr(time)
Case "bscall"
tempOne = FIN(stock, exercise, time, interest, sigma, "dONE")
tempTwo = FIN(stock, exercise, time, interest, sigma, "dTWO")
FIN = stock * Application.NormSDist(tempOne) - exercise * Exp(-time * interest) * Application.NormSDist(tempTwo)
Case "bsput"
tempBS = FIN(stock, exercise, time, interest, sigma, "bscall")
FIN = tempBS + exercise * Exp(-interest * time) - stock
Case "deltaput"
tempOne = FIN(stock, exercise, time, interest, sigma, "dONE")
FIN = Application.NormSDist(tempOne) - 1
Case Else
FIN = CVErr(xlErrNA)
End Select
End Function