Binomial European Pricing Model

I created a program using VBA to calculate the price of a European Call option, as follows:

Private Sub CallPrice_Click()
Dim K As Single
Dim So As Single
Dim r As Single
Dim T As Single
Dim sigma As Single
Dim u As Single
Dim d As Single
Dim p As Single
Dim CP As Single
Dim M As Single
Dim S As Single
Dim CB As Double
Dim n As Integer
Dim i As Integer

K = Cells(2, 2)
So = Cells(3, 2)
r = Cells(4, 2)
T = Cells(5, 2)
sigma = Cells(6, 2)
n = Cells(7, 2)
u = Exp(sigma * Sqr(T / n))
d = 1 / u
p = (Exp(r * T / n) - d) / (u - d)
CP = 0
For i = 0 To n Step 1
    M = WorksheetFunction.Max(So * (u ^ i) * d ^ (n - i) - K, 0)
    CB = WorksheetFunction.Combin(n, i)
    S = M * CB * (p ^ n) * (1 - p) ^ (n - i)
    CP = CP + S
Next i
Cells(9, 2) = CP / (1 + r) ^ n
End Sub

Here is the table layout:

enter image description here

When I ran the program, an error occurred.

enter image description here

enter image description here

Can anyone here explain what is wrong with my program and how to fix it?

+4
source share
2 answers

Is your equation for S correct? It looks like it should be:

S = M * CB * (p ^ i) ...

instead

S = M * CB * (p ^ n) ...

If your equation is really wrong, you can use BINOMDIST instead of COMBIN, because by definition:

Binom_Dist(i, n, p, False) = (p ^ i) * (1 - p) ^ (n - i) * Combin(n, i)

So your code will look like this:

S = M * WorksheetFunction.Binom_Dist(i, n, p, False)

instead

CB = WorksheetFunction.Combin(n, i)
S = M * CB * (p ^ n) * (1 - p) ^ (n - i)

BINOMDIST is not so sensitive to large n, i.

+1
source

You get an overflow error. If you check the worksheet:

COMBIN(5000, 161) = 3.3E+307
COMBIN(5000, 162) = #NUM!

COMBIN(5000, 4838) = #NUM!
COMBIN(5000, 4839) = 3.3E+307

, , .

+1

All Articles