Floating Rate bond pricing related questions in QL and QLXL

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Floating Rate bond pricing related questions in QL and QLXL

christos.arvanitis
Hello to everyone
I have some questions related in general with the pricing of Floating Bonds in QL and QLXL


1. Question
Started from the QL example FittedBondCurve.cpp I have managed to understand it and compiled fine and ok! Then i have altered a bit the code trying to test my understanding. I have altered the part of the shifted YC calculations for instance as:

for (Size k=0; k<LENGTH(mat_fix)-1; k++) { //start from 0


        // retrieve quote object & value from instruments
        Real P = instrumentsB[k]->quote()->value();

        // retrieve bond object from instruments
            const Bond& b = *instrumentsB[k]->bond();


            // Calculate YTM
            // BondFunctions is a structure containing Bond calculation  methods
            Rate ytm = BondFunctions::yield(b,             // Bond object
            P,             // value clean price
                                            dc_AA,         // day-counter
                                            Compounded,    // compounding
                                            Annual,        // freq
                                            today);        // calculation date



            // Calculate Duration
            Time dur = BondFunctions::duration(b,           // Bond object
              ytm,         // yield
                                               dc_AA,       // day-counter
                                               Compounded,  // compounding
                                               Annual,      // freq
                                               Duration::Modified,  // modified duration
                                               today);      // calculation date



            // Calculate Convexity
            Real convexity = BondFunctions::convexity(b,
             ytm,
             dc_AA,
             Compounded,
             Annual,
             today);


            // Rate shift
            const Real bpsChange = 5.;

            // dP = -dur * P * dY+0.5*P^2*convexity*dy^2

                          // duration correction
            Real deltaP = -dur * P * (bpsChange/10000.)
                  // convexity  correction
                  +0.5*pow(P,2)*convexity*pow(bpsChange/10000.,2);

            // set calculate corrected values

             quote[k+1]->setValue(P + deltaP);

        }


the instumentsB is the ususal vector of bond helpers

the above code part fails to compile with the error

..\main.cpp:1409:14: error: 'quote' was not declared in this scope


2. Question
To price a floatter without cap/floor do you always have to specify the coupon pricer with zero vol?

3. Question
I have created a floating bond with say a cap and to price this bond I have to specify appart the YC the vol curve and passed to the coupon pricer
a. Appart the blackcoupon pricer what other pricer classes can i use
b. can you provide with a sample code for the stripping of capplets and calculation of vol surface

4. Question
I tried also to implement part of the calculation using the SWIG Python Bindinds. I have remarked that there are no available bindings for the Nelson siegel method. Is this because it is hard to expose the class to python?

5. Question
Then to go further i have tried to implement the full floating bond valuation in QLXL.
I have managed to reproduce the pricing and risk figures in accordance with Bloomberg but its worth to mention few questions i had
I have remarked the following things:

a. All setting being equal between the Bloomberg and qlxl i have remarked that the next coupon function for floatter has a permanet 1-2 days diff with bloomberg for some not all the floatters i have tested.
I will retest the settings again and repost back in case the issue persists

b. In QLXL only the blackiborcoupon pricer is exposed are there any other possibilities?

c. In QLXL there is no bindinds for the Nelson siegel method the only posiibility being the piecewise bootstrapping.Are they dificult to expose this class in xl?


I thing i have to stop here for the moment


Thank you very much in advance for your help

Regards
Christos




Reply | Threaded
Open this post in threaded view
|

Re: Floating Rate bond pricing related questions in QL and QLXL

christos.arvanitis
please can anyone can help at least with the first question?
Many tnks
christos
Reply | Threaded
Open this post in threaded view
|

Re: Floating Rate bond pricing related questions in QL and QLXL

Luigi Ballabio
As for the first question: what is line 1409 in your main.cpp?  You're
using a variable "quote" there which is not defined.

The second: if you don't have caps or floors the vol won't be used,
even if you pass it; but you don't need to. You can leave it empty.

The other questions will take more time...

Luigi


On Wed, Jul 31, 2013 at 1:10 PM, christos.arvanitis
<[hidden email]> wrote:

> please can anyone can help at least with the first question?
> Many tnks
> christos
>
>
>
> --
> View this message in context: http://quantlib.10058.n7.nabble.com/Floating-Rate-bond-pricing-related-questions-in-QL-and-QLXL-tp14476p14479.html
> Sent from the quantlib-users mailing list archive at Nabble.com.
>
> ------------------------------------------------------------------------------
> Get your SQL database under version control now!
> Version control is standard for application code, but databases havent
> caught up. So what steps can you take to put your SQL databases under
> version control? Why should you start doing it? Read more to find out.
> http://pubads.g.doubleclick.net/gampad/clk?id=49501711&iu=/4140/ostg.clktrk
> _______________________________________________
> QuantLib-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/quantlib-users



--
<https://implementingquantlib.blogspot.com>
<https://twitter.com/lballabio>

------------------------------------------------------------------------------
Get your SQL database under version control now!
Version control is standard for application code, but databases havent
caught up. So what steps can you take to put your SQL databases under
version control? Why should you start doing it? Read more to find out.
http://pubads.g.doubleclick.net/gampad/clk?id=49501711&iu=/4140/ostg.clktrk
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: Floating Rate bond pricing related questions in QL and QLXL

christos.arvanitis
In reply to this post by christos.arvanitis
Dear Luigi,

Thank you very much for your reply.

1. It is clear to me by know that whenever i have a floater without a cap or floor no optionlet vol is needed to pass to the coupon pricer. In fact the coupon pricer is not neeeded at all.

2. For the cpp code issue i have to tell that i dont understand fully what is going on........!
   I have not manage to change properly the bond values with the changes induced by the  bps change.
   As far as I understand setValue() is a modifier method for SimpleQuote
   I have instrumentsB which is a vector of shared_ptr<BondHelper> with a quoteHandle attached which  is  initiated by a SimpleQuote.

Therefore it looked reasonable to me to mimic the original code from the example FittedBondCurve.cpp of QL examples which compiles without a problem

Below I copy the part of the original code from the QL example and my code for reference

If way is not compiling properly can you suggest a code piece which can change the bond quotes by applying the bps change?


a.  FittedBondCurve.cpp example loop across bonds


for (Size k=0; k<LENGTH(lengths)-1; k++) {

            Real P = instrumentsA[k]->quote()->value();   // retrieve quote object & value from instrumentsA
            const Bond& b = *instrumentsA[k]->bond();    // retrieve bond object from instrumentsA


            // Calculate YTM
            // BondFunctions is a structure containing Bond calculation  methods
            Rate ytm = BondFunctions::yield(b,             // Bond object
                P,             // value clean price
                                                        dc,            // day-counter
                                                        Compounded,    // compounding
                                                        frequency,     // Annual
                                                        today);        // calculation date



            // Calculate duration
            Time dur = BondFunctions::duration(b,           // Bond object
                     ytm,         // yield
                                                             dc,          // day-counter
                                                             Compounded,  // compounding
                                                             frequency,   // Annual
                                                             Duration::Modified,  // modified duration
                                                             today);      // calculation date



            // Calculate convexity
            Real convexity = BondFunctions::convexity(
                                                                       b,
                               ytm,
                                            dc,
                           Compounded,
                        frequency,
            today);


            // Rate shift
            const Real bpsChange = 5.;

            // dP = -dur * P * dY+0.5*P^2*convexity*dy^2
            Real deltaP = -dur * P * (bpsChange/10000.)+      // duration correction
                  0.5*pow(P,2)*convexity*pow(bpsChange/10000.,2);  // conv correction

            // set calculate corrected values
            quote[k+1]->setValue(P + deltaP);       
}


which compiles fine


b. my code which in fact is a copy !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!


for (Size k=0; k<LENGTH(mat_fix)-1; k++) { //start from 0


        // retrieve quote object & value from instruments
        Real P = instrumentsB[k]->quote()->value();

        // retrieve bond object from instruments
            const Bond& b = *instrumentsB[k]->bond();


            // Calculate YTM
            // BondFunctions is a structure containing Bond calculation  methods
            Rate ytm = BondFunctions::yield(b,             // Bond object
                P,             // value clean price
                                                        dc_AA,         // day-counter
                                                        Compounded,    // compounding
                                                        Annual,        // freq
                                                        today);        // calculation date



            // Calculate Duration
            Time dur = BondFunctions::duration(b,           // Bond object
                                 ytm,         // yield
                                                            dc_AA,       // day-counter
                                                            Compounded,  // compounding
                                                            Annual,      // freq
                                                           Duration::Modified,  // modified duration
                                                           today);      // calculation date



            // Calculate Convexity
            Real convexity = BondFunctions::convexity(b,
             ytm,
             dc_AA,
             Compounded,
             Annual,
             today);


            // Rate shift
            const Real bpsChange = 5.;

            // dP = -dur * P * dY+0.5*P^2*convexity*dy^2

                          // duration correction
            Real deltaP = -dur * P * (bpsChange/10000.)
                  // convexity  correction
                  +0.5*pow(P,2)*convexity*pow(bpsChange/10000.,2);

            // set calculate corrected values

            quote[k+1]->setValue(P + deltaP);

        }


Thanks in advance for the support and help provided

christos arvanitis


Reply | Threaded
Open this post in threaded view
|

Re: Floating Rate bond pricing related questions in QL and QLXL

Luigi Ballabio
Christos,
    apologies for the delay, I was on vacation last week.

I'm not sure what you're doing here exactly.  Did you copy the code
from the example into your own code? If so, make sure that you also
copied the relevant declarations, or the compiler won't know what
you're referring to (for instance, you'll need the declaration of
"quote" at line 98 in the original file).

Luigi



On Thu, Aug 1, 2013 at 12:48 PM, christos.arvanitis
<[hidden email]> wrote:

> Dear Luigi,
>
> Thank you very much for your reply.
>
> 1. It is clear to me by know that whenever i have a floater without a cap or
> floor no optionlet vol is needed to pass to the coupon pricer. In fact the
> coupon pricer is not neeeded at all.
>
> 2. For the cpp code issue i have to tell that i dont understand fully what
> is going on........!
>    I have not manage to change properly the bond values with the changes
> induced by the  bps change.
>    As far as I understand setValue() is a modifier method for SimpleQuote
>    I have instrumentsB which is a vector of shared_ptr<BondHelper> with a
> quoteHandle attached which  is  initiated by a SimpleQuote.
>
> Therefore it looked reasonable to me to mimic the original code from the
> example FittedBondCurve.cpp of QL examples which compiles without a problem
>
> Below I copy the part of the original code from the QL example and my code
> for reference
>
> If way is not compiling properly can you suggest a code piece which can
> change the bond quotes by applying the bps change?
>
>
> a.  FittedBondCurve.cpp example loop across bonds
>
>
> for (Size k=0; k<LENGTH(lengths)-1; k++) {
>
>             Real P = instrumentsA[k]->quote()->value();   // retrieve quote
> object & value from instrumentsA
>             const Bond& b = *instrumentsA[k]->bond();    // retrieve bond
> object from instrumentsA
>
>
>             // Calculate YTM
>             // BondFunctions is a structure containing Bond calculation
> methods
>             Rate ytm = BondFunctions::yield(b,             // Bond object
>                                              P,             // value clean price
>                                                         dc,            //
> day-counter
>                                                         Compounded,    //
> compounding
>                                                         frequency,     //
> Annual
>                                                         today);        //
> calculation date
>
>
>
>             // Calculate duration
>             Time dur = BondFunctions::duration(b,           // Bond object
>                                                   ytm,         // yield
>                                                              dc,          //
> day-counter
>                                                              Compounded,  //
> compounding
>                                                              frequency,   //
> Annual
>
> Duration::Modified,  // modified duration
>                                                              today);      //
> calculation date
>
>
>
>             // Calculate convexity
>             Real convexity = BondFunctions::convexity(
>                                                                        b,
>                                                             ytm,
>                                                                  dc,
>                                                                                                         Compounded,
>                                                                                                      frequency,
>                                                 today);
>
>
>             // Rate shift
>             const Real bpsChange = 5.;
>
>             // dP = -dur * P * dY+0.5*P^2*convexity*dy^2
>             Real deltaP = -dur * P * (bpsChange/10000.)+      // duration
> correction
>                                0.5*pow(P,2)*convexity*pow(bpsChange/10000.,2);  //
> conv correction
>
>             // set calculate corrected values
>            * quote[k+1]->setValue(P + deltaP);*
> }
>
>
> which compiles fine
>
>
> b. my code which in fact is a copy
> !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
>
>
> for (Size k=0; k<LENGTH(mat_fix)-1; k++) { //start from 0
>
>
>                 // retrieve quote object &amp; value from instruments
>                 Real P = instrumentsB[k]->quote()->value();
>
>                  // retrieve bond object from instruments
>             const Bond& b = *instrumentsB[k]->bond();
>
>
>             // Calculate YTM
>             // BondFunctions is a structure containing Bond calculation
> methods
>             Rate ytm = BondFunctions::yield(b,             // Bond object
>                                              P,             // value clean price
>                                                         dc_AA,         //
> day-counter
>                                                         Compounded,    //
> compounding
>                                                         Annual,        //
> freq
>                                                         today);        //
> calculation date
>
>
>
>             // Calculate Duration
>             Time dur = BondFunctions::duration(b,           // Bond object
>                                                       ytm,         // yield
>                                                             dc_AA,       //
> day-counter
>                                                             Compounded,  //
> compounding
>                                                             Annual,      //
> freq
>
> Duration::Modified,  // modified duration
>                                                            today);      //
> calculation date
>
>
>
>             // Calculate Convexity
>             Real convexity = BondFunctions::convexity(b,
>                                                                                           ytm,
>                                                                                           dc_AA,
>                                                                                           Compounded,
>                                                                                           Annual,
>                                                                                           today);
>
>
>             // Rate shift
>             const Real bpsChange = 5.;
>
>             // dP = -dur * P * dY+0.5*P^2*convexity*dy^2
>
>                           // duration correction
>             Real deltaP = -dur * P * (bpsChange/10000.)
>                                // convexity  correction
>                                +0.5*pow(P,2)*convexity*pow(bpsChange/10000.,2);
>
>             // set calculate corrected values
>
>             quote[k+1]->setValue(P + deltaP);
>
>         }
>
>
> Thanks in advance for the support and help provided
>
> christos arvanitis
>
>
>
>
>
>
> --
> View this message in context: http://quantlib.10058.n7.nabble.com/Floating-Rate-bond-pricing-related-questions-in-QL-and-QLXL-tp14476p14481.html
> Sent from the quantlib-users mailing list archive at Nabble.com.
>
> ------------------------------------------------------------------------------
> Get your SQL database under version control now!
> Version control is standard for application code, but databases havent
> caught up. So what steps can you take to put your SQL databases under
> version control? Why should you start doing it? Read more to find out.
> http://pubads.g.doubleclick.net/gampad/clk?id=49501711&iu=/4140/ostg.clktrk
> _______________________________________________
> QuantLib-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/quantlib-users



--
<https://implementingquantlib.blogspot.com>
<https://twitter.com/lballabio>

------------------------------------------------------------------------------
Get 100% visibility into Java/.NET code with AppDynamics Lite!
It's a free troubleshooting tool designed for production.
Get down to code-level detail for bottlenecks, with <2% overhead.
Download for free and get started troubleshooting in minutes.
http://pubads.g.doubleclick.net/gampad/clk?id=48897031&iu=/4140/ostg.clktrk
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: Floating Rate bond pricing related questions in QL and QLXL

christos.arvanitis
Dear Luigi,

Thanks again for your reply. I was on holiday too and I have seen your reply today.

Regarding my inquiries i posted some time ago i have to report that

Q1 Solved it was a stupidity from my part. I had  a typo in the declarations of variables in my cpp files sorry for waisting your time

Q2 solved and understood

Q3 i am still struggling to undestand how i can strip vol vol curves there from capplets. I will be helpfull if you can provide some exaples and sample code

Q4 and Q5 are the hardest ones I is not at all clear to me how i can create python and excel bindings of c++ functions classes. For instance how one can implement Nelson-Siegel at QLXL? Where i can find some guidance?

Thnks again for your help

Regards

christos



 
Reply | Threaded
Open this post in threaded view
|

Re: Floating Rate bond pricing related questions in QL and QLXL

Luigi Ballabio
Christos,
    apologies for the delay--again.

What little sample code we have for caplet stripping is in the test
suite, in optionletstripper.cpp.  The classes themselves are in the
ql/termstructure/volatility/optionlet folder.

As for QLXL, Eric has some tutorials up at
<http://quantlib.org/quantlibaddin//tutorials.html>. You'll probably
want to follow "Expose QuantLib Classes to QuantLibXL".

Later,
    Luigi



On Mon, Sep 2, 2013 at 4:21 PM, christos.arvanitis
<[hidden email]> wrote:

> Dear Luigi,
>
> Thanks again for your reply. I was on holiday too and I have seen your reply
> today.
>
> Regarding my inquiries i posted some time ago i have to report that
>
> Q1 Solved it was a stupidity from my part. I had  a typo in the declarations
> of variables in my cpp files sorry for waisting your time
>
> Q2 solved and understood
>
> Q3 i am still struggling to undestand how i can strip vol vol curves there
> from capplets. I will be helpfull if you can provide some exaples and sample
> code
>
> Q4 and Q5 are the hardest ones I is not at all clear to me how i can create
> python and excel bindings of c++ functions classes. For instance how one can
> implement Nelson-Siegel at QLXL? Where i can find some guidance?
>
> Thnks again for your help
>
> Regards
>
> christos
>
>
>
>
>
>
>
> --
> View this message in context: http://quantlib.10058.n7.nabble.com/Floating-Rate-bond-pricing-related-questions-in-QL-and-QLXL-tp14476p14505.html
> Sent from the quantlib-users mailing list archive at Nabble.com.
>
> ------------------------------------------------------------------------------
> How ServiceNow helps IT people transform IT departments:
> 1. Consolidate legacy IT systems to a single system of record for IT
> 2. Standardize and globalize service processes across IT
> 3. Implement zero-touch automation to replace manual, redundant tasks
> http://pubads.g.doubleclick.net/gampad/clk?id=51271111&iu=/4140/ostg.clktrk
> _______________________________________________
> QuantLib-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/quantlib-users



--
<https://implementingquantlib.blogspot.com>
<https://twitter.com/lballabio>

------------------------------------------------------------------------------
LIMITED TIME SALE - Full Year of Microsoft Training For Just $49.99!
1,500+ hours of tutorials including VisualStudio 2012, Windows 8, SharePoint
2013, SQL 2012, MVC 4, more. BEST VALUE: New Multi-Library Power Pack includes
Mobile, Cloud, Java, and UX Design. Lowest price ever! Ends 9/20/13.
http://pubads.g.doubleclick.net/gampad/clk?id=58041151&iu=/4140/ostg.clktrk
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: Floating Rate bond pricing related questions in QL and QLXL

christos.arvanitis
In reply to this post by christos.arvanitis
Dear Luigi,

Thanks for your help I will take a careful look in the libary for optionlets stripping and I will revert back....

As for the exposition of the Nelson Siegel class in QLXL it looks to me that it is indeed a harder excersise....
I will take a look at the suggested tutorial but any way if its possible i will appreciate also any additional help from any of you that had the experience to expose already the class at excel.

Now comes another question on the universe of flotters in QL
How I can construct in QL a floater that say at a first period has a floating ibor index and after a while turns to constant maturity index?

Thanks in advance for your help

Best Regards
Christos Arvanitis
 
Reply | Threaded
Open this post in threaded view
|

Re: Floating Rate bond pricing related questions in QL and QLXL

Luigi Ballabio
Hi Christos,
    you'll have to build a new bond class, but that's easier than it
seems.  If you look at the way the FloatingRateBond and CmsRateBond
classes are implemented, you'll see that they inherit all their
functionality from the Bond class and that they only define a
constructor where they build their cashflows.

You can build such a class whose constructor should build a series of
cms cashflows (like CmsRateBond) and then replace the first one with
an IborCoupon.

Luigi



On Thu, Sep 19, 2013 at 4:49 PM, christos.arvanitis
<[hidden email]> wrote:

> Dear Luigi,
>
> Thanks for your help I will take a careful look in the libary for optionlets
> stripping and I will revert back....
>
> As for the exposition of the Nelson Siegel class in QLXL it looks to me that
> it is indeed a harder excersise....
> I will take a look at the suggested tutorial but any way if its possible i
> will appreciate also any additional help from any of you that had the
> experience to expose already the class at excel.
>
> Now comes another question on the universe of flotters in QL
> How I can construct in QL a floater that say at a first period has a
> floating ibor index and after a while turns to constant maturity index?
>
> Thanks in advance for your help
>
> Best Regards
> Christos Arvanitis
>
>
>
>
> --
> View this message in context: http://quantlib.10058.n7.nabble.com/Floating-Rate-bond-pricing-related-questions-in-QL-and-QLXL-tp14476p14527.html
> Sent from the quantlib-users mailing list archive at Nabble.com.
>
> ------------------------------------------------------------------------------
> LIMITED TIME SALE - Full Year of Microsoft Training For Just $49.99!
> 1,500+ hours of tutorials including VisualStudio 2012, Windows 8, SharePoint
> 2013, SQL 2012, MVC 4, more. BEST VALUE: New Multi-Library Power Pack includes
> Mobile, Cloud, Java, and UX Design. Lowest price ever! Ends 9/20/13.
> http://pubads.g.doubleclick.net/gampad/clk?id=58041151&iu=/4140/ostg.clktrk
> _______________________________________________
> QuantLib-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/quantlib-users



--
<https://implementingquantlib.blogspot.com>
<https://twitter.com/lballabio>

------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60133471&iu=/4140/ostg.clktrk
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users