R: Re: Curve building with depo, futures and swaps

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

R: Re: Curve building with depo, futures and swaps

tarpanelli@libero.it
Hi Kim,

the code is in try /catch block....
The code is into a mex file (it receives data from Matlab and returns the
results to Matlab)
The strange thing is this:
if I use just Depo and Futures I can build the yield curve and get discount
factors, rates computed correctly by quantlib into Matlab without no problem,
but when I added the swap rates, so I use the SwapRateHelper the system crashes
and returns me this exception:
 
QuantLib::Error at memory location 0x00c2d760..

And the same exception I have if I use bond instruments, when I go to
implement the Schedule.

Thanks in advance,
ciao
P

>----Messaggio originale----
>Da: [hidden email]
>Data: 28/07/2010 20.32
>A: "[hidden email]"<[hidden email]>
>Cc: <[hidden email]>
>Ogg: Re: [Quantlib-users] Curve building with depo, futures and swaps
>
>
>Hi P,
>
>[hidden email] schrieb:
>> Hello,
>>
>> I am just trying to build a curve by using the swap rates, futures and
depos
>> but I am having a very strange error (my system crash). Before re-
installing I
>> would like to know if someone of you see some error in my piece of code
that I
>> used. May be there is some error that I cant see.
>>  
>you seemed to have a runtime error. Can you provide a standalone example
>where we can reproduce the error?
>BTW did you put your code in a try/catch block to catch the runtime error?
>
>-Kim
>
>> Legenda = instruments is just a vector containing Rates and prices for
depo,
>> swap and futures.
>> Everithing looks works well till when I added the RateHelper for swap! In
fact
>> if I delete the swaps everithing works and I can use the PieceWise Yield
>> curve.
>>
>>
>> Rgrds
>>
>> P
>>
>>
-----------------------------------------------------------------------------------------------------
>> Code Below
>>
----------------------------------------------------------------------------

>>
>> // Deposit instruments <---
>> deporates = instruments[nInst+i];
>> boost::shared_ptr<Quote> depoquotes(new SimpleQuote(deporates));
>> boost::shared_ptr<RateHelper> deporatehelper(new DepositRateHelper
>> (Handle<Quote>(depoquotes),
>>     numtenor * tenor,
>>     fixingdays,
>>                          cal,
>>     rollconvention,
>>     false,
>>     daycount));
>>   instrumentCollection.push_back(deporatehelper);
>>
>> // Future instruments <---
>> futprices = instruments[nInst+i];
>> boost::shared_ptr<Quote> futquotes(new SimpleQuote(futprices));
>> Date expdate((int)instruments[4*nInst+i] + 1);
>> Date iMMdates = IMM::nextDate(expdate);
>> boost::shared_ptr<RateHelper> futratehelper(new FuturesRateHelper
(Handle<Quote>

>> (futquotes),
>>                     iMMdates,
>>                   futmonths,
>>                   cal,
>>                   rollconvention,
>>                   false,
>>                  daycount));
>> instrumentCollection.push_back(futratehelper);
>>
>> // Swap instruments <---
>> swrates = instruments[nInst+i];
>> boost::shared_ptr<Quote> swquotes(new SimpleQuote(swrates));
>> boost::shared_ptr<RateHelper> swratehelper(new SwapRateHelper
(Handle<Quote>

>> (swquotes),
>>                       numtenor * Years,
>>                   cal,
>>                  swFixedLegFreq,       // Annual
>>                  rollconvention,            // Unadjusted
>>                  swFixedLegDc,          // Thirty360(thirty360::
>> European)
>>                  swFloatingLegIndex));   // Euribor6M
>> instrumentCollection.push_back(swratehelper);
>>
>> // Yield curve constructor
>> double tolerance = 1.0e-15;
>> boost::shared_ptr<YieldTermStructure> depoFutSwapTermStructure(new
>> PiecewiseYieldCurve<Discount,LogLinear>(referencedate,
>>                       instrumentCollection,
>>   daycount,
>>   tolerance));
>> RelinkableHandle<YieldTermStructure> discountCurve;
>>
>>
------------------------------------------------------------------------------

>> This SF.net email is sponsored by Sprint
>> What will you do first with EVO, the first 4G phone?
>> Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
>> _______________________________________________
>> QuantLib-users mailing list
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/quantlib-users
>>
>>  
>
>



------------------------------------------------------------------------------
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share
of $1 Million in cash or HP Products. Visit us here for more details:
http://p.sf.net/sfu/dev2dev-palm
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: R: Re: Curve building with depo, futures and swaps

Kim Kuen Tang

Hi P,

[hidden email] schrieb:

> Hi Kim,
>
> the code is in try /catch block....
> The code is into a mex file (it receives data from Matlab and returns the
> results to Matlab)
> The strange thing is this:
> if I use just Depo and Futures I can build the yield curve and get discount
> factors, rates computed correctly by quantlib into Matlab without no problem,
> but when I added the swap rates, so I use the SwapRateHelper the system crashes
>  
i wish i can investigate the error, but without a standalone example i
cant do anything.
> and returns me this exception:
>  
> QuantLib::Error at memory location 0x00c2d760..
>  
IMHO QuantLib throws every error with a message, indicating the location
or the reason for the runtime error. Are you sure that this is the
entire message?
> And the same exception I have if I use bond instruments, when I go to
> implement the Schedule.
>  
Most of the problems i know come from the fact that the bootstrapping
method cannot find a satisfied solution for finding a root. Perhaps you
can go in this direction.

HTH

-Kim

> Thanks in advance,
> ciao
> P
>  
>> ----Messaggio originale----
>> Da: [hidden email]
>> Data: 28/07/2010 20.32
>> A: "[hidden email]"<[hidden email]>
>> Cc: <[hidden email]>
>> Ogg: Re: [Quantlib-users] Curve building with depo, futures and swaps
>>
>>
>> Hi P,
>>
>> [hidden email] schrieb:
>>    
>>> Hello,
>>>
>>> I am just trying to build a curve by using the swap rates, futures and
>>>      
> depos
>  
>>> but I am having a very strange error (my system crash). Before re-
>>>      
> installing I
>  
>>> would like to know if someone of you see some error in my piece of code
>>>      
> that I
>  
>>> used. May be there is some error that I cant see.
>>>  
>>>      
>> you seemed to have a runtime error. Can you provide a standalone example
>> where we can reproduce the error?
>> BTW did you put your code in a try/catch block to catch the runtime error?
>>
>> -Kim
>>
>>    
>>> Legenda = instruments is just a vector containing Rates and prices for
>>>      
> depo,
>  
>>> swap and futures.
>>> Everithing looks works well till when I added the RateHelper for swap! In
>>>      
> fact
>  
>>> if I delete the swaps everithing works and I can use the PieceWise Yield
>>> curve.
>>>
>>>
>>> Rgrds
>>>
>>> P
>>>
>>>
>>>      
> -----------------------------------------------------------------------------------------------------
>  
>>> Code Below
>>>
>>>      
> ----------------------------------------------------------------------------
>  
>>> // Deposit instruments <---
>>> deporates = instruments[nInst+i];
>>> boost::shared_ptr<Quote> depoquotes(new SimpleQuote(deporates));
>>> boost::shared_ptr<RateHelper> deporatehelper(new DepositRateHelper
>>> (Handle<Quote>(depoquotes),
>>>     numtenor * tenor,
>>>     fixingdays,
>>>                          cal,
>>>     rollconvention,
>>>     false,
>>>     daycount));
>>>   instrumentCollection.push_back(deporatehelper);
>>>
>>> // Future instruments <---
>>> futprices = instruments[nInst+i];
>>> boost::shared_ptr<Quote> futquotes(new SimpleQuote(futprices));
>>> Date expdate((int)instruments[4*nInst+i] + 1);
>>> Date iMMdates = IMM::nextDate(expdate);
>>> boost::shared_ptr<RateHelper> futratehelper(new FuturesRateHelper
>>>      
> (Handle<Quote>
>  
>>> (futquotes),
>>>                     iMMdates,
>>>                   futmonths,
>>>                   cal,
>>>                   rollconvention,
>>>                   false,
>>>                  daycount));
>>> instrumentCollection.push_back(futratehelper);
>>>
>>> // Swap instruments <---
>>> swrates = instruments[nInst+i];
>>> boost::shared_ptr<Quote> swquotes(new SimpleQuote(swrates));
>>> boost::shared_ptr<RateHelper> swratehelper(new SwapRateHelper
>>>      
> (Handle<Quote>
>  
>>> (swquotes),
>>>                       numtenor * Years,
>>>                   cal,
>>>                  swFixedLegFreq,       // Annual
>>>                  rollconvention,            // Unadjusted
>>>                  swFixedLegDc,          // Thirty360(thirty360::
>>> European)
>>>                  swFloatingLegIndex));   // Euribor6M
>>> instrumentCollection.push_back(swratehelper);
>>>
>>> // Yield curve constructor
>>> double tolerance = 1.0e-15;
>>> boost::shared_ptr<YieldTermStructure> depoFutSwapTermStructure(new
>>> PiecewiseYieldCurve<Discount,LogLinear>(referencedate,
>>>                       instrumentCollection,
>>>   daycount,
>>>   tolerance));
>>> RelinkableHandle<YieldTermStructure> discountCurve;
>>>
>>>
>>>      
> ------------------------------------------------------------------------------
>  
>>> This SF.net email is sponsored by Sprint
>>> What will you do first with EVO, the first 4G phone?
>>> Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
>>> _______________________________________________
>>> QuantLib-users mailing list
>>> [hidden email]
>>> https://lists.sourceforge.net/lists/listinfo/quantlib-users
>>>
>>>  
>>>      
>>    
>
>
>
>  


------------------------------------------------------------------------------
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share
of $1 Million in cash or HP Products. Visit us here for more details:
http://p.sf.net/sfu/dev2dev-palm
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: R: Re: Curve building with depo, futures and swaps

Luigi Ballabio
On Thu, 2010-07-29 at 21:34 +0200, Kim Kuen Tang wrote:

> [hidden email] schrieb:
> > the code is in try /catch block....
> >  
> > and returns me this exception:
> >  
> > QuantLib::Error at memory location 0x00c2d760..
> >  
> IMHO QuantLib throws every error with a message, indicating the location
> or the reason for the runtime error. Are you sure that this is the
> entire message?

Yes, it seems like the error wasn't caught.  What does your catch block
do, and what kind of errors does it catch?

Luigi


--

Don't let school get in the way of your education.
-- Mark Twain



------------------------------------------------------------------------------
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share
of $1 Million in cash or HP Products. Visit us here for more details:
http://p.sf.net/sfu/dev2dev-palm
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: R: Re: Curve building with depo, futures and swaps

Kim Kuen Tang

Hi tarpanelli,

Luigi Ballabio schrieb:
>> IMHO QuantLib throws every error with a message, indicating the location
>> or the reason for the runtime error. Are you sure that this is the
>> entire message?
>>    
>
> Yes, it seems like the error wasn't caught.  What does your catch block
> do, and what kind of errors does it catch?
>  

just want to make sure that u know how to catch all exceptions.

You need to add a catch block with this signature:

catch(...)

By doing this you will be sure that u really catch all and really all
errors.

# include <boost/cstdlib.hpp>

int main()
{
    try{
       // ur code
        return boost::exit_success;;
    }
    catch(std::exception& e)
    {
        std::cout<<e.what();
        return boost::exit_failure;
    }
    catch(...)
    {
        std::cout<<"UNKNOWN ERROR";
        return boost::exit_failure;
    }
}

> Luigi
>
>
>  


------------------------------------------------------------------------------
This SF.net email is sponsored by

Make an app they can't live without
Enter the BlackBerry Developer Challenge
http://p.sf.net/sfu/RIM-dev2dev 
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users