final IborIndex index = new Euribor6M(curveHandle);
for (int i=0; i<vars.swaps; i++) {
final Period tenor = new Period(swapData[i].n, swapData[i].units);
final VanillaSwap swap = new MakeVanillaSwap(tenor, index, 0.0)
.withEffectiveDate(vars.settlement)
.withFixedLegDayCount(vars.fixedLegDayCounter)
.withFixedLegTenor(new Period(vars.fixedLegFrequency))
.withFixedLegConvention(vars.fixedLegConvention)
.withFixedLegTerminationDateConvention(vars.fixedLegConvention)
.value();
/*@Rate*/ final double expectedRate = swapData[i].rate/100;
/*@Rate*/ final double estimatedRate = swap.fairRate();
/*@Real*/ final double tolerance = 1.0e-9;
if (Math.abs(expectedRate-estimatedRate) > tolerance) {
throw new RuntimeException(
String.format("%s %d %s %s %f %s %s %f",
"before LIBOR fixing:\n",
swapData[i].n, " year(s) swap:\n",
" estimated rate: ", estimatedRate, "\n",
" expected rate: ", expectedRate));
}
}
final Flag f = new Flag();
vars.termStructure.addObserver(f);
f.lower();
index.addFixing(vars.today, 0.0425);
if (!f.isUp())
throw new RuntimeException("Observer was not notified of rate fixing");
for (int i=0; i<vars.swaps; i++) {
final Period tenor = new Period(swapData[i].n, swapData[i].units);
final VanillaSwap swap = new MakeVanillaSwap(tenor, index, 0.0)
.withEffectiveDate(vars.settlement)
.withFixedLegDayCount(vars.fixedLegDayCounter)
.withFixedLegTenor(new Period(vars.fixedLegFrequency))
.withFixedLegConvention(vars.fixedLegConvention)
.withFixedLegTerminationDateConvention(vars.fixedLegConvention)
.value();
/*@Rate*/ final double expectedRate = swapData[i].rate/100;
/*@Rate*/ final double estimatedRate = swap.fairRate();
/*@Real*/ final double tolerance = 1.0e-9;
if (Math.abs(expectedRate-estimatedRate) > tolerance) {
throw new RuntimeException(
String.format("%s %d %s %s %f %s %s %f",
"after LIBOR fixing:\n",