Private Sub btn_calcola_Click()
Dim S As Single, X As Single, T As Single
Dim d1 As Double, d2 As Double, Delta As Double, vega() As Double
Dim r As Byte, k As Byte, v As Byte, I As Byte, J As Double, L As Double
S = txtS
X = txtX
T = txtT
r = txtr
k = txtk
v = txtv
If txtS < 100 Then
MsgBox prompt:="Valore del prezzo corrente inferiore a 100 ", Buttons:=vbCritical, Title:="errore inserimento dati"
Exit Sub
End If
d1 = (Application.Ln(S / X) + (r - k + (v ^ 2) / 2) * T) / v * Sqr(T)
txtd1 = d1
d2 = d1 - v * Sqr(T)
txtd2 = d2
'Delta = Exp(-k * T)
Delta = Application.NormSDist(d1) * Exp(-k * T)
txtdelta = Delta
For J = 1 To 20
For I = 2 To 20
Cells(1, 1).Value = S - 90
Cells(I, 1).Value = Cells(I - 1, 1).Value + 10
d1 = (Application.Ln(Cells(J, 1).Value / X) + (r - k + (v ^ 2) / 2) * T) / v * Sqr(T)
Cells(J, 3).Value = d1
Next I, J
For L = 1 To 20
Cells(L, 2).Value = Application.NormSDist(Cells(L, 3).Value) * Exp(-k * T)
Next L
End Sub |