new Array(0), new Array(0),
new Array(0), new Array(0),
false,
100.0, new Date(30,Month.November,2004));
final PricingEngine bondEngine = new DiscountingBondEngine(riskFreeRate);
bond1.setPricingEngine(bondEngine);
PricerSetter.setCouponPricer(bond1.cashflows(),pricer);
final boolean indexedCoupon = new Settings().isUseIndexedCoupon();
final double cachedPrice1 = indexedCoupon ? 99.874645 : 99.874646;
double price = bond1.cleanPrice();
if (Math.abs(price-cachedPrice1) > tolerance) {
fail("failed to reproduce cached price:\n"
+ " calculated: " + price + "\n"
+ " expected: " + cachedPrice1 + "\n"
+ " error: " + (price-cachedPrice1));
}
// different risk-free and discount curve
final FloatingRateBond bond2 = new FloatingRateBond(settlementDays, vars.faceAmount, sch,
index, new ActualActual(ActualActual.Convention.ISMA),
BusinessDayConvention.ModifiedFollowing, fixingDays,
new Array(0), new Array(0),
new Array(0), new Array(0),
false,
100.0, new Date(30,Month.November,2004));
final PricingEngine bondEngine2 = new DiscountingBondEngine(discountCurve);
bond2.setPricingEngine(bondEngine2);
PricerSetter.setCouponPricer(bond2.cashflows(),pricer);
final double cachedPrice2 = indexedCoupon ? 97.955904 : 97.955904; // yes, they are the same, according to QuantLib/C++