Situation: I would like to make a small script which prices loans (fe annuities or fixed payment) for the ALM purposes. However, I am stuck in the amount of classes existing in Quantlib and would like to understand how to do it properly.
Say I have a simple loan with calendar and fixed interest, which yields monthly principal and interest payments. All of them are trivially calculated using school maths, and making such a calendar is also very easy in pandas. I wrote additional custom class for yield curve to get discounts, so my pandas output looks like this:
However, I want to use Quantlib functionality. As far as I understand, there is no built-in loan or mortgage class. The "Bond" class is not applicable for the case. I tried to use FixedRateLeg class for the stream of the principal repayments:
leg = FixedRateLeg(schedule, dayCount, [nominal], [rate])
but it also didn't work due to daycount issues.
So, the question is:
- What built-in class am I supposed to use for such a cashflow stream? I am fine with calculating the required values of payments by myself and providing
zip(Schedule, Payments)
, but if there is a class that calculates such payments by itself, it is also great. - Given such class, how do I merge it with a yield curve to obtain discounts and npv? Assume I already have a
yc = ZeroCurve(*args)
. - Is there a way to perform such calculation with a floating interest rate (apart of merging pre-calculated schedule and payments like in 1)?