Directory of Open Source for Quantitative Finance and Trading
Username: Password: Not registered?
 
Quick Search:    (AJAX based: No need to press button)

QuantCode Forum Index
   QuantFinance
     Help for pricing caplet using LMM in VBA
Register To Post

Flat Previous Topic | Next Topic
Poster Thread
othnay
Posted on: 2009/3/9 15:51
Just popping in
Joined: 2009/2/24
From:
Posts: 2
Help for pricing caplet using LMM in VBA
Good evening,

I try to implement the libor market model 1 factor to price caplet 1-years 10 years but something is wrong with the results. The first caplets' prices are quite close to the ones provided by Black but after Three years prices begin to differ significantly. I checked everything and i still can't find the problem. If anyone can help, it would be very nice. Thanks in advance.



Sub Question2()

Dim Strike As Double, Notional As Double, M As Long, maturite As Long, IRate As Double, spread As Double
spread = Range("B47")
Notional = Range("B48")
IRate = Range("B49")
M = Range("B50")
maturite = Range("B52")


Dim dt As Double, t As Long, sigma As Double
Dim F() As Double, vol() As Double, r() As Double, delta() As Double
Dim cap(1 To 10) As Double
ReDim vol(1 To 2, 0 To maturite - 1)
ReDim delta(0 To maturite)
ReDim F(0 To maturite, 0 To maturite)
ReDim r(1 To maturite, 1 To M)


For i = 0 To maturite - 1
vol(1, i) = Range("volatilite").Cells(i + 1)
vol(2, i) = Range("volatilite2").Cells(i + 1)
Next

For i = 0 To maturite
delta(i) = Range("delta").Cells(i + 1)
Next


For K = 0 To maturite
F(0, K) = IRate
Next

Rnd -1
Randomize seed

For j = 1 To M

For t = 1 To maturite

For i = t To maturite

Sum = (delta(t) * F(t - 1, t) * (vol(1, 0) * vol(1, i - t) + vol(2, 0) * vol(2, i - t))) / (1 + delta(t) * F(t - 1, t))
For s = t + 1 To i
Sum = Sum + (delta(s) * F(t - 1, s) * (vol(1, s - t) * vol(1, i - t) + vol(2, s - t) * vol(2, i - t))) / (1 + delta(s) * F(t - 1, s))
Next
F(t, i) = F(t - 1, i) * Exp((Sum - ((vol(1, i - t) * vol(1, i - t) + vol(2, i - t) * vol(2, i - t)) / 2) * delta(t - 1) + vol(1, i - t) * (delta(t - 1) ^ (0.5)) * Gauss() + vol(2, i - t) * (delta(t - 1) ^ 0.5) * Gauss()))
Next

discount = 1 + delta(0) * F(0, 0)
For D = 1 To t
discount = discount * (1 + delta(D) * F(D, D))
Next
r(t, j) = (Notional * delta(t) * Application.WorksheetFunction.Max(F(t, t) - F(t - 1, t - 1) - spread, 0)) / discount
Next

Next




For j = 1 To maturite

cap(j) = r(j, 1)
For i = 2 To M
cap(j) = cap(j) + r(j, i)
Next
cap(j) = cap(j) / M
Range("F" & 69 + j) = cap(j)

Dim var() As Double
ReDim var(1 To M)
For s = 1 To M
var(s) = r(j, s)
Next
Range("G" & 69 + j) = Application.WorksheetFunction.StDev(var) / (M ^ 0.5)



Next


















End Sub



Flat Previous Topic | Next Topic

Subject Poster Date
 » Help for pricing caplet using LMM in VBA othnay 2009/3/9 15:51
     Re: Help for pricing caplet using LMM in VBA Toopi 2009/3/9 19:57
     Re: Help for pricing caplet using LMM in VBA vanna 2009/3/10 2:38
       Re: Help for pricing caplet using LMM in VBA othnay 2009/3/10 7:38

Register To Post
 
Similar Links:
Caplet pricing using Blacks formula (Software)
Swaplet pricing in LMM using MC simulation (Software)
Basket CDS pricing using Copula (Software)
DO NOT DOWNLOAD - Caplet Pricing in single factor Libor market model (Software)
Option Pricing using Integral Transforms (Paper)
Copyright © 2011 QuantCode Inc. All rights reserved.