Re: calendar.advance problem with Days TimeUnit (bug?)

Posted by Luca Ferraro-3 on
URL: http://quantlib.414.s1.nabble.com/calendar-advance-problem-with-Days-TimeUnit-bug-tp6531p6533.html

 <marco.tarenghi <at> bancaleonardo.com> writes:

>
>
> When the shift period is not "Days",
> the "advance" method works in this order 1) shift of tha period
> 2) adjustment on calendar business daysOn the other side, when the shift period
> is "Days", the shift is made day by day on business days; so
> a shift of 365Days is different from a shift of 1Year, and making a 365Days
> shift will not take you a yera before.The same reasoning holds for forward
> adjustment.I hope this answers youByeMarco

Marco, thanks a lot for your replay.

If I understand well, every Period object which has a "Days" time unit behaves
like that ... so, if I have to calibrate a short-rate model, using for example
SwaptionCalibrationHelper (which takes as first argument the maturity period of
the swaption) and the maturity dates of the calibrating options, I should
initialize the maturity period as:

Date AsOfDate(1, January, 2008);
std::vector< Date > swaptionMaturityDates();
// initialize maturity dates

Calendar calendar = TARGET();
std::vector< Period > swaptionMaturityPeriods()
for (int i = 0; i < swaptionMaturityDates.size(); ++i) {
    swaptionMaturityPeriods.push_back(
        Period firstMaturity(calendar.businessDaysBetween(
            AsOfDate, swaptionMaturityDates[i]) , Days) )
    );
}

... instead of (the wrong way I've been using):

DayCounter dc = ActualActual();
for (int i = 0; i < swaptionMaturityDates.size(); ++i) {
    swaptionMaturityPeriods.push_back(
        Period firstMaturity(dc.dayCount(
            AsOfDate, swaptionMaturityDates[i]) , Days) )
    );
}

... am I right? Is there a better way to compute periods to initialize
CalibrationHelpers?

Thanks again,

luca

PS: can anybody pleeeease spend some words on the question I previously posted,
titled "Calibrating Hull-White model with market data" (see
http://article.gmane.org/gmane.comp.finance.quantlib.user/5007). I have found
the SwaptionVolatilityMatrix class to interpolate volatilities, but what is the
common practice? Any sample code? At least a link to a newby discussion :-)


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users