2
$\begingroup$

I am trying to value inflation swaps using necessary functions from quantlib and successfully completed the valuation. Underneath helper function is working well for most of the swaps. But few swaps giving me below error. RuntimeError: more than one instrument with pillar May 17th, 2021.

helpers = []
for idx, row in rate_data.iterrows():
    rate = row["mid_yield"] / 100
    tenor = row.tenor
    if tenor == "1D":
        helpers.append(ql.DepositRateHelper(rate, index))
    else:
        helpers.append(
            ql.OISRateHelper(
                0, ql.Period(tenor), ql.QuoteHandle(ql.SimpleQuote(rate)), index
            )
        )

I know the maturity dates from 'helper' is colliding with the maturity dates of rates. I just want to know how to print the variables/dates/pillars from 'helpers' in python to see the dates. Thereafter I can do further analysis based on constructed helpers maturity dates.

$\endgroup$

1 Answer 1

4
$\begingroup$

You can see at the beginning of this file the methods exported by all helpers. For the pillar dates, you can write

for h in helpers:
    print(h.pillarDate())
$\endgroup$
5
  • $\begingroup$ Ballaio Thanks for your reply. This is super helpful. Is there any link where I can refer more helpers attributes to print like you just did h.pillarDate(). $\endgroup$
    – robin
    Commented Dec 3, 2021 at 15:58
  • $\begingroup$ @ Luigi Ballabio I have one more question. Can we also convert helper pillar dates into unique pillar dates. In this way, I can eliminate duplicate pillar dates in helper. $\endgroup$
    – robin
    Commented Dec 3, 2021 at 18:18
  • $\begingroup$ You can find more info at quantlib-python-docs.readthedocs.io or in the code itself at github.com/lballabio/QuantLib-SWIG/tree/master/SWIG . $\endgroup$ Commented Dec 3, 2021 at 19:05
  • $\begingroup$ I'm not sure what you mean with "convert into unique dates"? There's no conversion — if you have two instruments maturing on the same date, you'll have to choose one and discard the other. $\endgroup$ Commented Dec 3, 2021 at 19:06
  • $\begingroup$ Thanks for your reply. It was very helpful. $\endgroup$
    – robin
    Commented Dec 8, 2021 at 21:44

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.