Need some help on following items regarding functions in Qunatlib:

  1. Is there any function available to calculate time between two dates with specific day count convention. For Example, I want to know time between D1 and D2 using 30/360, Act/360, etc day count convention.
  2. Can we know previous and next coupon dates for bonds on particular date using schedule or some other function in Quantlib. I see schedule provides all cash flow dates but need something which gives previous and next cash flow dates.

1 Answer 1

  1. Yes. You can write, for instance, Actual360().yearFraction(d1,d2). Look for the DayCounter class at http://quantlib.org/reference for docs and the list of the supported day-count conventions.

  2. You can use the CashFlows::previousCashFlowDate and CashFlows::nextCashFlowDate methods. Again, see the link above for details.

  • $\begingroup$ How can 2 be implemented in python? Sorry but weak with that conversion. $\endgroup$
    – BHr
    Commented Feb 8, 2018 at 10:37
  • $\begingroup$ Sorry, those methods are not exported to Python. You can request them by opening an issue at github.com/lballabio/QuantLib-SWIG/issues. $\endgroup$ Commented Feb 8, 2018 at 14:11
  • $\begingroup$ Thanks for your response...created github.com/lballabio/QuantLib-SWIG/issues/100 $\endgroup$
    – BHr
    Commented Feb 8, 2018 at 15:45
  • $\begingroup$ On closer look there is one more variant of above functions qlSchedulePreviousDate and qlScheduleNextDate. I guess these methods are also not exported to Python? $\endgroup$
    – BHr
    Commented Feb 8, 2018 at 15:50
  • $\begingroup$ Right. You can add them to the issue. $\endgroup$ Commented Feb 9, 2018 at 8:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.