rockr | Bonjour à tous,
pourriez-vous me venir en aide car j'ai un problème concernant mes variables : le code ne me renvois absolument rien, et lorsque je débug pas à pas, je vois que mes variables sont vides. Or, lorsque NbSteps est de l'ordre de 500 ou plus, alors les variables apparaissent comme "elles devraient le faire".
Le code est le suivant :
Code :
- Function BinomialTree()
- Dim dt As Double, NbSteps As Integer
- Dim uS As Double, dS As Double, uB As Double, dB As Double
- Dim RuSd As Double, RuSu As Double, RdSu As Double, RdSd As Double
- Dim IntRateRiskless As Double, BondYield As Double, DividendYield As Double
- Dim S_0 As Double, B_0 As Double
- Dim NodeValue() As Double
- Dim CouponFrequency As Double, Coupontime As Double, CouponSchedule() As Double
- Dim ConversionRatio As Double, ConversionValue As Double
-
- Dim i As Double, j As Double, k As Double, l As Double
-
- Worksheets("BinomialTree" ).Activate
-
- dt = Range("Delta_t" ).Value
- NbSteps = Range("NbSteps" ).Value
- uS = Range("UpStock" ).Value
- dS = Range("DownStock" ).Value
- uB = Range("UpBond" ).Value
- dB = Range("DownBond" ).Value
- RuSd = Range("RuSd" ).Value
- RuSu = Range("RuSu" ).Value
- RdSu = Range("RdSu" ).Value
- RdSd = Range("RdSd" ).Value
- IntRateRiskless = Range("LnIntRate" ).Value
- BondYield = Range("LnIntRateRisky" ).Value
- DividendYield = Range("LnDivRate" ).Value
- S_0 = Range("StockPrice" ).Value
- B_0 = Range("BondPrice" ).Value
- ConversionRatio = Range("Conversion" ).Value
- CouponFrequency = Range("CouponFrequency" ).Value
-
- ReDim NodeValue(0 To NbSteps, 0 To NbSteps, 0 To NbSteps)
-
- For i = NbSteps To 0 Step -1
- For j = NbSteps To 0 Step -1
- NodeValue(i, j, NbSteps) = WorksheetFunction.Max(ConversionRatio * S_0 * (uS ^ i) * dS ^ (NbSteps - i), B_0 * (uB ^ j) * dB ^ (NbSteps - j))
-
- Next j
- Next i
-
- For k = NbSteps - 1 To 0 Step -1
- For i = k To 0 Step -1
- For j = k To 0 Step -1
- NodeValue(i, j, k) = (RuSd * NodeValue(i, j + 1, k + 1) + RuSu * NodeValue(i + 1, j + 1, k + 1) + RdSd * NodeValue(i, j, k + 1) + RdSu * NodeValue(i + 1, j, k + 1)) * Exp(-IntRateRiskless * dt * k)
-
- Next j
- Next i
- Next k
-
- Cells(1, 2) = NodeValue(0, 0, 0) - B_0
-
- End Function
|
Voilà pour le topo,
merci beaucoup d'avance
Rockr |