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 ‘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

# Sub ss

Updated January 17, 2019- Subject
- Pages 2
- Words 305
- Views 9

Get help to write your own 100% unique essay

Get custom paper78 writers are online and ready to chat

This essay has been submitted to us by a student. This is not an example of the work written by our writers.

Sub ss. (2019, Mar 08). Retrieved from https://sunnypapers.com/sub-ss/