Can anyone tell me what I have done wrong with my code below - cant seem to get it to work?
Function AA_Black76_FutOpt(Calc As String, OptType As String, Spot As Double, Strike As Double, Expiry As Double, DealDate As Double, RFR As Double, Vol As Double)
Dim T As Double
Dim d1 As Double
Dim d2 As Double
Dim ert As Double
If Worksheet.Function.And(Calc = "P", OptType = "C") Then
AA_Black76_FutOpt = ert * (Spot * Worksheet.Function.NormSDist(d1) - Strike * Worksheet.Function.NormSDist(d2))
Else
AA_Black76_FutOpt = ert * (Strike * Worksheet.Function.NormSDist(-d2) - Spot * Worksheet.Function.NormSDist(-d1))
End If
T = (Expiry - DealDate + 1) / 360
d1 = (Worksheet.Function.Ln(Spot / Strike) + Vol ^ 2 * T * 0.2) / (Vol * Worksheet.Function.Sqrt(T))
d2 = d1 - Vol * Worksheet.Function.Sqrt(T)
ert = Worksheet.Function.Exp(-RFR * T)
End Function
Function AA_Black76_FutOpt(Calc As String, OptType As String, Spot As Double, Strike As Double, Expiry As Double, DealDate As Double, RFR As Double, Vol As Double)
Dim T As Double
Dim d1 As Double
Dim d2 As Double
Dim ert As Double
If Worksheet.Function.And(Calc = "P", OptType = "C") Then
AA_Black76_FutOpt = ert * (Spot * Worksheet.Function.NormSDist(d1) - Strike * Worksheet.Function.NormSDist(d2))
Else
AA_Black76_FutOpt = ert * (Strike * Worksheet.Function.NormSDist(-d2) - Spot * Worksheet.Function.NormSDist(-d1))
End If
T = (Expiry - DealDate + 1) / 360
d1 = (Worksheet.Function.Ln(Spot / Strike) + Vol ^ 2 * T * 0.2) / (Vol * Worksheet.Function.Sqrt(T))
d2 = d1 - Vol * Worksheet.Function.Sqrt(T)
ert = Worksheet.Function.Exp(-RFR * T)
End Function