Re: Bond Credit Spread Calibration

Posted by John Orford on
URL: http://quantlib.414.s1.nabble.com/Bond-Credit-Spread-Calibration-tp16237p16244.html

Thanks Cheng! I'll check your amendments now and let you know : )

On Mon Feb 09 2015 at 9:58:35 AM cheng li <[hidden email]> wrote:

Hi John,

 

Thank you for sharing your codes. There are some changes needed to be made to your codes to make the example work properly:

 

Line 80: z_spreaded_term_structure = ZeroSpreadedTermStructure( discounting_term_structure, QuoteHandle( z_spread ))

 

Should be amended as :

 

Line 80: z_spreaded_term_structure = ZeroSpreadedTermStructure( discounting_term_structure, QuoteHandle( z_spread ), compounding,  payment_frequency)

 

Z-Spread has its own compounding rule and frequency. And you should make it consistent with what you offer to the function when you call CashFlows.zSpread.

 

Line 153: print "NPV+AA\t" + str(fixed_rate_bond.NPV() + fixed_rate_bond.accruedAmount())

 

Should be:

 

Line 153: print "NPV-AA\t" + str(fixed_rate_bond.NPV() - fixed_rate_bond.accruedAmount())

 

Normally NPV of bond is it dirty price. So AA should be excluded to be compared with MV which supposed to be clean price.

 

Regards,

Cheng

 

发件人: John Orford [mailto:[hidden email]]
发送时间: 201526 18:34
收件人: QuantLib users
主题: Re: [Quantlib-users] Bond Credit Spread Calibration

 

Previous file was wrong - this is the one to look at.

On Fri Feb 06 2015 at 6:23:46 PM John Orford <[hidden email]> wrote:

I attached an example.

 

Suspect this isn't a stupid mistake, but a fundamental misunderstanding of mine, which is a little worrying.

 

Any help'll be appreciated.

 

John

 

On Fri Feb 06 2015 at 1:06:50 PM John Orford <[hidden email]> wrote:

Hey Guys,

 

Long time no questions - looking forward to getting back into QL again! Spending too much time ensconced in Javascript.

 

In any case, I can't figure out what I am doing wrong.

 

I create a FixedRateBond object with all the requisite accoutrements.

 

Then call a zSpread function reusing everything from the FixedRateBond object.

 

For the NPV which'll be calibrated to, I take a quoted clean market price and add the accrued amount from the bond object.

 

For example, MV = 135, Accrued Amt = 9.99, and NPV ~= 145.

 

However, when I take the output of the zSpread function and create a new object, the NPV turns out to be ~144.

 

I tried increasing accuracy and iterations but to no avail.

 

Are there any common gotchas while using the zSpread function?

 

As I write this I realise, a code example would be very helpful. I will do that now.

 

John


------------------------------------------------------------------------------
Dive into the World of Parallel Programming. The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net/
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users