1
$\begingroup$

I am using the "Bond" function in QuantLib-Python 1.14.

I am planning to use it in this way:

BondPtr::BondPtr(Natural,Calendar const &,Date const &,Leg const &)

I tried to construct the last parameter as ql.Leg((cf1,cf2,cf3,cf4))

where cf1=ql.SimpleCashFlow(3,ql.Date(25,1,20XX)), cf2=..., cf3=..., cf4=...

Finally, I got the error:

RuntimeError: no coupons provided

Can someone one tell me how to make it correct? Thank you a lot!

Here is my code for reference:

import QuantLib as ql cf1=ql.SimpleCashFlow(3,ql.Date(25,1,2019)) cf2=ql.SimpleCashFlow(3,ql.Date(25,1,2020)) cf3=ql.SimpleCashFlow(53,ql.Date(25,1,2021)) cf4=ql.SimpleCashFlow(51.5,ql.Date(25,1,2022)) couponsLeg=ql.Leg() couponsLeg.push_back(cf1) couponsLeg.push_back(cf2) couponsLeg.push_back(cf3) couponsLeg.push_back(cf4) newBond=ql.Bond(0,ql.UnitedStates(),ql.Date(25,1,2018),couponsLeg)

$\endgroup$
  • $\begingroup$ My purpose is to construct a bond with advanced principle payment (I have added my code for reference). I have read the C++ code, I am not clear whether I used the ql.Leg() correctly. $\endgroup$ – user38862 Feb 19 at 12:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.