public double rate()
{
double swapletRate = underlying_ != null ? underlying_.rate() : base.rate();
if (isFloored_ || isCapped_)
{
if (underlying_ != null)
{
if (underlying_.pricer() != null)
throw new ApplicationException("pricer not set");
}
else
{
throw new ApplicationException("pricer not set");
}
}
double floorletRate = 0.0;
if (isFloored_)
{
floorletRate = underlying_ != null ? underlying_.pricer().floorletRate(effectiveFloor()) : pricer().floorletRate(effectiveFloor());
}
double capletRate = 0.0;
if (isCapped_)
{
capletRate = underlying_ != null ? underlying_.pricer().capletRate(effectiveCap()) : pricer().capletRate(effectiveCap());
}
return swapletRate + floorletRate - capletRate;
}