Login  Register

How to serialize an object in Quantlibxl?

Posted by cheng li on Aug 09, 2012; 11:04am
URL: http://quantlib.414.s1.nabble.com/How-to-serialize-an-object-in-Quantlibxl-tp763.html

Hi All,

 

I am using Quantlibxl to build our own yield curves. Now I am facing one problem. I do succeed in building the curve use qlPiecewiseYieldCurve. Then I want to save that curve to my local driver for future use. I looked into the function categories of Quantlibxl and found that function ohObjectSave may meet my purpose. Unfortunately after I serialized the yield curve to my own folder successfully, I was not able to deserialize that file by ohObjectLoad/ ohObjectLoadString, my sample input is as follows, I am using Quantlibxl 1.1.0 and Office 2010

 

Serialization: ohObjectSave(“CNY_Treasury_Curve_2008-1-2”, “F:\data\Curve\StandaloneCurves\CNY_Treasury_Curve_2008-1-2.xml”, TRUE)

Deserialization: ohObjectLoadString(“F:\data\Curve\StandaloneCurves\CNY_Treasury_Curve_2008-1-2.xml”, TRUE)

 

Besides, another question, the outputted .xml file seems no enough information to reconstruct a curve. It only contains the parameters which are used to construct that object, one sample file are as follows: the file contains the object names of the rate helpers without the detail info on the rate helpers.

 

<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>

<!DOCTYPE boost_serialization>

<boost_serialization signature="serialization::archive" version="8">

<object_list class_id="1" tracking_level="1" version="0" object_id="_0">

         <count>1</count>

         <item_version>1</item_version>

         <item class_id="0" tracking_level="0" version="1">

                   <px class_id="140" tracking_level="1" version="0" object_id="_1">

                            <ObjectId>CNY_Treasury_Curve_2008-1-2</ObjectId>

                            <ClassName>qlPiecewiseYieldCurve</ClassName>

                            <NDays>0</NDays>

                            <Calendar>China</Calendar>

                            <RateHelpers class_id="236" tracking_level="0" version="0">

                                     <count>21</count>

                                     <item_version>0</item_version>

                                     <item>060001.IB_.0251_2006-3-8_2013-2-27_7Y_helper</item>

                                     <item>060003.IB_.028_2006-4-5_2016-3-27_10Y_helper</item>

                                     <item>060019.IB_.0327_2006-11-23_2021-11-15_15Y_helper</item>

                                     <item>0700002.IB_.0468_2007-9-27_2022-9-18_15Y_helper</item>

                                     <item>0700004.IB_.0455_2007-10-12_2022-9-29_15Y_helper</item>

                                     <item>0700006.IB_.0469_2007-11-26_2022-11-19_15Y_helper</item>

                                     <item>0700008.IB_.0441_2007-12-24_2017-12-17_10Y_helper</item>

                                     <item>070014.IB_.039_2007-8-31_2014-8-23_7Y_helper</item>

                                     <item>070017.IB_.04_2007-10-29_2012-10-22_5Y_helper</item>

                                     <item>070018.IB_.0435_2007-12-5_2014-11-26_7Y_helper</item>

                                     <item>070002.IB_.021_2007-3-22_2008-3-15_1Y_helper</item>

                                     <item>070016.IB_.0295_2007-9-20_2008-9-13_1Y_helper</item>

                                     <item>070020.IB_.0366_2007-12-19_2008-12-13_1Y_helper</item>

                                     <item>040003.IB_.0442_2004-4-30_2009-4-20_5Y_helper</item>

                                     <item>9902.IB_.0472_1999-5-19_2009-4-29_10Y_helper</item>

                                     <item>030001.IB_.0266_2003-2-26_2010-2-19_7Y_helper</item>

                                     <item>030007.IB_.0266_2003-9-1_2010-8-20_7Y_helper</item>

                                     <item>060018.IB_.0248_2006-11-3_2011-10-25_5Y_helper</item>

                                     <item>070005.IB_.0318_2007-4-30_2012-4-23_5Y_helper</item>

                                     <item>050005.IB_.0337_2005-6-3_2012-5-25_7Y_helper</item>

                                     <item>020009.IB_.027_2002-7-30_2012-7-19_10Y_helper</item>

                            </RateHelpers>

                            <DayCounter>Bond Basis</DayCounter>

                            <Jumps class_id="237" tracking_level="0" version="0">

                                     <count>0</count>

                                     <item_version>0</item_version>

                            </Jumps>

                            <JumpDates>

                                     <count>0</count>

                                     <item_version>0</item_version>

                            </JumpDates>

                            <Accuracy>9.9999999999999998e-013</Accuracy>

                            <TraitsID>ZeroYield</TraitsID>

                            <InterpolatorID>Linear</InterpolatorID>

                            <Permanent>0</Permanent>

                            <UserProperties class_id="238" tracking_level="0" version="0">

                                     <count>0</count>

                                     <item_version>0</item_version>

                            </UserProperties>

                   </px>

         </item>

</object_list>

</boost_serialization>

 

Regards,

Cheng


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users