GLIMBO_BOX
04-01-2023, 08:34 AM
I am trying to calculate the PUT PRICE but I am getting error Value. This is the code :
Function Mon_AmericanPut_Trinomial(S, X, T, rf, sigma, n)
[/COLOR]delta_t = T / n
up = Exp(sigma * Sqr(3 * delta_t))
down = 1 / up
r = Exp(rf * delta_t)
Pu = (r - down) / (up - down)
Pd = (up - r) / (up - down)
Pm = 1 - Pu - Pd
Dim Prix_t_plus_1() As Double
Dim Prix_t() As Double
ReDim Prix_t_plus_1(n)
For State = 0 To n
Prix_t_plus_1(State) = Application.Max(X - S * _
up ^ State * down ^ (n - State), 0)
Next State
For Index = n - 1 To 0 Step -1
ReDim Prix_t(Index)
For State = 0 To Index
Prix_t(State) = Application.Max(X - S * up ^ State * down ^ (Index - State), _
(r) ^ (-1) * ((Pd) * Prix_t_plus_1(State) + (Pm) * Prix_t_plus_1(State + 1) + (Pu) * Prix_t_plus_1(State + 2)))
Next State
ReDim Prix_t_plus_1(Index)
For State = 0 To Index
Prix_t_plus_1(State) = Prix_t(State)
Next State
Next Index
Mon_AmericanPut_Trinomial = Prix_t(0)
End Function
Function Mon_AmericanPut_Trinomial(S, X, T, rf, sigma, n)
[/COLOR]delta_t = T / n
up = Exp(sigma * Sqr(3 * delta_t))
down = 1 / up
r = Exp(rf * delta_t)
Pu = (r - down) / (up - down)
Pd = (up - r) / (up - down)
Pm = 1 - Pu - Pd
Dim Prix_t_plus_1() As Double
Dim Prix_t() As Double
ReDim Prix_t_plus_1(n)
For State = 0 To n
Prix_t_plus_1(State) = Application.Max(X - S * _
up ^ State * down ^ (n - State), 0)
Next State
For Index = n - 1 To 0 Step -1
ReDim Prix_t(Index)
For State = 0 To Index
Prix_t(State) = Application.Max(X - S * up ^ State * down ^ (Index - State), _
(r) ^ (-1) * ((Pd) * Prix_t_plus_1(State) + (Pm) * Prix_t_plus_1(State + 1) + (Pu) * Prix_t_plus_1(State + 2)))
Next State
ReDim Prix_t_plus_1(Index)
For State = 0 To Index
Prix_t_plus_1(State) = Prix_t(State)
Next State
Next Index
Mon_AmericanPut_Trinomial = Prix_t(0)
End Function