 Rock Street, San Francisco

Sub ss()

‘ Calculates European or American option prices using the Cox, Ross, Rubinstein binomial lattice
‘ Spot = Spot Price of the underlying
‘ K = Strike Price
‘ T = Option Maturity in Years
‘ rf = Interest Rate in decimal (i.e, for 5%, use 0.05)
‘ vol = Yearly volatility of the underlying in decimal
‘ n = Number of time steps
‘ OpType = ‘C’ for Call and ‘P’ for Put
‘ ExType = ‘A’ for American and ‘E’ for European

We Will Write a Custom Essay Specifically
For You For Only \$13.90/page!

order now

We Will Write a Custom Essay Specifically
For You For Only \$13.90/page!

order now

‘volopta

Function CRRTree(Spot, K, T, rf, vol, n, OpType As String, ExType As String)
dt = T / n
u = Exp(vol * (dt ^ 0.5))
d = 1 / u
p = (Exp(rf * dt) – d) / (u – d)

‘ Tree for stock price

Dim S() As Double
ReDim S(n + 1, n + 1) As Double

For i = 1 To n + 1
For j = i To n + 1
S(i, j) = Spot * u ^ (j – i) * d ^ (i – 1)
Next j
Next i

‘ Calculate Terminal Price for Calls and Puts

Dim Op() As Double
ReDim Op(n + 1, n + 1) As Double

For i = 1 To n + 1
Select Case OpType
Case “C”: Op(i, n + 1) = Application.Max(S(i, n + 1) – K, 0)
Case “P”: Op(i, n + 1) = Application.Max(K – S(i, n + 1), 0)
End Select
Next i

‘ Calculate Remaining entries for Calls and Puts

For j = n To 1 Step -1
For i = 1 To j
Select Case ExType
Case “A”:
If OpType = “C” Then
Op(i, j) = Application.Max(S(i, j) – K, Exp(-rf * dt) * (p * Op(i, j + 1) + (1 – p) * Op(i + 1, j + 1)))
ElseIf OpType = “P” Then
Op(i, j) = Application.Max(K – S(i, j), Exp(-rf * dt) * (p * Op(i, j + 1) + (1 – p) * Op(i + 1, j + 1)))
End If
Case “E”:
Op(i, j) = Exp(-rf * dt) * (p * Op(i, j + 1) + (1 – p) * Op(i + 1, j + 1))
End Select
Next i
Next j

CRRTree = Op(1, 1)

End Function

### Post Author: admin

x Hi!
I'm Victoria

Would you like to get a custom essay? How about receiving a customized one?

Check it out
x Hi!
I'm Jeremy!

Would you like to get a custom essay? How about receiving a customized one?

Check it out