Overwriting Historical Fixings in QuantLib-Python
Summary
The document describes a QuantLib-Python issue encountered when changing a historical fixing that has already been added to a floating-rate index. Adding the same date again raises a duplicate-fixing error. Although the underlying API has a force-overwrite option, the questioner reports that their Python method does not accept it as a keyword argument.
The accepted answer explains that the option was not exposed in the then-current Python release and was expected in a subsequent release. It also notes a wrapper limitation: once available, the option may need to be passed positionally rather than by keyword. The example concerns changing a past fixing used for a floating bond coupon. This is version-dependent API guidance; the document gives no current-version check or broader discussion of correcting historical data, so users need to confirm the binding behavior in their installed release.
Key ideas
- Adding a second fixing for the same date triggers a duplicate-fixing error.
- The accepted answer says the overwrite parameter was not exposed in the Python release discussed.
- After exposure, the SWIG wrapper may require passing the overwrite flag positionally.
- The guidance concerns changing a past index fixing and depends on the QuantLib-Python version.
Tags
Full text
# how to change the value set by the addFixing method in QuantLib # how to change the value set by the addFixing method in QuantLib Suppose we have had constructed an index for forecasting future interests of a floating bond, and as suggested by the official document, I used addFixing method to set a past fixing for the current coupon. What I confused was when I reset the addFixing value the program returned an error which says "At least one duplicated fixing provided: ..." . To solve this problem, I backed to check the source code and api doc, and found that there is a parameter called forceOverwrite which seems to be what I need, but when I changed the default value to True, the program told me that "addFixing() got an unexpected keyword argument 'forceOverwrite'". So, is it a bug in QuantLib-Python? If not, what should I do to change the value after having calling addFixing once. Thanks! ``` flat_forward = FlatForward(Date(8, 5, 2017), 0.04, Actual360(), Compounded, Quarterly) term_structure = RelinkableYieldTermStructureHandle(flat_forward) index = USDLibor(Period(3, Months), term_structure) index.addFixing(Date(24, 3, 2017), 0.03) # how to change 0.03 to 0.05 ``` ## Answer by Luigi Ballabio (score 1, accepted) https://quant.stackexchange.com/a/41554 The parameter is not exposed to Python in the current release. It will in the next (see https://github.com/lballabio/QuantLib-SWIG/pull/125, which was merged in the master branch one month ago). If you don't want to wait, you can check out the latest version of the code from GitHub. A note: the parameter will be exposed, but due to the machinery used by SWIG to generate wrappers you probably won't be able to pass it as a keyword argument. Instead of `forceOverwrite=True`, just pass `True`.
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.