Login  Register

CPIBond/ZeroInflationIndex issue (fixings persisted)

Posted by smazzucca on Aug 05, 2014; 2:19pm
URL: http://quantlib.414.s1.nabble.com/CPIBond-ZeroInflationIndex-issue-fixings-persisted-tp15674.html

When creating a ZeroInflationIndex in order to create a CPIBond, it appears the object created comes with data already in memory.

If you look at line 1 (below), inflationIndex is created anew.
The first time this code is executed there is no problem, but the second time line 8 throws this exception:
Exception: System.ApplicationException: At least one duplicated fixing provided: April 30th, 2014, 236.293 while 237.099 value is already present


1. ZeroInflationIndex inflationIndex = new USCPI(interpolated, cpiTS);
2. int monthdiff = ScenarioDate.month() - BusinessDate.month();
3. Period testperiod = new Period(monthdiff, TimeUnit.Months);
4. foreach (KeyValuePair<DateTime, double> indexValue in InflationIndexValues)
5. {
6. Date inputdate = indexValue.Key.ToDate();
7. Date adjusteddate = inputdate.Add(testperiod);
8. inflationIndex.addFixing(adjusteddate, indexValue.Value);
9. }

It appears that fixing was already part of the object. But how is it possible ? Since it was just created it should be empty.

I would manually clear the fixings as a workaround, but I don't see a way to do that.

I wonder if this is related to the Pure Virtual Function Call patch. See:
http://quantlib.10058.n7.nabble.com/pure-virtual-function-call-td15342.html

(Full method attached)
CreateIndexLinkedBond.cs

Thank you,
Simon