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 |
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 |
Hello,
it's almost as you say. Different instances of a same index are different objects, but contain pointers a single place storing fixings. In the most common use case this turns out ok; once you establish, for instance, the inflation fixing for last month or the Euribor fixing for today, you set it in one place and it becomes available everywhere. Normally that's what you want: it's market data, not some figure that might be dependent on your model. Of course this can become a hindrance in the less frequent scenario in which you want to do some kind of simulation or test. In that case: 1) if you're running the test alongside real calculations, consider creating a new index; otherwise, your test fixings would affect all calculations. To create a new index, you can use the base class (for instance, ZeroInflationIndex instead of USCPI, or IborIndex instead of Euribor6M) and pass a new family name that you just made up. 2) once you have your test index: in C++, you can write index.addFixing(date, value, true); to force overriding of the existing fixings. In the interfaces exported through SWIG, this is not yet possible (but you can add the forceOverwrite parameter and send me a pull request) so you'll have to clean up the whole history. In C++, you would do it as: IndexManager::instance().clearHistory(index->name()); You can do the same in other languages once you translate the :: and -> into their equivalent. Luigi On Thu, Aug 7, 2014 at 10:30 AM, Ballabio Gerardo <[hidden email]> wrote: > 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 -- <https://implementingquantlib.blogspot.com> <https://twitter.com/lballabio> ------------------------------------------------------------------------------ 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 |
Luigi/Gerardo,
Thanks for the answers. I still don't understand why QL would not dispose the object since the method variable goes out of scope in between first and second use. That seems like a bug. I will spend some time thinking about how to do the override, but is'n there a simpler method like: 1) Removing all fixings 2) Checking if a fixing already exists Thank again, Simon |
The object is disposed of, but the fixings are shared and persist.
On Thu, Aug 7, 2014 at 3:59 PM, smazzucca <[hidden email]> wrote: > Luigi/Gerardo, > > Thanks for the answers. I still don't understand why QL would not dispose > the object since the method variable goes out of scope in between first and > second use. That seems like a bug. > > I will spend some time thinking about how to do the override, but is'n there > a simpler method like: > > 1) Removing all fixings > 2) Checking if a fixing already exists > > Thank again, > Simon > > > > > > -- > View this message in context: http://quantlib.10058.n7.nabble.com/CPIBond-ZeroInflationIndex-issue-fixings-persisted-tp15674p15710.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 -- <https://implementingquantlib.blogspot.com> <https://twitter.com/lballabio> ------------------------------------------------------------------------------ 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 |
So, no way to remove/check?
My only way is to find a way to do the override, right ? |
You can remove the whole set (see the IndexManager thing in one of my
previous posts). It's also possible to check, but cumbersome (you have to ask the IndexManager for the whole history and look for the fixing in it). If you export the extra parameter to SWIG, overriding is way easier. Luigi On Thu, Aug 7, 2014 at 4:30 PM, smazzucca <[hidden email]> wrote: > So, no way to remove/check? > My only way is to find a way to do the override, right ? > > > > -- > View this message in context: http://quantlib.10058.n7.nabble.com/CPIBond-ZeroInflationIndex-issue-fixings-persisted-tp15674p15713.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 -- <https://implementingquantlib.blogspot.com> <https://twitter.com/lballabio> ------------------------------------------------------------------------------ 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 |
Free forum by Nabble | Edit this page |