Hi All, |
On 08/11/2006 10:03:17 PM, [hidden email] wrote: > A quick question regarding the SWIG wrapper for the various Binomial > vanilla pricing engines -- is the "BinomialEuropeanEngine" class name > misleading (eg: can it price European and American style options), or > was this intentional? Jeff, it's a misnomer (probably a historical one.) It's fixed in CVS now. Thanks for the heads-up. Luigi ---------------------------------------- I have made this letter longer than usual, only because I have not had the time to make it shorter. -- B. Pascal |
Hi,
For regular bond calculations (using unadjusted dates, equal coupon periods, same coupon amount paid for each period) where we have either a long first or last coupon period, the yearFraction() method of the DayCounter classes often produce the wrong values. for example, if you have a long final coupon period of 6 month frequency and the dates are Penultimate coupon date = 40441 = 20/9/2010 Maturity date = 40623 = 21/3/2011 Penultimate coupon date + 6 months = 60622 = 20/3/2011 A typical DayCounter class will have as variable values PeriodStart = 20/9/2010 PeriodEnd = 21/3/2011 refPeriodStart = 20/9/2010 refPeriodEnd = 20/3/2011 Bascially a long end period by one day. For a bond (especially for most government bonds where adjusted dates are not used), the usual way to compute the yearfraction for long periods would be to count all 6 month periods (in our case) as 0.5, and whatever is left we apply the yearFraction() function on this period. ie A = 20/9/2010 -> 20/3/2011 = 0.5 B = 20/3/2011 -> 21/3/2011 = yearFraction(20/3/2011, 21/3/2011, 20/3/2011, 20/3/2011 + 6M) TotalYearFraction = A + B. Currently, most of the DayCounter classes will return a value less than 0.5 for the same period. I'm thinking maybe a neat solution around this would be to create a templated class which would take a DayCounter as the template parameter and derive from this. When a long period is detected, it will perform the computation above, else delegate to normal operations. The nice thing about this route is that the user can create the templated object and pass it to the firstPeriodDayCount variable of the FixedRateCouponVector function(). It might be a good idea to use this same firstPeriodDayCount for a possible long/short **LAST** coupon period and thus rename the firstPeriodDayCount parameter to accuralPeriodDayCount. Thoughts... Toy out. |
Actually, thinking about it, maybe it would be better to just derive the templated class from DayCounter and then just delegate. Toy out... >From: "Toyin Akin" <[hidden email]> >To: [hidden email] >CC: [hidden email] >Subject: [Quantlib-users] Problem in bond long coupon calculations... >Date: Sun, 03 Sep 2006 04:50:09 +0100 > >Hi, > >For regular bond calculations (using unadjusted dates, equal coupon >periods, >same coupon amount paid for each period) where we have either a long first >or last coupon period, the yearFraction() method of the DayCounter classes >often produce the wrong values. > >for example, if you have a long final coupon period of 6 month frequency >and >the dates are > >Penultimate coupon date = 40441 = 20/9/2010 >Maturity date = 40623 = 21/3/2011 > >Penultimate coupon date + 6 months = 60622 = 20/3/2011 > >A typical DayCounter class will have as variable values > >PeriodStart = 20/9/2010 >PeriodEnd = 21/3/2011 > >refPeriodStart = 20/9/2010 >refPeriodEnd = 20/3/2011 > >Bascially a long end period by one day. > >For a bond (especially for most government bonds where adjusted dates are >not used), the usual way to compute the yearfraction for long periods would >be to count all 6 month periods (in our case) as 0.5, and whatever is left >we apply the yearFraction() function on this period. > >ie > >A = 20/9/2010 -> 20/3/2011 = 0.5 >B = 20/3/2011 -> 21/3/2011 = yearFraction(20/3/2011, 21/3/2011, 20/3/2011, >20/3/2011 + 6M) > >TotalYearFraction = A + B. > >Currently, most of the DayCounter classes will return a value less than 0.5 >for the same period. > >I'm thinking maybe a neat solution around this would be to create a >templated class which would take a DayCounter as the template parameter and >derive from this. When a long period is detected, it will perform the >computation above, else delegate to normal operations. The nice thing about >this route is that the user can create the templated object and pass it to >the firstPeriodDayCount variable of the FixedRateCouponVector function(). > >It might be a good idea to use this same firstPeriodDayCount for a possible >long/short **LAST** coupon period and thus rename the firstPeriodDayCount >parameter to accuralPeriodDayCount. > >Thoughts... > >Toy out. > > > >------------------------------------------------------------------------- >Using Tomcat but need to do more? Need to support web services, security? >Get stuff done quickly with pre-integrated technology to make your job >easier >Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo >http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 >_______________________________________________ >QuantLib-users mailing list >[hidden email] >https://lists.sourceforge.net/lists/listinfo/quantlib-users |
In reply to this post by Toyin Akin
Hi,
within the Bond.cpp class, the main function used for Yield-to-maturity calculation, dirtyPriceFromYield(), gives incorrect values when the Compounding type is SimpleThenCompounded. This Compounding type is useful because it corresponds to the Mossmuller Yield calculation method (as opposed to the Compounded method which corresponds to the ISMA Yield calculation). Basically, the discount() function of the InterestRate object always uses the Simple method for all periods because of the way dates are passed in (start and end dates are always equal to the frequency period). If however you fixed the start date to the settledate (instead of the lastDate variable) and then computed the discount(), then all is well. You would then have to change discount *= to discount = One other question, a query really, within the same function, you have the logic couponDate - 1*Years; Should this be couponDate - (12/frequency)*Months ? Toy out. >From: "Toyin Akin" <[hidden email]> >To: [hidden email] >CC: [hidden email] >Subject: [Quantlib-users] Problem in bond long coupon calculations... >Date: Sun, 03 Sep 2006 04:50:09 +0100 > >Hi, > >For regular bond calculations (using unadjusted dates, equal coupon >periods, >same coupon amount paid for each period) where we have either a long first >or last coupon period, the yearFraction() method of the DayCounter classes >often produce the wrong values. > >for example, if you have a long final coupon period of 6 month frequency >and >the dates are > >Penultimate coupon date = 40441 = 20/9/2010 >Maturity date = 40623 = 21/3/2011 > >Penultimate coupon date + 6 months = 60622 = 20/3/2011 > >A typical DayCounter class will have as variable values > >PeriodStart = 20/9/2010 >PeriodEnd = 21/3/2011 > >refPeriodStart = 20/9/2010 >refPeriodEnd = 20/3/2011 > >Bascially a long end period by one day. > >For a bond (especially for most government bonds where adjusted dates are >not used), the usual way to compute the yearfraction for long periods would >be to count all 6 month periods (in our case) as 0.5, and whatever is left >we apply the yearFraction() function on this period. > >ie > >A = 20/9/2010 -> 20/3/2011 = 0.5 >B = 20/3/2011 -> 21/3/2011 = yearFraction(20/3/2011, 21/3/2011, 20/3/2011, >20/3/2011 + 6M) > >TotalYearFraction = A + B. > >Currently, most of the DayCounter classes will return a value less than 0.5 >for the same period. > >I'm thinking maybe a neat solution around this would be to create a >templated class which would take a DayCounter as the template parameter and >derive from this. When a long period is detected, it will perform the >computation above, else delegate to normal operations. The nice thing about >this route is that the user can create the templated object and pass it to >the firstPeriodDayCount variable of the FixedRateCouponVector function(). > >It might be a good idea to use this same firstPeriodDayCount for a possible >long/short **LAST** coupon period and thus rename the firstPeriodDayCount >parameter to accuralPeriodDayCount. > >Thoughts... > >Toy out. > > > >------------------------------------------------------------------------- >Using Tomcat but need to do more? Need to support web services, security? >Get stuff done quickly with pre-integrated technology to make your job >easier >Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo >http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 >_______________________________________________ >QuantLib-users mailing list >[hidden email] >https://lists.sourceforge.net/lists/listinfo/quantlib-users |
In reply to this post by Toyin Akin
Hi, Possible solution (files) enclosed. Feel free to rename the class... Toy out. >From: "Toyin Akin" <[hidden email]> >To: [hidden email] >CC: [hidden email] >Subject: Re: [Quantlib-users] Problem in bond long coupon calculations... >Date: Sun, 03 Sep 2006 05:00:51 +0100 > > >Actually, thinking about it, maybe it would be better to just derive the >templated class from DayCounter and then just delegate. > >Toy out... > > >From: "Toyin Akin" <[hidden email]> > >To: [hidden email] > >CC: [hidden email] > >Subject: [Quantlib-users] Problem in bond long coupon calculations... > >Date: Sun, 03 Sep 2006 04:50:09 +0100 > > > >Hi, > > > >For regular bond calculations (using unadjusted dates, equal coupon > >periods, > >same coupon amount paid for each period) where we have either a long >first > >or last coupon period, the yearFraction() method of the DayCounter >classes > >often produce the wrong values. > > > >for example, if you have a long final coupon period of 6 month frequency > >and > >the dates are > > > >Penultimate coupon date = 40441 = 20/9/2010 > >Maturity date = 40623 = 21/3/2011 > > > >Penultimate coupon date + 6 months = 60622 = 20/3/2011 > > > >A typical DayCounter class will have as variable values > > > >PeriodStart = 20/9/2010 > >PeriodEnd = 21/3/2011 > > > >refPeriodStart = 20/9/2010 > >refPeriodEnd = 20/3/2011 > > > >Bascially a long end period by one day. > > > >For a bond (especially for most government bonds where adjusted dates are > >not used), the usual way to compute the yearfraction for long periods >would > >be to count all 6 month periods (in our case) as 0.5, and whatever is >left > >we apply the yearFraction() function on this period. > > > >ie > > > >A = 20/9/2010 -> 20/3/2011 = 0.5 > >B = 20/3/2011 -> 21/3/2011 = yearFraction(20/3/2011, 21/3/2011, >20/3/2011, > >20/3/2011 + 6M) > > > >TotalYearFraction = A + B. > > > >Currently, most of the DayCounter classes will return a value less than >0.5 > >for the same period. > > > >I'm thinking maybe a neat solution around this would be to create a > >templated class which would take a DayCounter as the template parameter >and > >derive from this. When a long period is detected, it will perform the > >computation above, else delegate to normal operations. The nice thing >about > >this route is that the user can create the templated object and pass it >to > >the firstPeriodDayCount variable of the FixedRateCouponVector function(). > > > >It might be a good idea to use this same firstPeriodDayCount for a >possible > >long/short **LAST** coupon period and thus rename the firstPeriodDayCount > >parameter to accuralPeriodDayCount. > > > >Thoughts... > > > >Toy out. > > > > > > > >------------------------------------------------------------------------- > >Using Tomcat but need to do more? Need to support web services, security? > >Get stuff done quickly with pre-integrated technology to make your job > >easier > >Download IBM WebSphere Application Server v.1.0.1 based on Apache >Geronimo > >http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 > >_______________________________________________ > >QuantLib-users mailing list > >[hidden email] > >https://lists.sourceforge.net/lists/listinfo/quantlib-users > > > >------------------------------------------------------------------------- >Using Tomcat but need to do more? Need to support web services, security? >Get stuff done quickly with pre-integrated technology to make your job >easier >Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo >http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 >_______________________________________________ >QuantLib-users mailing list >[hidden email] >https://lists.sourceforge.net/lists/listinfo/quantlib-users |
In reply to this post by Toyin Akin
Hi again, The suggestion that I previously described may intorduce errors in the sense that the wrong time period may be computed due to adjusted dates. I recommend instead to accumulate a time variable inside the dirtyPriceFromYield() function (via the yearFraction() function) and use this variable within the discount() function (via the overloaded Time version of the function). Toy out. >From: "Toyin Akin" <[hidden email]> >To: [hidden email] >CC: [hidden email] >Subject: [Quantlib-users] Bug in dirtyPriceFromYield() function... >Date: Sun, 03 Sep 2006 05:14:06 +0100 > >Hi, > >within the Bond.cpp class, the main function used for Yield-to-maturity >calculation, dirtyPriceFromYield(), gives incorrect values when the >Compounding type is SimpleThenCompounded. > >This Compounding type is useful because it corresponds to the Mossmuller >Yield calculation method (as opposed to the Compounded method which >corresponds to the ISMA Yield calculation). > >Basically, the discount() function of the InterestRate object always uses >the Simple method for all periods because of the way dates are passed in >(start and end dates are always equal to the frequency period). > >If however you fixed the start date to the settledate (instead of the >lastDate variable) and then computed the discount(), then all is well. You >would then have to change > >discount *= > >to > >discount = > >One other question, a query really, within the same function, you have the >logic > >couponDate - 1*Years; > >Should this be > >couponDate - (12/frequency)*Months ? > >Toy out. > > >From: "Toyin Akin" <[hidden email]> > >To: [hidden email] > >CC: [hidden email] > >Subject: [Quantlib-users] Problem in bond long coupon calculations... > >Date: Sun, 03 Sep 2006 04:50:09 +0100 > > > >Hi, > > > >For regular bond calculations (using unadjusted dates, equal coupon > >periods, > >same coupon amount paid for each period) where we have either a long >first > >or last coupon period, the yearFraction() method of the DayCounter >classes > >often produce the wrong values. > > > >for example, if you have a long final coupon period of 6 month frequency > >and > >the dates are > > > >Penultimate coupon date = 40441 = 20/9/2010 > >Maturity date = 40623 = 21/3/2011 > > > >Penultimate coupon date + 6 months = 60622 = 20/3/2011 > > > >A typical DayCounter class will have as variable values > > > >PeriodStart = 20/9/2010 > >PeriodEnd = 21/3/2011 > > > >refPeriodStart = 20/9/2010 > >refPeriodEnd = 20/3/2011 > > > >Bascially a long end period by one day. > > > >For a bond (especially for most government bonds where adjusted dates are > >not used), the usual way to compute the yearfraction for long periods >would > >be to count all 6 month periods (in our case) as 0.5, and whatever is >left > >we apply the yearFraction() function on this period. > > > >ie > > > >A = 20/9/2010 -> 20/3/2011 = 0.5 > >B = 20/3/2011 -> 21/3/2011 = yearFraction(20/3/2011, 21/3/2011, >20/3/2011, > >20/3/2011 + 6M) > > > >TotalYearFraction = A + B. > > > >Currently, most of the DayCounter classes will return a value less than >0.5 > >for the same period. > > > >I'm thinking maybe a neat solution around this would be to create a > >templated class which would take a DayCounter as the template parameter >and > >derive from this. When a long period is detected, it will perform the > >computation above, else delegate to normal operations. The nice thing >about > >this route is that the user can create the templated object and pass it >to > >the firstPeriodDayCount variable of the FixedRateCouponVector function(). > > > >It might be a good idea to use this same firstPeriodDayCount for a >possible > >long/short **LAST** coupon period and thus rename the firstPeriodDayCount > >parameter to accuralPeriodDayCount. > > > >Thoughts... > > > >Toy out. > > > > > > > >------------------------------------------------------------------------- > >Using Tomcat but need to do more? Need to support web services, security? > >Get stuff done quickly with pre-integrated technology to make your job > >easier > >Download IBM WebSphere Application Server v.1.0.1 based on Apache >Geronimo > >http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 > >_______________________________________________ > >QuantLib-users mailing list > >[hidden email] > >https://lists.sourceforge.net/lists/listinfo/quantlib-users > > > >------------------------------------------------------------------------- >Using Tomcat but need to do more? Need to support web services, security? >Get stuff done quickly with pre-integrated technology to make your job >easier >Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo >http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 >_______________________________________________ >QuantLib-users mailing list >[hidden email] >https://lists.sourceforge.net/lists/listinfo/quantlib-users |
Free forum by Nabble | Edit this page |