public Swap value() { Date startDate; if (effectiveDate_ != null) { startDate = effectiveDate_; } else { int fixingDays = iborIndex_.fixingDays(); Date refDate = Settings.evaluationDate(); // if the evaluation date is not a business day // then move to the next business day refDate = floatCalendar_.adjust(refDate); Date spotDate = floatCalendar_.advance(refDate, new Period(fixingDays, TimeUnit.Days)); startDate = spotDate + forwardStart_; } Date terminationDate = startDate + swapTenor_; Schedule cmsSchedule = new Schedule(startDate, terminationDate, cmsTenor_, cmsCalendar_, cmsConvention_, cmsTerminationDateConvention_, cmsRule_, cmsEndOfMonth_, cmsFirstDate_, cmsNextToLastDate_); Schedule floatSchedule = new Schedule(startDate, terminationDate, floatTenor_, floatCalendar_, floatConvention_, floatTerminationDateConvention_, floatRule_, floatEndOfMonth_, floatFirstDate_, floatNextToLastDate_); List <CashFlow> cmsLeg = new CmsLeg(cmsSchedule, swapIndex_) .withPaymentDayCounter(cmsDayCount_) .withFixingDays(swapIndex_.fixingDays()) .withGearings(cmsGearing_) .withSpreads(cmsSpread_) .withCaps(cmsCap_) .withFloors(cmsFloor_) .withNotionals(nominal_) .withPaymentAdjustment(cmsConvention_); if (couponPricer_ != null) { Utils.setCouponPricer(cmsLeg, couponPricer_); } double?usedSpread = iborSpread_; if (useAtmSpread_) { Utils.QL_REQUIRE(!iborIndex_.forwardingTermStructure().empty(), () => "null term structure set to this instance of " + iborIndex_.name()); Utils.QL_REQUIRE(!swapIndex_.forwardingTermStructure().empty(), () => "null term structure set to this instance of " + swapIndex_.name()); Utils.QL_REQUIRE(couponPricer_ != null, () => "no CmsCouponPricer set (yet)"); List <CashFlow> fLeg = new IborLeg(floatSchedule, iborIndex_) .withPaymentDayCounter(floatDayCount_) .withFixingDays(iborIndex_.fixingDays()) .withNotionals(nominal_) .withPaymentAdjustment(floatConvention_); Swap temp = new Swap(cmsLeg, fLeg); temp.setPricingEngine(engine_); double?npv = temp.legNPV(0) + temp.legNPV(1); usedSpread = -npv / temp.legBPS(1) * 1e-4; } else { Utils.QL_REQUIRE(usedSpread.HasValue, () => "null spread set"); } List <CashFlow> floatLeg = new IborLeg(floatSchedule, iborIndex_) .withSpreads(usedSpread.Value) .withPaymentDayCounter(floatDayCount_) .withFixingDays(iborIndex_.fixingDays()) .withPaymentAdjustment(floatConvention_) .withNotionals(nominal_); Swap swap; if (payCms_) { swap = new Swap(cmsLeg, floatLeg); } else { swap = new Swap(floatLeg, cmsLeg); } swap.setPricingEngine(engine_); return(swap); }