Skip to content
All library documents

Supplying a CDOR Index and Spread to QuantLib’s Swap Rate Helper

Article Quant Q&A · Author: Arron Tran

Summary

The document addresses a constructor error encountered while setting up swap rate helpers for a Canadian-dollar rate curve. The example passes the CDOR class where the helper expects an index object, and omits a required spread argument when supplying later optional parameters.

The answer explains that the index should be instantiated and that the spread must be provided as a quote handle, even when the spread is zero. This is a narrow API troubleshooting note rather than a guide to building a volatility cube or calibrating a curve. It gives no worked output or broader discussion of market conventions, so readers still need to check the helper’s applicable signature and ensure their instrument inputs match their data.

Key ideas

  • QuantLib expects an instantiated CDOR index, rather than the index class, as the helper argument.
  • A spread quote handle is required when passing the subsequent helper parameters, even for a zero spread.
  • The constructor error arises from argument types and ordering, not from the volatility cube calibration itself.

Tags

Full text
# Quantlib: how to construct CDOR volatility cube? Getting error when using SwapRateHelper


# Quantlib: how to construct CDOR volatility cube? Getting error when using SwapRateHelper












```
import QuantLib as ql
import pandas as pd

today = ql.Date().todaysDate()
calendar = ql.Canada()

# Load the CDOR swap rates data into a pandas DataFrame
cdor_data = pd.read_csv('cdor_swap_rates.csv')

# Convert the data into QuantLib objects
cdor_curve = ql.RelinkableYieldTermStructureHandle()
cdor_helpers = []
for i, row in cdor_data.iterrows():
    tenor = ql.Period(row['Term'])
    rate = row['Rate'] / 100.0
    helper = ql.SwapRateHelper(rate, tenor, calendar,
                               ql.Annual, ql.Unadjusted,
                               ql.Thirty360(ql.Thirty360.BondBasis), ql.Cdor, ql.Period('1D'),
                               cdor_curve)
    cdor_helpers.append(helper)
```

Hey guys, I can't figure out why my SwapRateHelper function is not working, throwing a TypeError: Wrong number or type of arguments for overloaded function 'new_SwapRateHelper'.

## Answer by Luigi Ballabio (score 2)

https://quant.stackexchange.com/a/75357

Looking at the declaration of the constructor you're using (https://github.com/lballabio/QuantLib-SWIG/blob/master/SWIG/ratehelpers.i#L236) I see two reasons:

- you're passing `ql.Cdor` which is the name of the class. You need to pass `ql.Cdor()` which is an instance of the index.

- after the index, the next parameter is a `QuoteHandle` containing the spread. Even if the spread is 0, that's needed if you're passing the other parameters after this one.

Shown in full with attribution under the source's licence. Licence: CC BY-SA 4.0 (Stack Exchange)

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.