//@} protected override void initializeDates() { Date settlementDate = settlementCalendar_.advance(evaluationDate_, settlementDays_, TimeUnit.Days); Date maturityDate = settlementDate + swapTenor_; Period shortLegTenor = shortIndex_.tenor(); Schedule shortLegSchedule = new MakeSchedule() .from(settlementDate) .to(maturityDate) .withTenor(shortLegTenor) .withCalendar(settlementCalendar_) .withConvention(rollConvention_) .endOfMonth(eom_) .value(); Period longLegTenor = longIndex_.tenor(); Schedule longLegSchedule = new MakeSchedule() .from(settlementDate) .to(maturityDate) .withTenor(longLegTenor) .withCalendar(settlementCalendar_) .withConvention(rollConvention_) .endOfMonth(eom_) .value(); double nominal = 1.0; double shortLegSpread = 0.0; double longLegSpread = 0.0; if (spreadOnShort_) { shortLegSpread = quote_.link.value(); } else { longLegSpread = quote_.link.value(); } /* Arbitrarily set the swap as paying the long index */ swap_ = new BasisSwap(BasisSwap.Type.Payer, nominal, shortLegSchedule, shortIndex_, shortLegSpread, shortIndex_.dayCounter(), longLegSchedule, longIndex_, longLegSpread, longIndex_.dayCounter(), BusinessDayConvention.Following); IPricingEngine engine; engine = new DiscountingSwapEngine(discountHandle_, false, settlementDate, settlementDate); engine.reset(); swap_.setPricingEngine(engine); earliestDate_ = swap_.startDate(); latestDate_ = swap_.maturityDate(); maturityDate_ = latestRelevantDate_ = swap_.maturityDate(); }
public BasisSwap value() { Date startDate; if (effectiveDate_ != null) { startDate = effectiveDate_; } else { int fixingDays = iborIndex1_.fixingDays(); Date referenceDate = Settings.evaluationDate(); Date spotDate = float1Calendar_.advance(referenceDate, new Period(fixingDays, TimeUnit.Days)); startDate = spotDate + forwardStart_; } Date endDate; if (terminationDate_ != null) { endDate = terminationDate_; } else { endDate = startDate + swapTenor_; } Schedule float1Schedule = new Schedule(startDate, endDate, float1Tenor_, float1Calendar_, float1Convention_, float1TerminationDateConvention_, float1Rule_, float1EndOfMonth_, float1FirstDate_, float1NextToLastDate_); Schedule float2Schedule = new Schedule(startDate, endDate, float2Tenor_, float2Calendar_, float2Convention_, float2TerminationDateConvention_, float2Rule_, float2EndOfMonth_, float2FirstDate_, float2NextToLastDate_); BasisSwap swap = new BasisSwap(type_, nominal_, float1Schedule, iborIndex1_, float1Spread_, float1DayCount_, float2Schedule, iborIndex2_, float2Spread_, float2DayCount_); swap.setPricingEngine(engine_); return(swap); }