Search code examples
quantlib

Failed to create a SwapRateHelper with frequency ql.NoFrequency


I'd like to create a SwapRateHelper for a swap that pays fixed leg interest at maturity. I tried ql.NoFrequency, but it gives me "unknown fixed leg default tenor" error. Some swap pays interest at maturity for tenor less than 1Y. Here is the sample code to reproduce the issue. Note, I am using MXN as a made-up example, even though MXN has a 4W frequency in realty.

import QuantLib as ql

tiie_index =  ql.IborIndex('TIIE', ql.Period('4W') , 1, ql.MXNCurrency(), ql.NullCalendar(), ql.Following, False, ql.Actual360())

rate = 0.02

tenor = ql.Period('4W')

frequency = ql.NoFrequency  # This will cause failure. What should I set for at-maturity type swap?

bdays_adj = ql.Following

day_count = ql.Actual360()

h = ql.SwapRateHelper(ql.QuoteHandle(ql.SimpleQuote(rate)), tenor, ql.Mexico(), frequency, bdays_adj, day_count, tiie_index)

Solution

  • The correct frequency for a single payment should be ql.Once, but unfortunately this doesn't work either; you might want to open an issue on GitHub for that.

    In the meantime, a workaround is to pass ql.Annual as frequency. The schedule will try to generate dates one year apart, but since there are only 4 weeks (or whatever the period is) between the start and end date it will keep those two and add no other dates in between.