Hi,
I've modified parts of the test-suite/hestonmodel.cpp to incorporate dividends. Specifically, I've changed the testDAXCalibration method to include some descrete divident values (paid at the same dates in the program) as follows (full source code attached): vector<Real> dividends; for (i = 0; i < 8; ++i) { dates.push_back(settlementDate + t[i]); rates.push_back(r[i]); dividends.push_back(0.1); } Handle<YieldTermStructure> dividendTS( boost::shared_ptr<YieldTermStructure>( new ZeroCurve(dates, dividends, dayCounter))); When I run the program, it aborts. On Linux, I get the following trace using gdb. Continuing. Testing Heston model calibration using DAX volatility data... Program received signal SIGABRT, Aborted. 0x0000002a9643f479 in raise () from /lib64/tls/libc.so.6 (gdb) where #0 0x0000002a9643f479 in raise () from /lib64/tls/libc.so.6 #1 0x0000002a96440abf in abort () from /lib64/tls/libc.so.6 #2 0x0000002a9606fca6 in __cxxabiv1::__terminate () from /usr/lib64/libstdc++.so.5 #3 0x0000002a9606fcd3 in std::terminate () from /usr/lib64/libstdc++.so.5 #4 0x0000002a9606fdc3 in __cxa_throw () from /usr/lib64/libstdc++.so.5 #5 0x0000000000489b6e in InterpolatedZeroCurve (this=<value optimized out>, dates=<value optimized out>, yields=<value optimized out>, dayCounter=<value optimized out>, interpolator=<value optimized out>) at /QuantLib-0.8.1/ql/termstructures/yieldcurves/zerocurve.hpp:150 #6 0x000000000043d370 in main (argc=<value optimized out>, argv=<value optimized out>) at HestonDAXCalibration.cpp:73 Could someone point out what I'm doing wrong. Thank you very much. HestonDAXCalibration.cpp |
Hi,
please change it into vector<Real> dividends; dividends.push_back(0,1); for (i = 0; i < 8; ++i) { dates.push_back(settlementDate + t[i]); rates.push_back(r[i]); dividends.push_back(0.1); } In addition I'd recommend to add a "global" try-catch block for QuantLib exceptions around your program. E. g. then you get the correct error message std::exception: dates/yields count mismatch for your original program. hope that helps Klaus On Tuesday 08 July 2008 19:10:03 cc2008 wrote: > Hi, > I've modified parts of the test-suite/hestonmodel.cpp to incorporate > dividends. Specifically, I've changed the testDAXCalibration method to > include some descrete divident values (paid at the same dates in the > program) as follows (full source code attached): > > vector<Real> dividends; > > for (i = 0; i < 8; ++i) { > > dates.push_back(settlementDate + t[i]); > > rates.push_back(r[i]); > > dividends.push_back(0.1); > > } > > > Handle<YieldTermStructure> dividendTS( > boost::shared_ptr<YieldTermStructure>( > new ZeroCurve(dates, dividends, dayCounter))); > > > When I run the program, it aborts. On Linux, I get the following trace > using gdb. > Continuing. > Testing Heston model calibration using DAX volatility data... > > Program received signal SIGABRT, Aborted. > 0x0000002a9643f479 in raise () from /lib64/tls/libc.so.6 > (gdb) where > #0 0x0000002a9643f479 in raise () from /lib64/tls/libc.so.6 > #1 0x0000002a96440abf in abort () from /lib64/tls/libc.so.6 > #2 0x0000002a9606fca6 in __cxxabiv1::__terminate () > from /usr/lib64/libstdc++.so.5 > #3 0x0000002a9606fcd3 in std::terminate () from /usr/lib64/libstdc++.so.5 > #4 0x0000002a9606fdc3 in __cxa_throw () from /usr/lib64/libstdc++.so.5 > #5 0x0000000000489b6e in InterpolatedZeroCurve (this=<value optimized > out>, dates=<value optimized out>, yields=<value optimized out>, > dayCounter=<value optimized out>, interpolator=<value optimized out>) > at /QuantLib-0.8.1/ql/termstructures/yieldcurves/zerocurve.hpp:150 > #6 0x000000000043d370 in main (argc=<value optimized out>, > argv=<value optimized out>) at HestonDAXCalibration.cpp:73 > > > Could someone point out what I'm doing wrong. Thank you very much. > > > http://www.nabble.com/file/p18343830/HestonDAXCalibration.cpp > HestonDAXCalibration.cpp -- Klaus Spanderen Ludwig Erhard Str. 12 48734 Reken (Germany) EMail: [hidden email] (remove NOSPAM from the address) ------------------------------------------------------------------------- Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW! Studies have shown that voting for your favorite open source project, along with a healthy diet, reduces your potential for chronic lameness and boredom. Vote Now at http://www.sourceforge.net/community/cca08 _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
Hi Klaus,
Thank you very much. I totally missed the mismatch in sizes of dates and dividends. Thanks again.
|
Free forum by Nabble | Edit this page |