Hello all, first of i would like to thank the people responsible, especially Luigi and Ferdinando, for the forum last week in London. I enjoyed it. Now my question about swap evaluation: QuantLib version: 1.0.1 In "QuantLib::DiscountingSwapEngine" the settlement and evaluation dates are determined as follows: ------------------------------------------------------------------------------------ Date refDate = (*discountCurve_)->referenceDate(); Date settlementDate = settlementDate_; if (settlementDate_==Date()) { settlementDate = refDate; } else { QL_REQUIRE(settlementDate>=refDate, "settlement date (" << settlementDate << ") before " "discount curve reference date (" << refDate << ")"); } results_.valuationDate = npvDate_; if (npvDate_==Date()) { results_.valuationDate = refDate; } else { QL_REQUIRE(npvDate_>=refDate, "npv date (" << npvDate_ << ") before " "discount curve reference date (" << refDate << ")"); } ------------------------------------------------------------------------------------ Via SWIG i have one constructor available, which sets the discounting termstructure only. So the dates npvDate_ and refDate_ are initially "Date()" at the beginning of the above code. So they both default to "refDate" which is the reference date of the discounting curve. I tried to get the full constructor into the SWIG code, but until now i always had errors in the automatically created C++ wrapper code regarding the definition of optional parameters. Anyways, a little later "CashFlows::npv" is called: ------------------------------------------------------------------------------------ CashFlows::npv(arguments_.legs[i], **discountCurve_, includeRefDateFlows, settlementDate, results_.valuationDate); ------------------------------------------------------------------------------------ The default settings for the dates there are as follows: ------------------------------------------------------------------------------------ if (settlementDate == Date()) settlementDate = Settings::instance().evaluationDate(); if (npvDate == Date()) npvDate = settlementDate; Real totalNPV = 0.0; for (Size i=0; i<leg.size(); ++i) { if (!leg[i]->hasOccurred(settlementDate, includeSettlementDateFlows)) totalNPV += leg[i]->amount() * discountCurve.discount(leg[i]->date()); } return totalNPV/discountCurve.discount(npvDate); ------------------------------------------------------------------------------------ So every time i run a swap evaluation using the DiscountingSwapEngine, the Settings::evaluationDate is totally ignored, since all dates are set to the reference date of the discounting curve. That leads to really unwanted behavior, if the the curve's reference date is earlier than the Settings::evaluationDate and there are cashflows in between. Now even the cashflows placed before Settings::evaluationDate a included into the NPV. So why is the default date in DiscountingSwapEngine (*discountCurve_)->referenceDate(); and not Settings::instance().evaluationDate(); ? If this is not an error, i would appreciate any help getting the full constructor of DiscountingSwapEngine (discountCurve, includeSettlementDateFlows, settlementDate, npvDate) to work in SWIG or to evaluate a VanillaSwap without using DiscountingSwapEngine. Best regards, Henner Heck ------------------------------------------------------------------------------ Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)! Finally, a world-class log management solution at an even better price-free! Download using promo code Free_Logger_4_Dev2Dev. Offer expires February 28th, so secure your free ArcSight Logger TODAY! http://p.sf.net/sfu/arcsight-sfd2d _______________________________________________ QuantLib-dev mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-dev |
Hi Henner
> So why is the default date in DiscountingSwapEngine > (*discountCurve_)->referenceDate(); > and not > Settings::instance().evaluationDate(); ? because the discount curve reference date is tautologically the reference date to which all cashflows should be discounted. The usual usage if for discountCurve_)->referenceDate() > Settings::instance().evaluationDate(), since you might want to discount to today or some future date, not to a date into the past > So every time i run a swap evaluation using the DiscountingSwapEngine, > the Settings::evaluationDate is totally ignored, since all dates are set to > the reference date of the discounting curve. > That leads to really unwanted behavior, if the curve's reference date is > earlier > than the Settings::evaluationDate and there are cashflows in between. > Now even the cashflows placed before Settings::evaluationDate a included > into the NPV. mmm... you surely have some good point for this usage, but I must confess I don't see how the curve's reference date can be earlier than the Settings::evaluationDate > If this is not an error, i would appreciate any help getting the full > constructor of > DiscountingSwapEngine (discountCurve, includeSettlementDateFlows, > settlementDate, npvDate) > to work in SWIG or to evaluate a VanillaSwap without > using DiscountingSwapEngine. this is a legitimate request. I'm pretty sure Luigi will oblige to it. > i would like to thank the people responsible, > especially Luigi and Ferdinando, for the forum last > week in London. I enjoyed it. you're welcome ciao -- Nando ------------------------------------------------------------------------------ Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)! Finally, a world-class log management solution at an even better price-free! Download using promo code Free_Logger_4_Dev2Dev. Offer expires February 28th, so secure your free ArcSight Logger TODAY! http://p.sf.net/sfu/arcsight-sfd2d _______________________________________________ QuantLib-dev mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-dev |
On Tue, 2011-01-25 at 13:05 +0100, Ferdinando Ametrano wrote:
> > I would appreciate any help getting the full > > constructor of > > DiscountingSwapEngine (discountCurve, includeSettlementDateFlows, > > settlementDate, npvDate) > > to work in SWIG or to evaluate a VanillaSwap without > > using DiscountingSwapEngine. > > this is a legitimate request. I'm pretty sure Luigi will oblige to it. The patch is in the mail. I mean, it's attached. Also, I confess I didn't fully understand your setup; but if you want the reference date of the curve to follow the evaluation date, you can instantiate the curve by passing a number of settlement days (possibly 0) and a calendar (possibly NullCalendar) instead of a fixed settlement date. If you do so, the reference date of the curve will change when the evaluation date does. Luigi -- The first rule of intelligent tinkering is to save all the parts. -- Paul Erlich ------------------------------------------------------------------------------ Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)! Finally, a world-class log management solution at an even better price-free! Download using promo code Free_Logger_4_Dev2Dev. Offer expires February 28th, so secure your free ArcSight Logger TODAY! http://p.sf.net/sfu/arcsight-sfd2d _______________________________________________ QuantLib-dev mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-dev swap.patch (1K) Download Attachment |
Hello, @Ferdinando: Correct me if i am wrong: I make a swap contract at 26.1., the swap has a fixing offset of two days, so it actually starts at 28.1.. If i want to evaluate the swap for 28.1., i would take the newest market data i have from the 26.1. and use it to build a discount curve and forecast curve with 26.1. as reference date. I'd forecast the floating leg fixings and then use the discount curve to discount all cashflows to the 26.1. and finally discount the sum of these discounted cashflows to the 28.1.. So in the CashFlows::npv function my SettlementDate and my npvDate would be the 28.1., which is not identical with my discountcurve reference date, the 26.1.. If i interpret the official QuantLib swap example correctly, the way to do it with the DiscountingSwapEngine's constructor using only the discountCurve parameter would be to set the curve's reference date to 28.1. and thereby implicitly set SettlementDate and npvDate to the same date which introduces a slight difference by discounting to the 28.1. directly with a curve moved two days into the future. Also if wanted to forecast the value of a swap at different dates during it's life using today's market data (whether it makes sense or not :) ), the SettlementDate and npvDate would have to be different from the curve's reference date and further into the future than it. The patch gives me the freedom i needed, so at the moment everything's fine. :) @Luigi Thank you for the patch. Will it be in future official releases? The line "%feature("kwargs") DiscountingSwapEnginePtr;" is for Python compatibility, if i am correct, but it has the effect, that only the constructor with all possible parameters is available in the Java class. This of course breaks code which uses the previously available "discountCurve-only" constructor from Java. I don't mind, just wanted to bring it to attention. Best regards, Henner Heck Am 25.01.2011, 13:18 Uhr, schrieb Luigi Ballabio <[hidden email]>: > On Tue, 2011-01-25 at 13:05 +0100, Ferdinando Ametrano wrote: >> > I would appreciate any help getting the full >> > constructor of >> > DiscountingSwapEngine (discountCurve, includeSettlementDateFlows, >> > settlementDate, npvDate) >> > to work in SWIG or to evaluate a VanillaSwap without >> > using DiscountingSwapEngine. >> >> this is a legitimate request. I'm pretty sure Luigi will oblige to it. > > The patch is in the mail. I mean, it's attached. > > Also, I confess I didn't fully understand your setup; but if you want > the reference date of the curve to follow the evaluation date, you can > instantiate the curve by passing a number of settlement days (possibly > 0) and a calendar (possibly NullCalendar) instead of a fixed settlement > date. If you do so, the reference date of the curve will change when the > evaluation date does. > > Luigi > > -- Erstellt mit Operas revolutionärem E-Mail-Modul: http://www.opera.com/mail/ ------------------------------------------------------------------------------ Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)! Finally, a world-class log management solution at an even better price-free! Download using promo code Free_Logger_4_Dev2Dev. Offer expires February 28th, so secure your free ArcSight Logger TODAY! http://p.sf.net/sfu/arcsight-sfd2d _______________________________________________ QuantLib-dev mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-dev |
On Thu, 2011-01-27 at 15:26 +0100, Henner Heck wrote:
> @Luigi > Thank you for the patch. Will it be in future official releases? Yes. Not the very next one, though, because it's almost out of the door. > The line > "%feature("kwargs") DiscountingSwapEnginePtr;" > is for Python compatibility, if i am correct, but it has the effect, > that only the constructor with all possible parameters is available in > the Java class. Does it? I wasn't aware that it had any effect on languages other that Python. I'll wrap it in an #ifdef(SWIGPYTHON) then... Luigi -- Use every man after his desert, and who shall scape whipping? -- Hamlet, Act II, scene II ------------------------------------------------------------------------------ Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)! Finally, a world-class log management solution at an even better price-free! Download using promo code Free_Logger_4_Dev2Dev. Offer expires February 28th, so secure your free ArcSight Logger TODAY! http://p.sf.net/sfu/arcsight-sfd2d _______________________________________________ QuantLib-dev mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-dev |
In reply to this post by Henner Heck
Hi Henner
> [...] the SettlementDate > and npvDate would have to be different from the curve's reference date and > further into the future than it. agreed ! I didn't see how the curve's reference date could be earlier than the Settings::evaluationDate. No problem with it being earlier than SettlementDate and/or npvDate ciao -- Nando ------------------------------------------------------------------------------ Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)! Finally, a world-class log management solution at an even better price-free! Download using promo code Free_Logger_4_Dev2Dev. Offer expires February 28th, so secure your free ArcSight Logger TODAY! http://p.sf.net/sfu/arcsight-sfd2d _______________________________________________ QuantLib-dev mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-dev |
Thank you! Am 27.01.2011, 18:29 Uhr, schrieb Ferdinando Ametrano <[hidden email]>: > Hi Henner > >> [...] the SettlementDate >> and npvDate would have to be different from the curve's reference date >> and >> further into the future than it. > > agreed ! > > I didn't see how the curve's reference date could be earlier than > the Settings::evaluationDate. No problem with it being earlier than > SettlementDate and/or npvDate > > ciao -- Nando > > ------------------------------------------------------------------------------ > Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)! > Finally, a world-class log management solution at an even better > price-free! > Download using promo code Free_Logger_4_Dev2Dev. Offer expires > February 28th, so secure your free ArcSight Logger TODAY! > http://p.sf.net/sfu/arcsight-sfd2d > _______________________________________________ > QuantLib-dev mailing list > [hidden email] > https://lists.sourceforge.net/lists/listinfo/quantlib-dev -- Erstellt mit Operas revolutionärem E-Mail-Modul: http://www.opera.com/mail/ ------------------------------------------------------------------------------ Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)! Finally, a world-class log management solution at an even better price-free! Download using promo code Free_Logger_4_Dev2Dev. Offer expires February 28th, so secure your free ArcSight Logger TODAY! http://p.sf.net/sfu/arcsight-sfd2d _______________________________________________ QuantLib-dev mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-dev |
Free forum by Nabble | Edit this page |