RE: R: Credit default pricing / G2++ model

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

RE: R: Credit default pricing / G2++ model

Toyin Akin
Hi Marco,

I too deduced that the main implementation was on page 149, but the formula
for M(0,T) is on pg 144. Thus I was refering just to this piece of code.

Thankyou for the explanation. I just wanted to know where the simplification
came from and now I know.

As for the pricing of Bermudan swaptions on FLT/FLT swaps, surely some
modifications will need to be done within the G2++ class?

In fact you would have 2 sets of logic, one for FLT/FLT (same currencies)
and one for FLT/FLT (different currencies). Or am I missing something...?

A G2++ model is perfect for pricing bermudan options on swaps, where the
swaps have differing currency legs.

Thankyou again,
Best Regards,
Toyin Akin.

>From: "Tarenghi Marco" <[hidden email]>
>To: "Toyin Akin" <[hidden email]>
>Subject: R: [Quantlib-users] Credit default pricing / G2++ model
>Date: Fri, 7 Oct 2005 09:01:17 +0200
>
>
>Hi Toyin,
>for what concerning the implementation of the G2++ model, I have tested the
>QuantLib functions and I think they work quite well. The formulas in
>G2::SwaptionPricingFunction class you are referring to are those on page
>149 of the Brigo-Mercurio book and not those on page 144.
>Anyway they use the formulas on page 144, since mux_ = -M(0,T): the fact is
>that the expression of mux_ is obtained using the formulas on page 144 but
>simply setting s=0 and t=T, so that the expression simplifies a lot.
>
>I hope I have been clear enough.
>
>Also, you are right: this class can price only vanilla options.
>Bermudan and/or amortizing swaptions can be priced using trees, and these
>are available in the G2 class: what you have to do is to implement a new
>Swaption class which has to derive from the DiscretizedOption class.
>
>Sorry for answering directly to you and not to the mailing list but I
>cannot do it with my office pc...
>I should do it from home
>
>Best regards,
>Marco
>
>-----Messaggio originale-----
>Da: [hidden email]
>[mailto:[hidden email]]Per conto di Toyin
>Akin
>Inviato: giovedì 6 ottobre 2005 17:26
>A: [hidden email]; [hidden email]
>Oggetto: [Quantlib-users] Credit default pricing / G2++ model
>
>
>
>Hi folks,
>
>Are there any plans to implement credit default swaps/options within
>QuantLib?
>
>I read somewhere, within one of the wilmott forums, that someone did
>actually have some working code. However I'm not too sure whether they are
>going to dedicate this code to the QuantLib project.
>
>I certainly would like to get a good handle on a C++ implementation of
>Credit derivatives as I'm pretty new to it, however I don't want to start a
>new credit project which could take months if someone else already has some
>working code.
>
>Also, I am stepping through the code of the G2++ model, comparing the math
>there to that of the Brigo-Mercurio book and all seems well apart from one
>expression that I can't get my head around.
>
>This concerns the code within the constructor of the
>G2::SwaptionPricingFunction class.
>
>There are expressions for mux_ and muy_ which I believe corresponds to the
>same expressions at the bottom of page 144.
>
>Taking just the mux_ expression, for example, I cannot match up the
>expressions within the book to that of the code. It's the 2nd and 3rd
>expressions of the formula (according to the book) that I am having some
>trouble matching up.
>
>Can someone confirm that the code here is correct and it's just a case of
>some smart mathematical  manipulation (My brain has already died after
>validating all the other parts of the G2 model!!).
>
>Also from my analysis, it looks like we can only price options on vanilla
>swaptions under this G2++ implementation, no variation of notionals
>(amortisation), coupons, or margins (spreads). This should be possible but
>I
>believe that the limiting factor is because it is based on a SimpleSwap
>object which does not allow for such rich definitions of a swap.
>
>Also, does anyone know what code changes would be needed to implement a
>bermudan swaption on a FLT/FLT swap? I don't think that the
>SwaptionPricingFunction class is valid for this type of structure.
>
>Very good clean code by the way...
>
>Best Regards,
>Toyin Akin.
>
>
>
>
>
>DISCLAIMER:
>Privileged/Confidential Information may be contained in this message and in
>any of its attachments (the "message"). If you are not the addressee
>indicated in this message (or responsible for delivery of the message to
>such person), you may not copy or deliver this message to anyone. In such
>case, you should destroy this message and kindly notify the sender by reply
>e-mail. The contents of this message shall be understood as neither given
>nor endorsed by Banca Profilo S.p.A., nor Profilo Real Estate SGR S.p.A.,
>nor Profilo Asset Management SGR S.p.A., nor Profilo Academy S.p.A.. Banca
>Profilo S.p.A., Profilo Real Estate SGR S.p.A., Profilo Asset Management
>SGR S.p.A., Profilo Academy S.p.A. do not accept liability for corruption,
>interception or amendment, if any, or the consequences thereof.
>Il presente messaggio e/o i suoi allegati (di seguito il "messaggio")
>possono contenere informazioni privilegiate e/o confidenziali. Se non siete
>i destinatari indicati nel messaggio (o persona incaricata di inoltrare il
>messaggio al/i destinatario/i), non potete copiare o inoltrare il messaggio
>ad altri e siete invitati a distruggerlo dandone informazione al mittente a
>mezzo e-mail. Il contenuto del presente messaggio non deve essere
>considerato come trasmesso o autorizzato nè da Banca Profilo S.p.A., nè da
>Profilo Real Estate SGR S.p.A., nè da Profilo Asset Management SGR S.p.A.,
>nè da Profilo Academy S.p.A.. Nè Banca Profilo S.p.A., nè Profilo Real
>Estate SGR S.p.A., nè Profilo Asset Management SGR S.p.A., nè Profilo
>Academy S.p.A. si assumono alcuna responsabilità per eventuali
>intercettazioni, modifiche o danneggiamenti del presente messaggio e-mail e
>per le eventuali conseguenze.




Reply | Threaded
Open this post in threaded view
|

RE: [Quantlib-dev] RE: R: Credit default pricing / G2++ model

Toyin Akin
Hi Marco,

Ignore my comments on bermudan swaptions on FLT/FLT swaps where both legs
are of the same currency. This can be defined, as you said, within a new
class inherited from the DiscretizedOption class if pricing via the Tree.

However can the same be said with FLT/FLT swaps with different currencies on
each leg (including exchange of notionals)?

Best Regards,
Toyin akin.







>From: "Toyin Akin" <[hidden email]>
>To: [hidden email],[hidden email]
>Subject: [Quantlib-dev] RE: R: [Quantlib-users] Credit default pricing /
>G2++ model
>Date: Fri, 07 Oct 2005 08:54:53 +0100
>
>
>Hi Marco,
>
>I too deduced that the main implementation was on page 149, but the formula
>for M(0,T) is on pg 144. Thus I was refering just to this piece of code.
>
>Thankyou for the explanation. I just wanted to know where the
>simplification came from and now I know.
>
>As for the pricing of Bermudan swaptions on FLT/FLT swaps, surely some
>modifications will need to be done within the G2++ class?
>
>In fact you would have 2 sets of logic, one for FLT/FLT (same currencies)
>and one for FLT/FLT (different currencies). Or am I missing something...?
>
>A G2++ model is perfect for pricing bermudan options on swaps, where the
>swaps have differing currency legs.
>
>Thankyou again,
>Best Regards,
>Toyin Akin.
>
>>From: "Tarenghi Marco" <[hidden email]>
>>To: "Toyin Akin" <[hidden email]>
>>Subject: R: [Quantlib-users] Credit default pricing / G2++ model
>>Date: Fri, 7 Oct 2005 09:01:17 +0200
>>
>>
>>Hi Toyin,
>>for what concerning the implementation of the G2++ model, I have tested
>>the QuantLib functions and I think they work quite well. The formulas in
>>G2::SwaptionPricingFunction class you are referring to are those on page
>>149 of the Brigo-Mercurio book and not those on page 144.
>>Anyway they use the formulas on page 144, since mux_ = -M(0,T): the fact
>>is that the expression of mux_ is obtained using the formulas on page 144
>>but simply setting s=0 and t=T, so that the expression simplifies a lot.
>>
>>I hope I have been clear enough.
>>
>>Also, you are right: this class can price only vanilla options.
>>Bermudan and/or amortizing swaptions can be priced using trees, and these
>>are available in the G2 class: what you have to do is to implement a new
>>Swaption class which has to derive from the DiscretizedOption class.
>>
>>Sorry for answering directly to you and not to the mailing list but I
>>cannot do it with my office pc...
>>I should do it from home
>>
>>Best regards,
>>Marco
>>
>>-----Messaggio originale-----
>>Da: [hidden email]
>>[mailto:[hidden email]]Per conto di Toyin
>>Akin
>>Inviato: giovedì 6 ottobre 2005 17:26
>>A: [hidden email]; [hidden email]
>>Oggetto: [Quantlib-users] Credit default pricing / G2++ model
>>
>>
>>
>>Hi folks,
>>
>>Are there any plans to implement credit default swaps/options within
>>QuantLib?
>>
>>I read somewhere, within one of the wilmott forums, that someone did
>>actually have some working code. However I'm not too sure whether they are
>>going to dedicate this code to the QuantLib project.
>>
>>I certainly would like to get a good handle on a C++ implementation of
>>Credit derivatives as I'm pretty new to it, however I don't want to start
>>a
>>new credit project which could take months if someone else already has
>>some
>>working code.
>>
>>Also, I am stepping through the code of the G2++ model, comparing the math
>>there to that of the Brigo-Mercurio book and all seems well apart from one
>>expression that I can't get my head around.
>>
>>This concerns the code within the constructor of the
>>G2::SwaptionPricingFunction class.
>>
>>There are expressions for mux_ and muy_ which I believe corresponds to the
>>same expressions at the bottom of page 144.
>>
>>Taking just the mux_ expression, for example, I cannot match up the
>>expressions within the book to that of the code. It's the 2nd and 3rd
>>expressions of the formula (according to the book) that I am having some
>>trouble matching up.
>>
>>Can someone confirm that the code here is correct and it's just a case of
>>some smart mathematical  manipulation (My brain has already died after
>>validating all the other parts of the G2 model!!).
>>
>>Also from my analysis, it looks like we can only price options on vanilla
>>swaptions under this G2++ implementation, no variation of notionals
>>(amortisation), coupons, or margins (spreads). This should be possible but
>>I
>>believe that the limiting factor is because it is based on a SimpleSwap
>>object which does not allow for such rich definitions of a swap.
>>
>>Also, does anyone know what code changes would be needed to implement a
>>bermudan swaption on a FLT/FLT swap? I don't think that the
>>SwaptionPricingFunction class is valid for this type of structure.
>>
>>Very good clean code by the way...
>>
>>Best Regards,
>>Toyin Akin.
>>
>>
>>
>>
>>
>>DISCLAIMER:
>>Privileged/Confidential Information may be contained in this message and
>>in any of its attachments (the "message"). If you are not the addressee
>>indicated in this message (or responsible for delivery of the message to
>>such person), you may not copy or deliver this message to anyone. In such
>>case, you should destroy this message and kindly notify the sender by
>>reply e-mail. The contents of this message shall be understood as neither
>>given nor endorsed by Banca Profilo S.p.A., nor Profilo Real Estate SGR
>>S.p.A., nor Profilo Asset Management SGR S.p.A., nor Profilo Academy
>>S.p.A.. Banca Profilo S.p.A., Profilo Real Estate SGR S.p.A., Profilo
>>Asset Management SGR S.p.A., Profilo Academy S.p.A. do not accept
>>liability for corruption, interception or amendment, if any, or the
>>consequences thereof.
>>Il presente messaggio e/o i suoi allegati (di seguito il "messaggio")
>>possono contenere informazioni privilegiate e/o confidenziali. Se non
>>siete i destinatari indicati nel messaggio (o persona incaricata di
>>inoltrare il messaggio al/i destinatario/i), non potete copiare o
>>inoltrare il messaggio ad altri e siete invitati a distruggerlo dandone
>>informazione al mittente a mezzo e-mail. Il contenuto del presente
>>messaggio non deve essere considerato come trasmesso o autorizzato nè da
>>Banca Profilo S.p.A., nè da Profilo Real Estate SGR S.p.A., nè da Profilo
>>Asset Management SGR S.p.A., nè da Profilo Academy S.p.A.. Nè Banca
>>Profilo S.p.A., nè Profilo Real Estate SGR S.p.A., nè Profilo Asset
>>Management SGR S.p.A., nè Profilo Academy S.p.A. si assumono alcuna
>>responsabilità per eventuali intercettazioni, modifiche o danneggiamenti
>>del presente messaggio e-mail e per le eventuali conseguenze.
>
>
>
>
>-------------------------------------------------------
>This SF.Net email is sponsored by:
>Power Architecture Resource Center: Free content, downloads, discussions,
>and more. http://solutions.newsforge.com/ibmarch.tmpl
>_______________________________________________
>Quantlib-dev mailing list
>[hidden email]
>https://lists.sourceforge.net/lists/listinfo/quantlib-dev




Reply | Threaded
Open this post in threaded view
|

RE: [Quantlib-dev] RE: R: Credit default pricing / G2++ model

Toyin Akin
Hi,

Concerning the Bermudan FLT/FLT swap (or bermudan basis swaption) assuming
one leg is based on a LIBOR curve and the other on a BASIS curve, how does
one refer to each individual curve within a DiscretizedAsset class (assuming
that one wants to model the code similar to that of the DiscretizedSwap
class). Or is the infrastructure only suitable for only refering to a single
curve.

It looks like you need to model two G2++ objects and their joint dynamics.

Probably the logic presented within the beginning of Chapter 11 of
Brigo-Mercurio.

Best Regards,
Toyin Akin.


>From: "Toyin Akin" <[hidden email]>
>To: [hidden email],[hidden email]
>Subject: RE: [Quantlib-dev] RE: R: [Quantlib-users] Credit default pricing
>/ G2++ model
>Date: Fri, 07 Oct 2005 17:21:56 +0100
>
>
>Hi Marco,
>
>Ignore my comments on bermudan swaptions on FLT/FLT swaps where both legs
>are of the same currency. This can be defined, as you said, within a new
>class inherited from the DiscretizedOption class if pricing via the Tree.
>
>However can the same be said with FLT/FLT swaps with different currencies
>on each leg (including exchange of notionals)?
>
>Best Regards,
>Toyin akin.
>
>
>
>
>
>
>
>>From: "Toyin Akin" <[hidden email]>
>>To:
>>[hidden email],[hidden email]
>>Subject: [Quantlib-dev] RE: R: [Quantlib-users] Credit default pricing /
>>G2++ model
>>Date: Fri, 07 Oct 2005 08:54:53 +0100
>>
>>
>>Hi Marco,
>>
>>I too deduced that the main implementation was on page 149, but the
>>formula for M(0,T) is on pg 144. Thus I was refering just to this piece of
>>code.
>>
>>Thankyou for the explanation. I just wanted to know where the
>>simplification came from and now I know.
>>
>>As for the pricing of Bermudan swaptions on FLT/FLT swaps, surely some
>>modifications will need to be done within the G2++ class?
>>
>>In fact you would have 2 sets of logic, one for FLT/FLT (same currencies)
>>and one for FLT/FLT (different currencies). Or am I missing something...?
>>
>>A G2++ model is perfect for pricing bermudan options on swaps, where the
>>swaps have differing currency legs.
>>
>>Thankyou again,
>>Best Regards,
>>Toyin Akin.
>>
>>>From: "Tarenghi Marco" <[hidden email]>
>>>To: "Toyin Akin" <[hidden email]>
>>>Subject: R: [Quantlib-users] Credit default pricing / G2++ model
>>>Date: Fri, 7 Oct 2005 09:01:17 +0200
>>>
>>>
>>>Hi Toyin,
>>>for what concerning the implementation of the G2++ model, I have tested
>>>the QuantLib functions and I think they work quite well. The formulas in
>>>G2::SwaptionPricingFunction class you are referring to are those on page
>>>149 of the Brigo-Mercurio book and not those on page 144.
>>>Anyway they use the formulas on page 144, since mux_ = -M(0,T): the fact
>>>is that the expression of mux_ is obtained using the formulas on page 144
>>>but simply setting s=0 and t=T, so that the expression simplifies a lot.
>>>
>>>I hope I have been clear enough.
>>>
>>>Also, you are right: this class can price only vanilla options.
>>>Bermudan and/or amortizing swaptions can be priced using trees, and these
>>>are available in the G2 class: what you have to do is to implement a new
>>>Swaption class which has to derive from the DiscretizedOption class.
>>>
>>>Sorry for answering directly to you and not to the mailing list but I
>>>cannot do it with my office pc...
>>>I should do it from home
>>>
>>>Best regards,
>>>Marco
>>>
>>>-----Messaggio originale-----
>>>Da: [hidden email]
>>>[mailto:[hidden email]]Per conto di Toyin
>>>Akin
>>>Inviato: giovedì 6 ottobre 2005 17:26
>>>A: [hidden email]; [hidden email]
>>>Oggetto: [Quantlib-users] Credit default pricing / G2++ model
>>>
>>>
>>>
>>>Hi folks,
>>>
>>>Are there any plans to implement credit default swaps/options within
>>>QuantLib?
>>>
>>>I read somewhere, within one of the wilmott forums, that someone did
>>>actually have some working code. However I'm not too sure whether they
>>>are
>>>going to dedicate this code to the QuantLib project.
>>>
>>>I certainly would like to get a good handle on a C++ implementation of
>>>Credit derivatives as I'm pretty new to it, however I don't want to start
>>>a
>>>new credit project which could take months if someone else already has
>>>some
>>>working code.
>>>
>>>Also, I am stepping through the code of the G2++ model, comparing the
>>>math
>>>there to that of the Brigo-Mercurio book and all seems well apart from
>>>one
>>>expression that I can't get my head around.
>>>
>>>This concerns the code within the constructor of the
>>>G2::SwaptionPricingFunction class.
>>>
>>>There are expressions for mux_ and muy_ which I believe corresponds to
>>>the
>>>same expressions at the bottom of page 144.
>>>
>>>Taking just the mux_ expression, for example, I cannot match up the
>>>expressions within the book to that of the code. It's the 2nd and 3rd
>>>expressions of the formula (according to the book) that I am having some
>>>trouble matching up.
>>>
>>>Can someone confirm that the code here is correct and it's just a case of
>>>some smart mathematical  manipulation (My brain has already died after
>>>validating all the other parts of the G2 model!!).
>>>
>>>Also from my analysis, it looks like we can only price options on vanilla
>>>swaptions under this G2++ implementation, no variation of notionals
>>>(amortisation), coupons, or margins (spreads). This should be possible
>>>but I
>>>believe that the limiting factor is because it is based on a SimpleSwap
>>>object which does not allow for such rich definitions of a swap.
>>>
>>>Also, does anyone know what code changes would be needed to implement a
>>>bermudan swaption on a FLT/FLT swap? I don't think that the
>>>SwaptionPricingFunction class is valid for this type of structure.
>>>
>>>Very good clean code by the way...
>>>
>>>Best Regards,
>>>Toyin Akin.
>>>
>>>
>>>
>>>
>>>
>>>DISCLAIMER:
>>>Privileged/Confidential Information may be contained in this message and
>>>in any of its attachments (the "message"). If you are not the addressee
>>>indicated in this message (or responsible for delivery of the message to
>>>such person), you may not copy or deliver this message to anyone. In such
>>>case, you should destroy this message and kindly notify the sender by
>>>reply e-mail. The contents of this message shall be understood as neither
>>>given nor endorsed by Banca Profilo S.p.A., nor Profilo Real Estate SGR
>>>S.p.A., nor Profilo Asset Management SGR S.p.A., nor Profilo Academy
>>>S.p.A.. Banca Profilo S.p.A., Profilo Real Estate SGR S.p.A., Profilo
>>>Asset Management SGR S.p.A., Profilo Academy S.p.A. do not accept
>>>liability for corruption, interception or amendment, if any, or the
>>>consequences thereof.
>>>Il presente messaggio e/o i suoi allegati (di seguito il "messaggio")
>>>possono contenere informazioni privilegiate e/o confidenziali. Se non
>>>siete i destinatari indicati nel messaggio (o persona incaricata di
>>>inoltrare il messaggio al/i destinatario/i), non potete copiare o
>>>inoltrare il messaggio ad altri e siete invitati a distruggerlo dandone
>>>informazione al mittente a mezzo e-mail. Il contenuto del presente
>>>messaggio non deve essere considerato come trasmesso o autorizzato nè da
>>>Banca Profilo S.p.A., nè da Profilo Real Estate SGR S.p.A., nè da Profilo
>>>Asset Management SGR S.p.A., nè da Profilo Academy S.p.A.. Nè Banca
>>>Profilo S.p.A., nè Profilo Real Estate SGR S.p.A., nè Profilo Asset
>>>Management SGR S.p.A., nè Profilo Academy S.p.A. si assumono alcuna
>>>responsabilità per eventuali intercettazioni, modifiche o danneggiamenti
>>>del presente messaggio e-mail e per le eventuali conseguenze.
>>
>>
>>
>>
>>-------------------------------------------------------
>>This SF.Net email is sponsored by:
>>Power Architecture Resource Center: Free content, downloads, discussions,
>>and more. http://solutions.newsforge.com/ibmarch.tmpl
>>_______________________________________________
>>Quantlib-dev mailing list
>>[hidden email]
>>https://lists.sourceforge.net/lists/listinfo/quantlib-dev
>
>
>
>
>-------------------------------------------------------
>This SF.Net email is sponsored by:
>Power Architecture Resource Center: Free content, downloads, discussions,
>and more. http://solutions.newsforge.com/ibmarch.tmpl
>_______________________________________________
>Quantlib-dev mailing list
>[hidden email]
>https://lists.sourceforge.net/lists/listinfo/quantlib-dev




Reply | Threaded
Open this post in threaded view
|

Bug in MCAmericanBasketEngine class

Toyin Akin
In reply to this post by Toyin Akin
Hi,

Seems to crash if you specify an odd number (ie - 5) for the required sample
size parameter of the constructor.

I've tracked it down to line 445, the crash actually happens on line 458.

Seems like the logic for filling in the array is flawed when an odd number
is specified (greater than 1).

Best Regards,
Toyin Akin.