protected override void initializeDates() { // dummy ibor index with curve/swap arguments IborIndex clonedIborIndex = iborIndex_.clone(termStructureHandle_); // do not pass the spread here, as it might be a Quote i.e. it can dinamically change swap_ = new MakeVanillaSwap(tenor_, clonedIborIndex, 0.0, fwdStart_) .withFixedLegDayCount(fixedDayCount_) .withFixedLegTenor(new Period(fixedFrequency_)) .withFixedLegConvention(fixedConvention_) .withFixedLegTerminationDateConvention(fixedConvention_) .withFixedLegCalendar(calendar_) .withFloatingLegCalendar(calendar_); earliestDate_ = swap_.startDate(); // Usually... latestDate_ = swap_.maturityDate(); // ...but due to adjustments, the last floating coupon might // need a later date for fixing #if QL_USE_INDEXED_COUPON FloatingRateCoupon lastFloating = (FloatingRateCoupon)swap_.floatingLeg()[swap_.floatingLeg().Count - 1]; Date fixingValueDate = iborIndex_.valueDate(lastFloating.fixingDate()); Date endValueDate = iborIndex_.maturityDate(fixingValueDate); latestDate_ = Date.Max(latestDate_, endValueDate); #endif }
public CapFloor value() { VanillaSwap swap = makeVanillaSwap_; List <CashFlow> leg = swap.floatingLeg(); if (firstCapletExcluded_) { leg.RemoveAt(0); } // only leaves the last coupon if (asOptionlet_ && leg.Count > 1) { leg.RemoveRange(0, leg.Count - 2); // Sun Studio needs an lvalue } List <double> strikeVector; if (strike_ == null) { // temporary patch... // should be fixed for every CapFloor::Engine BlackCapFloorEngine temp = engine_ as BlackCapFloorEngine; Utils.QL_REQUIRE(temp != null, () => "cannot calculate ATM without a BlackCapFloorEngine"); Handle <YieldTermStructure> discountCurve = temp.termStructure(); strikeVector = new InitializedList <double>(1, CashFlows.atmRate(leg, discountCurve, false, discountCurve.link.referenceDate())); //strikeVector[0] = CashFlows.atmRate(leg,discountCurve,false,discountCurve.link.referenceDate()); } else { strikeVector = new InitializedList <double>(1, strike_.Value); } CapFloor capFloor = new CapFloor(capFloorType_, leg, strikeVector); capFloor.setPricingEngine(engine_); return(capFloor); }
protected override void initializeDates() { // dummy ibor index with curve/swap arguments IborIndex clonedIborIndex = iborIndex_.clone(termStructureHandle_); // do not pass the spread here, as it might be a Quote i.e. it can dinamically change swap_ = new MakeVanillaSwap(tenor_, clonedIborIndex, 0.0, fwdStart_) .withFixedLegDayCount(fixedDayCount_) .withFixedLegTenor(new Period(fixedFrequency_)) .withFixedLegConvention(fixedConvention_) .withFixedLegTerminationDateConvention(fixedConvention_) .withFixedLegCalendar(calendar_) .withFloatingLegCalendar(calendar_); earliestDate_ = swap_.startDate(); // Usually... latestDate_ = swap_.maturityDate(); // ...but due to adjustments, the last floating coupon might // need a later date for fixing #if QL_USE_INDEXED_COUPON FloatingRateCoupon lastFloating = (FloatingRateCoupon)swap_.floatingLeg()[swap_.floatingLeg().Count - 1]; Date fixingValueDate = iborIndex_.valueDate(lastFloating.fixingDate()); Date endValueDate = iborIndex_.maturityDate(fixingValueDate); latestDate_ = Date.Max(latestDate_, endValueDate); #endif }