Logo Search packages:      
Sourcecode: quantlib version File versions  Download package

Time QuantLib::inflationYearFraction ( Frequency  ,
bool  indexIsInterpolated,
const DayCounter &  ,
const Date &  ,
const Date &   
)

utility function giving the time between two dates depending on index frequency and interpolation, and a day counter

Definition at line 337 of file inflationtermstructure.cpp.

References inflationPeriod(), and QuantLib::DayCounter::yearFraction().

                                                               {

        Time t=0;
        if (indexIsInterpolated) {
            // N.B. we do not use linear interpolation between flat
            // fixing forecasts for forecasts.  This avoids awkwardnesses
            // when bootstrapping the inflation curve.
            t = dayCounter.yearFraction(d1, d2);
        } else {
            // I.e. fixing is constant for the whole inflation period.
            // Use the value for half way along the period.
            // But the inflation time is the time between period starts
            std::pair<Date,Date> limD1 = inflationPeriod(d1, f);
            std::pair<Date,Date> limD2 = inflationPeriod(d2, f);
            t = dayCounter.yearFraction(limD1.first, limD2.first);
        }

        return t;
    }


Generated by  Doxygen 1.6.0   Back to index