Login  Register

R: CPIBond/ZeroInflationIndex issue (fixings persisted)

Posted by Ballabio Gerardo-4 on Aug 07, 2014; 8:30am
URL: http://quantlib.414.s1.nabble.com/CPIBond-ZeroInflationIndex-issue-fixings-persisted-tp15674p15694.html

If I'm not mistaken, the way indices are implemented in QuantLib (all indices, not just inflation indices), if you create two identical indices, they are actually pointers to the same data structure, i.e., they share values. So when you create the first one, it's empty; when you create the second one, it already contains all the fixings that you have set into the first, because they are really the same.
I don't know why it was done that way, but I suppose it was for a good reason. If the people who did it are reading this, they may explain please?

Gerardo Ballabio
Risk Management

Banca Profilo S.p.A.
Via Cerva 28 - 20122 Milano
Tel. +39 02 58408.463
www.bancaprofilo.it




-----Messaggio originale-----
Da: smazzucca [mailto:[hidden email]]
Inviato: martedì 5 agosto 2014 16.19
A: [hidden email]
Oggetto: [Quantlib-users] CPIBond/ZeroInflationIndex issue (fixings persisted)

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
<http://quantlib.10058.n7.nabble.com/file/n15674/CreateIndexLinkedBond.cs>  

Thank you,
Simon



--
View this message in context: http://quantlib.10058.n7.nabble.com/CPIBond-ZeroInflationIndex-issue-fixings-persisted-tp15674.html
Sent from the quantlib-users mailing list archive at Nabble.com.

------------------------------------------------------------------------------
Infragistics Professional
Build stunning WinForms apps today!
Reboot your WinForms applications with our WinForms controls.
Build a bridge from your legacy apps to the future.
http://pubads.g.doubleclick.net/gampad/clk?id=153845071&iu=/4140/ostg.clktrk
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head></head>
<body>
<div style="font-family:Calibri;font-size:10px">
Banca Profilo S.p.A.
Via Cerva, 28 - 20122 Milano - Tel. 02 58408.1, Fax 02 5831 6057
Capitale Sociale Euro 136.848.321,00 i.v.
Iscrizione al Registro Imprese di Milano, C.F. e P.IVA 09108700155 - [hidden email]
Iscritta all’Albo delle Banche e dei Gruppi bancari
Aderente al Fondo Interbancario di Tutela dei depositi
Aderente al Conciliatore Bancario Finanziario e all’Arbitro Bancario Finanziario
Appartenente al Gruppo bancario Banca Profilo e soggetta all’attività di direzione e coordinamento di Arepo BP S.p.A.


DISCLAIMER:
The information transmitted may contain confidential and/or privileged material.
Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon,
this information by persons or entities other than the intended recipient is prohibited.
If you received this in error, please contact the sender and delete the material from any computer.
</div>
</body>
</html>


------------------------------------------------------------------------------
Infragistics Professional
Build stunning WinForms apps today!
Reboot your WinForms applications with our WinForms controls.
Build a bridge from your legacy apps to the future.
http://pubads.g.doubleclick.net/gampad/clk?id=153845071&iu=/4140/ostg.clktrk
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users