Day counting offset

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

Day counting offset

Guowen Han

Hi, All

I have a day counting offset problem.

When I fit a swaption volatility (with maturity 10 years and length 20) in  a 30 year zero yield curve, I got the following error message:

In function `void QuantLib::YieldTermStructure::checkRange(QuantLib::Time, bool) const':
time (30.0082) is past max curve time (30)

Does anyone know how to fix it? My current solution is to take one month off the maturity, which is 119 months.


Thanks.

Guowen
Reply | Threaded
Open this post in threaded view
|

Re: Day counting offset

Luigi Ballabio
On 07/01/2005 05:44:19 PM, Guowen Han wrote:
>
> I have a day counting offset problem.
>
> Does anyone know how to fix it?

It looks either like a day-count mismatch or a business-date-adjustment  
problem. Can you provide more data on how you initialized the term  
structure and the other objects involved?

Later,
        Luigi


----------------------------------------

standards, n.:
         The principles we use to reject other people's code.



Reply | Threaded
Open this post in threaded view
|

Re: Day counting offset

Luigi Ballabio
In reply to this post by Guowen Han
On 07/06/2005 10:29:11 PM, Guowen Han wrote:

>
> The error message can be removed (suggested by Michelotti Enrico) by
> adding the following statement.
>         myTermStructure->enableExtrapolation();
>
> However the offset is still there, and I got more time points than
> expected. Here is my code, any suggestions are appreciated
>
>     std::vector<Date> dates;
>     dates.push_back(refDate + Period(0, Months));
>     ...
>     dates.push_back(refDate + Period(360, Months));

It's probably a date-adjustment thing. You're passing as the last date  
on the curve the reference date plus 30 years, unadjusted. But that  
date might be a holiday, so the swaption maturity (calculated inside  
the swaption helper) is set one or two days later and falls off the end  
of the term structure.

You can try initializing the curve dates as

std::vector<Date> dates;
Calendar calendar = ...; (the one relevant for your calculation)
dates.push_back(refDate);
dates.push_back(calendar.advance(refDate, Period(1,Months)));
...
dates.push_back(calendar.advance(refDate, Period(360,Months)));

This might push the end of the curve a day or two further, which is the  
lag you need.

Later,
        Luigi

----------------------------------------

The shortest way to do many things is to do only one thing at once.
-- Samuel Smiles