Bonjour,
voulant effectuer la macro suivante (simulation OBPI) un message d'erreur s'affiche, quand au dépassement de capacité au niveau de : d1 = (Log(Spot / Strike) + (rf + Sigma ^ 2 / 2) * Echéance) / (Sigma * Sqr(Dist_Echéance))
d2 = d1 - Sigma * Sqr(Echéance)
sauriez vous m'aider s'il vous plait ? (je suis preneuse de toute amélioration de ce code, et toute explications lié, merci beaucoup ! )

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
Sub OBPI()
 
Option Base 1
Dim rf As Double, S0 As Double, Mu As Double, Sigma As Double, Plancher As Double
Dim Plancher As Double, dT As Double, Nb_Points As Double, simulations As Double
Dim Position_Actions As Double, Valorisation_Position As Double, beta As Double
 
    S0 = 100
    Mu = 0.08
    Sigma = 0.3
 
    rf = 0.03
 
    Plancher = 80
    plancher = Deter_Strike(S0, Plancher, rf, Sigma, 1, Plancher / 100)
 
    Nb_Points = 252
    dT = 1 / Nb_Points
    Simulations = 1000
 
    ReDim Performance(Simulations, 2) As Double
 
    For i = 1 To Simulations
 
        Spot = S0
        Echéance = 1
        beta = Proportion_Actions(Spot, Plancher, rf, Sigma, Echéance)
 
        Position_Actions = beta * S0
        Position_sansrisque = (1 - beta) * S0
 
        For j = 1 To Nb_Points
 
            Taux_Rentabilite = Taux_Rentabilite_Action(Mu, Sigma, dT)
            Spot = Spot * Exp(Taux_Rentabilite)
            Valorisation_Position = Position_Actions * Exp(Taux_Rentabilite) + Position_sansrisque * Exp(rf * dT)
            Echéance = WorksheetFunction.Max(Echéance - dT, 1E-08)
            beta = Proportion_Actions(Spot, Plancher, rf, Sigma, Echéance)
            Position_Actions = beta * Valorisation_Position
            Position_sansrisque = (1 - beta) * Valorisation_Position
 
        Next j
 
 
        Performance(i, 2) = Valorisation_Position  
        Performance(i, 1) = Spot          
Next i
    Range("A1:B1000").Value = Performance
End Sub
Function Deter_Strike(S, K, R, Sigma, T, proportion_garde)
    epsilon = 1E-15
    Do
        d1 = (Log(S / K) + (R + 0.5 * Sigma ^ 2) * T) / (Sigma * Sqr(T))
        d2 = d1 - Sigma * Sqr(T)
        K = (-proportion_garde * (S + BS_STD("Put", S, K, R, Sigma, T)) + K * proportion_garde * Exp(-R * T) * Nd(-d2)) / _
        (proportion_garde * Exp(-R * T) * Nd(-d2) - 1)
        erreur = proportion_garde * (S + BS_STD("Put", S, K, R, Sigma, T)) - K
    Loop Until Abs(erreur) < epsilon
    Deter_Strike = K
End Function
Function Taux_Rentabilite_Action(Mu, Sigma, dT)
    epsilon = WorksheetFunction.NormSInv(Rnd)
    Taux_Rentabilite_Action = (Mu - Sigma ^ 2 / 2) * dT + Sigma * epsilon * Sqr(dT)
End Function
Function Proportion_Actions(Spot, Strike, rf, Sigma, Echéance)
    d1 = (Log(Spot / Strike) + (rf + Sigma ^ 2 / 2) * Echéance) / (Sigma * Sqr(Dist_Echéance))
    d2 = d1 - Sigma * Sqr(Echéance)
    Proportion_Actions = Spot * Nd(d1) / (Spot * Nd(d1) + Strike * Exp(-rf * Echéance) * Nd(-d2))
End Function
Function BS_STD(TypeOption, S, K, R, Sigma, T)
    d1 = (Log(S / K) + (R + 0.5 * Sigma ^ 2) * T) / _
    (Sigma * Sqr(T))
    d2 = d1 - Sigma * Sqr(T)
    Z = Switch(TypeOption)
    BS_STD = Z * (S * Nd(Z * d1) - K * Exp(-R * T) * Nd(Z * d2))
End Function
Function Nd(d)
    Nd = WorksheetFunction.NormSDist(d)
End Function
Function Switch(TypeOption)
    TypeOption = UCase(TypeOption)
    If TypeOption = "C" Or TypeOption = "CALL" Then
        Switch = 1
    Else
        Switch = -1
    End If
End Function