Re: FixedCouponBond pricing wrong?
Posted by Luigi Ballabio on
URL: http://quantlib.414.s1.nabble.com/FixedCouponBond-pricing-wrong-tp3741p3748.html
On 04/22/05 01:09:04, Feng Ning wrote:
>
> See the test_suite/bonds.cpp, testCachedYield() function.
> For bond1, the marketPrice1=99.203125.
> However, my caculation on scratch paper shows the price
> p = c*(u+u^2+u^3+u^4) + 1*u^4 = 98.41
> where c = 0.025, u =1/(1+y/2)
What figures did you put into your calculation? The formula is correct (and
the calendar and day counter used in testCachedYield are consistent with
it,) but I get
c = 0.025/2 = 0.0125
y = 0.02925
u = 1/(1+y/2) = 0.98559
p = c*(u+u^2+u^3+u^4) + 1*u^4 = 99.18 (not 98.41)
There's still a difference, but it is due to the fact that your formula
gives you the price at the issue date. The test calculates the bond price
on November 22nd, 2004---22 days after. The difference is the discount
factor between the two dates. If one edits the test and writes
Date today(30,October,2004);
the result is consistent with the formula.
Later,
Luigi
----------------------------------------
Barker's Proof:
Proofreading is more effective after publication.