public double fairRate()
{
// What does this mean before or after trade date?
// Always means that NPV is zero for _this_ instrument
// if it was created with _this_ rate
// _knowing_ the time from base to obs (etc).
IndexedCashFlow icf = legs_[1][0] as IndexedCashFlow;
if (icf == null)
{
throw new ApplicationException("failed to downcast to IndexedCashFlow in ::fairRate()");
}
// +1 because the IndexedCashFlow has growthOnly=true
double growth = icf.amount() / icf.notional() + 1.0;
double T = Utils.inflationYearFraction(infIndex_.frequency(),
infIndex_.interpolated(),
dayCounter_, baseDate_, obsDate_);
return(Math.Pow(growth, 1.0 / T) - 1.0);
// we cannot use this simple definition because
// it does not work for already-issued instruments
// return infIndex_->zeroInflationTermStructure()->zeroRate(
// maturityDate(), observationLag(), infIndex_->interpolated());
}