Strategies Options        "To manage is To Forecast..."
 The Option Trading Website
Accès Site
 
Home  >  Pricing Models  >  Binomial Model: VBA Code 

Binomial Model: VBA Code
Issued on October 07 2010 par Strategies-options.com

Binomial Tree Excel - Numerical model are sometimes really easy to program using VBA.
I - VBA Code

Function EuropeanBinomial(CallPutFlag As String, S As Double, X As Double, T As Double, r As Double, b As Double, v As Double, n As Integer) As Double

Dim u As Double, d As Double, p As Double
Dim sum As Double, dt As Double, a As Double
Dim j As Double

dt = T / n
u = Exp(v * Sqr(dt))
d = 1 / u
p = (Exp(b * dt) - d) / (u - d)
a = Int(Log(X / (S * d ^ n)) / Log(u / d)) + 1

sum = 0
If CallPutFlag = "c" Then
For j = a To n
sum = sum + Application.Combin(n, j) * p ^ j * (1 - p) ^ (n - j) * (S * u ^ j * d ^ (n - j) - X)
Next
ElseIf CallPutFlag = "p" Then
For j = 0 To a - 1
sum = sum + Application.Combin(n, j) * p ^ j * (1 - p) ^ (n - j) * (X - S * u ^ j * d ^ (n - j))
Next
End If
EuropeanBinomial = Exp(-r * T) * sum

End Function



II - How to use it

In any cells, "=EuropeanBinomial(c;100;110;1;0.05;0.05;0.30;1000)"

That leads to :
- option type a call (c)
- spot 100
- strike 110
- maturity d'1
- interest rate 0.05 (5%)
- cost of carry 0.05
- volatility 0.3 (30%)
- number of periods 1000
Call value : 10.017


Now for a put

"=EuropeanBinomial(p;100;110;1;0.05;0.02;0.30;1000)"


- option type, a put (p)
- spot100
- strike 110
- maturity d'1
- interest rate 0.05 (5%)
- cost of carry 0.02 (interest rate minus dividend rate :0.05-0.03)
- volatility 0.3 (30%)
- number of periods1000
Put value= 16.1903



Previous : Modèle Binomial : Version Détaillée - On Price! or Binomial Model: American Style Options, Let's Price With It !


Related Pdf :

- BINOMIAL MODEL


OPTIONS PRICING MODEL - INDEX
OPTIONS PRICING MODEL - INDEX
OPTIONS PRICING MODEL - CHAPTER I
OPTIONS PRICING MODEL - CHAPTER II
OPTIONS PRICING MODEL - CHAPTER III

Strategies-options.com
Other articles
- Pricing Models -
Models : Models are needed for derivatives pricing
"Because the difference between six and five can be very damned important " (Insp. Harry Callahan/ Dirty Harry)
- Hedging -
Delta Hedging
Delta Hedging is a very famous strategy to try to smooth the variation of the P&L of an option position.
- Futures and Equity Options Trading Strategies -
CAC40 SOIC DEC10 Strategy Summary
Summary and results.
- Options 101 -
VIX - Volatility Index
What is VIX ?
- Options 101 -
OPTIONS 101 - INDEX
INDEX
- Advanced Strategies -
Butterfly Spread : A First Attempt
Butterfly Spread is a famous strategy using options.