Re: Question about using QuantLib
Posted by
Dale Smith-7 on
URL: http://quantlib.414.s1.nabble.com/Question-about-using-QuantLib-tp3801p3803.html
Hi there,
I had some time to work on the suggestions
below. I do have one question, there doesn't seem to be a constructor for
FixedCouponBond in my build of 0.3.8 that takes a Handle<YieldTermStructure>.
The only one I can find does not take the Handle. In addition, cleanPrice
has two arguments - Rate and Date. I also checked the header file ql/Instruments/fixedcouponbond.hpp
and the constructor doesn't accept a Handle<YieldTermStructure>.
Should I get a later version than 0.3.8?
Is there something else going on that I am missing?
Thanks again,
Dale Smith, Ph.D.
[hidden email]
DTCC Risk Management
Quantitative Group
212-855-7641
Hi Dale,
On 05/25/2005 09:50:51 PM, Dale Smith wrote:
> I am a new QuantLib user. Right now I'm trying to use QuantLib to
> price straight Treasury bonds using a specified yield curve. I have
> read over the documentation, and more importantly, looked at the
> examples and test suite code. I still don't have a picture about how
> things should work.
> I'm following the swap valuation example to get a Handle to a
> YieldTermStructure. My specific question is how do I get back the
> discretely compounded forward rates for use in the pricing formula
> for the Treasury bond.
You can get the discount factors directly from the curve; once you have
a handle h, you can use h->discount(d) to get the discount factor at
a
date d. You can then obtain the price as the sum of the discounted
coupons. By the way, this is already implemented in the
performCalculations() method of class Bond; you can write e.g.
Handle<YieldTermStructure> h;
...initialize the term structure...
FixedCouponBond bond(parameters including h);
Real price = bond.cleanPrice();
to trigger the calculation.
On the other hand, if you want to get at the single forward rates, you
can use the forwardRate() method of YieldTermStructure. Given a handle
h, you can write e.g.
InterestRate f = h->forwardRate(d1,d2,dayCounter,Compounded,Annual);
to get the forward (where d1 and d2 are the start and end dates of the
coupon and dayCounter its day-count convention.) You can then combine
the forwards according to the formula.
One final remark: the yield term-structure in the swap-valuation
example is bootstrapped based on deposit-rate and swap-rate fixings,
which might or might not be appropriate for bond pricing. We'd welcome
any contribution aimed at obtaining a proper bond curve.
Later,
Luigi
----------------------------------------
The rule on staying alive as a forecaster is to give 'em a number or
give 'em a date, but never give 'em both at once.
-- Jane Bryant Quinn
-------------------------------------------------------
SF.Net email is sponsored by: GoToMeeting - the easiest way to collaborate
online with coworkers and clients while avoiding the high cost of travel
and
communications. There is no equipment to buy and you can meet as often
as
you want. Try it free.http://ads.osdn.com/?ad_idt02&alloc_id135&op=click
_______________________________________________
Quantlib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users