Hi, I noticed some strange behavior with the bond FixedCouponBond
class. When outputing the cashflows, the first coupon is wrong. Here is my simple python code that demonstrate the problem. Thanks a lot for your attention! from QuantLib import * calendar = UnitedStates() settlementDays = 1 issue = Date(15,11,2005) d1 = Date(1,12,2005) mat = Date(15,11, 2010) coupon = [1, 0.1] bond = FixedCouponBond(issue, d1, mat, settlementDays, coupon, Annual, Thirty360(), calendar) flows = bond.cashflows() for item in flows: print item.date(), item.amount() output: November 15th, 2006 95.5555555556 November 15th, 2007 10.0 November 17th, 2008 10.0555555556 November 16th, 2009 9.97222222222 November 15th, 2010 9.97222222222 |
On 1/12/06, [hidden email] <[hidden email]> wrote:
> Hi, I noticed some strange behavior with the bond FixedCouponBond > class. When outputing the cashflows, the first coupon is wrong. > Here is my simple python code that demonstrate the problem. Thanks a lot > for your attention! > > from QuantLib import * > > calendar = UnitedStates() > settlementDays = 1 > issue = Date(15,11,2005) > d1 = Date(1,12,2005) > mat = Date(15,11, 2010) > coupon = [1, 0.1] > bond = FixedCouponBond(issue, d1, mat, settlementDays, coupon, Annual, > Thirty360(), calendar) > flows = bond.cashflows() > for item in flows: > print item.date(), item.amount() > > output: > > November 15th, 2006 95.5555555556 > November 15th, 2007 10.0 > November 17th, 2008 10.0555555556 > November 16th, 2009 9.97222222222 > November 15th, 2010 9.97222222222 In what sense is wrong? If you're referring to the large amount, it's because you defined the coupons as: > coupon = [1, 0.1] which means that the first coupon is 100% and the following are 10%. If it's referring to dates or day counts, it might be some convention to set. what did you expect? Later, Luigi |
In reply to this post by laotze00
Hi all,
Are there any known bugs with MSVC6 when implementing PiecewiseYieldCurve? I can not compile my basic sample code, can you provide an example? I think a have a trouble with function template arguments. Thanks a lot. template <class T, class I> void testYieldCurve (const T&, const I& interpolator) { ... .. . boost::shared_ptr<YieldTermStructure> termStructure; termStructure = boost::shared_ptr<YieldTermStructure>( new PiecewiseYieldCurve<T,I>(Settlement,bondHelpers, Actual360(), 1.0e-12, LogLinear())); Handle<YieldTermStructure> ts; ts.linkTo(termStructure); . .. ... } int main(int, char* []) { testYieldCurve(ZeroYield(), LogLinear()); return 0; } C:\works\SXL\SXLL\QL_TEST\src\main.cpp(142) : error C2061: syntax error : identifier 'PiecewiseYieldCurve' C:\works\SXL\SXLL\QL_TEST\src\main.cpp(166) : see reference to function template instantiation 'void __cdecl testYieldCurve (const struct QuantLib::ZeroYield &,const class QuantLib::LogLinear &)' being compiled |
On 1/13/06, sercan atalik <[hidden email]> wrote:
> Are there any known bugs with MSVC6 when implementing PiecewiseYieldCurve? Yes---it doesn't compile. VC6 cannot handle it as it is, and I didn't have time to try and find an alternate implementation. The whole thing is #defined out when using VC6. Sorry, Luigi |
In reply to this post by Luigi Ballabio
Thank for pointing that out. I might misunderstood the convention
here. I was just following the example in /QuantLib/test-suite/bonds.cpp: FixedCouponBond bond(issue, dated, maturity, settlementDays, std::vector<Rate>(1, coupons[k]), frequencies[l], bondDayCount, calendar, convention, redemption); How would I set the convention if I want it to refer to the "1" to refer to dates? Thanks a lot! On 1/13/06, Luigi Ballabio <[hidden email]> wrote: > On 1/12/06, [hidden email] <[hidden email]> wrote: > > Hi, I noticed some strange behavior with the bond FixedCouponBond > > class. When outputing the cashflows, the first coupon is wrong. > > Here is my simple python code that demonstrate the problem. Thanks a lot > > for your attention! > > > > from QuantLib import * > > > > calendar = UnitedStates() > > settlementDays = 1 > > issue = Date(15,11,2005) > > d1 = Date(1,12,2005) > > mat = Date(15,11, 2010) > > coupon = [1, 0.1] > > bond = FixedCouponBond(issue, d1, mat, settlementDays, coupon, Annual, > > Thirty360(), calendar) > > flows = bond.cashflows() > > for item in flows: > > print item.date(), item.amount() > > > > output: > > > > November 15th, 2006 95.5555555556 > > November 15th, 2007 10.0 > > November 17th, 2008 10.0555555556 > > November 16th, 2009 9.97222222222 > > November 15th, 2010 9.97222222222 > > In what sense is wrong? If you're referring to the large amount, it's > because you defined the coupons as: > > > coupon = [1, 0.1] > > which means that the first coupon is 100% and the following are 10%. > If it's referring to dates or day counts, it might be some convention > to set. what did you expect? > > Later, > Luigi > |
On 1/13/06, [hidden email] <[hidden email]> wrote:
> Thank for pointing that out. I might misunderstood the convention > here. I was just following the example in > /QuantLib/test-suite/bonds.cpp: > > FixedCouponBond bond(issue, dated, maturity, settlementDays, > std::vector<Rate>(1, coupons[k]), > frequencies[l], bondDayCount, > calendar, convention, redemption); Oh, I see. In the std::vector constructor that would be the number of elements, but in Python it is not required---to build a list, one just enumerates its elements. For a bond paying 10%, you can just write coupon = [0.1] or if you want coupons with different rates, coupon = [0.1, 0.08, 0.04] Luigi |
In reply to this post by Luigi Ballabio
Its bad, I tried with VC80 Express edition, its fine. The problem is with
MSV6. Have you got any suggestion about that, I want to solve that, ill-fated banks are usually using VS6. -----Original Message----- From: Luigi Ballabio [mailto:[hidden email]] Sent: 13 January 2006 10:24 To: [hidden email] Cc: [hidden email] Subject: Re: [Quantlib-users] implementing PiecewiseYieldCurve via MSVC6 On 1/13/06, sercan atalik <[hidden email]> wrote: > Are there any known bugs with MSVC6 when implementing PiecewiseYieldCurve? Yes---it doesn't compile. VC6 cannot handle it as it is, and I didn't have time to try and find an alternate implementation. The whole thing is #defined out when using VC6. Sorry, Luigi |
Free forum by Nabble | Edit this page |