FinanceInformatiqueValo Actions

VBA Formule Option Greeks Black & Scholes

Option Explicit
Dim DrSup   ‘Cours Support
Dim PE      ‘Prix Exercice
Dim Tx      ‘Taux courts
Dim Tps     ‘Temps restant avant l’échéance en années
Dim Vol     ‘Volatilité annualisée en %

Dim D1
Dim D2

Dim Temp1
Dim Temp2
Dim Temp3

 

 
‘Calcul Coef d2
Function Greek_d1(DrSup, PE, Tx, Div, Tps, Vol)
    Greek_d1 = (1 / (Vol * Sqr(Tps))) * Log(((DrSup * Exp(-Div * Tps)) / (PE * Exp(-Tx * Tps)))) + 0.5 * Vol * Sqr(Tps)
End Function
‘Calcul coef d2
Function Greek_d2(DrSup, PE, Tx, Div, Tps, Vol)
Greek_d2 = Greek_d1(DrSup, PE, Tx, Div, Tps, Vol) – Vol * Sqr(Tps)

End Function
‘Calcul CALL *****************************************************************
Function OptionCall(DrSup, PE, Tx, Div, Tps, Vol)

D1 = Greek_d1(DrSup, PE, Tx, Div, Tps, Vol)
D2 = Greek_d2(DrSup, PE, Tx, Div, Tps, Vol)

OptionCall = DrSup * Exp(-Div * Tps) * WorksheetFunction.NormSDist(D1) – PE * Exp(-Tx * Tps) * WorksheetFunction.NormSDist(D2)
End Function
‘Calcul PUT *****************************************************************
Function OptionPut(DrSup, PE, Tx, Div, Tps, Vol)

D1 = Greek_d1(DrSup, PE, Tx, Div, Tps, Vol)
D2 = Greek_d2(DrSup, PE, Tx, Div, Tps, Vol)

OptionPut = DrSup * Exp(-Div * Tps) * (WorksheetFunction.NormSDist(D1) – 1) – PE * Exp(-Tx * Tps) * (WorksheetFunction.NormSDist(D2) – 1)
End Function
‘DELTA CALL *****************************************************************
Function Greek_Delta_Call(DrSup, PE, Tx, Div, Tps, Vol)
    D1 = Greek_d1(DrSup, PE, Tx, Div, Tps, Vol)
    Greek_Delta_Call = Exp(-Div * Tps) * WorksheetFunction.NormSDist(D1)
End Function
‘DELTA PUT *****************************************************************
Function Greek_Delta_Put(DrSup, PE, Tx, Div, Tps, Vol)
    D1 = Greek_d1(DrSup, PE, Tx, Div, Tps, Vol)
    Greek_Delta_Put = Exp(-Div * Tps) * (WorksheetFunction.NormSDist(D1) – 1)
End Function
‘GAMMA CALL & PUT *****************************************************************
Function Greek_Gamma_Call(DrSup, PE, Tx, Div, Tps, Vol)
    D1 = Greek_d1(DrSup, PE, Tx, Div, Tps, Vol)
    Greek_Gamma_Call = Exp(-Div * Tps) * WorksheetFunction.NormDist(D1, 0, 1, False)
    Greek_Gamma_Call = Greek_Gamma_Call / (DrSup * Vol * Sqr(Tps))
End Function
Function Greek_Gamma_Put(DrSup, PE, Tx, Div, Tps, Vol)
    D1 = Greek_d1(DrSup, PE, Tx, Div, Tps, Vol)
    Greek_Gamma_Call = Exp(-Div * Tps) * WorksheetFunction.NormDist(D1, 0, 1, False)
    Greek_Gamma_Call = Greek_Gamma_Call / (DrSup * Vol * Sqr(Tps))
End Function
‘VEGA CALL & PUT *****************************************************************
Function Greek_Vega_Call(DrSup, PE, Tx, Div, Tps, Vol)
    D1 = Greek_d1(DrSup, PE, Tx, Div, Tps, Vol)
    Greek_Vega_Call = DrSup * Exp(-Div * Tps) * Sqr(Tps) * WorksheetFunction.NormDist(D1, 0, 1, False)
    Greek_Vega_Call = Greek_Vega_Call / 100
End Function
Function Greek_Vega_Put(DrSup, PE, Tx, Div, Tps, Vol)
    D1 = Greek_d1(DrSup, PE, Tx, Div, Tps, Vol)
    Greek_Vega_Call = DrSup * Exp(-Div * Tps) * Sqr(Tps) * WorksheetFunction.NormDist(D1, 0, 1, False)
    Greek_Vega_Call = Greek_Vega_Call / 100
End Function
‘RHO CALL *****************************************************************
Function Greek_Rho_Call(DrSup, PE, Tx, Div, Tps, Vol)
    D2 = Greek_d2(DrSup, PE, Tx, Div, Tps, Vol)
    Greek_Rho_Call = PE * Exp(-Tx * Tps) * Tps * WorksheetFunction.NormSDist(D2)
    Greek_Rho_Call = Greek_Rho_Call / 100
End Function
‘RHO PUT *****************************************************************
Function Greek_Rho_Put(DrSup, PE, Tx, Div, Tps, Vol)
    D2 = Greek_d2(DrSup, PE, Tx, Div, Tps, Vol)
    Greek_Rho_Put = -PE * Exp(-Tx * Tps) * Tps * WorksheetFunction.NormSDist(-D2)
    Greek_Rho_Put = Greek_Rho_Put / 100
End Function
‘RHO_Div CALL *****************************************************************
Function Greek_Rho_Div_Call(DrSup, PE, Tx, Div, Tps, Vol)
    D1 = Greek_d1(DrSup, PE, Tx, Div, Tps, Vol)
    Greek_Rho_Div_Call = -DrSup * Exp(-Div * Tps) * Tps * WorksheetFunction.NormSDist(D1)
    Greek_Rho_Div_Call = Greek_Rho_Div_Call / 100
End Function
‘RHO_Div PUT *****************************************************************
Function Greek_Rho_Div_Put(DrSup, PE, Tx, Div, Tps, Vol)
    D1 = Greek_d1(DrSup, PE, Tx, Div, Tps, Vol)
    Greek_Rho_Div_Put = DrSup * Exp(-Div * Tps) * Tps * WorksheetFunction.NormSDist(-D1)
    Greek_Rho_Div_Put = Greek_Rho_Div_Put / 100
End Function
‘THETA CALL *****************************************************************
Function Greek_Theta_Call(DrSup, PE, Tx, Div, Tps, Vol)
    D1 = Greek_d1(DrSup, PE, Tx, Div, Tps, Vol)
    D2 = Greek_d2(DrSup, PE, Tx, Div, Tps, Vol)
   
    Temp1 = -DrSup * Exp(-Div * Tps) * Vol * WorksheetFunction.NormDist(D1, 0, 1, False) / (2 * Sqr(Tps))
    Temp2 = Div * DrSup * Exp(-Div * Tps) * WorksheetFunction.NormSDist(D1)
    Temp3 = Tx * PE * Exp(-Tx * Tps) * WorksheetFunction.NormSDist(D2)
    Greek_Theta_Call = Temp1 + Temp2 – Temp3
    Greek_Theta_Call = Greek_Theta_Call / 365.25
End Function
‘THETA PUT *****************************************************************
Function Greek_Theta_Put(DrSup, PE, Tx, Div, Tps, Vol)
    D1 = Greek_d1(DrSup, PE, Tx, Div, Tps, Vol)
    D2 = Greek_d2(DrSup, PE, Tx, Div, Tps, Vol)
   
    Temp1 = -DrSup * Exp(-Div * Tps) * Vol * WorksheetFunction.NormDist(D1, 0, 1, False) / (2 * Sqr(Tps))
    Temp2 = Div * DrSup * Exp(-Div * Tps) * WorksheetFunction.NormSDist(D1)
    Temp3 = Tx * PE * Exp(-Tx * Tps) * WorksheetFunction.NormSDist(D2)
    Greek_Theta_Put = Temp1 – Temp2 + Temp3
    Greek_Theta_Put = Greek_Theta_Put / 365.25
End Function