public Swaption value() { Date evaluationDate = Settings.evaluationDate(); Calendar fixingCalendar = swapIndex_.fixingCalendar(); fixingDate_ = fixingCalendar.advance(evaluationDate, optionTenor_, optionConvention_); if (exerciseDate_ == null) { exercise_ = new EuropeanExercise(fixingDate_); } else { if (exerciseDate_ <= fixingDate_) { throw new ArgumentException( "exercise date (" + exerciseDate_ + ") must be less " + "than or equal to fixing date (" + fixingDate_ + ")"); } exercise_ = new EuropeanExercise(exerciseDate_); } double usedStrike; if (strike_ == null) { // ATM on the forecasting curve if (!swapIndex_.forwardingTermStructure().empty()) { throw new ArgumentException( "no forecasting term structure set to " + swapIndex_.name()); } VanillaSwap temp = swapIndex_.underlyingSwap(fixingDate_); temp.setPricingEngine(new DiscountingSwapEngine( swapIndex_.forwardingTermStructure())); usedStrike = temp.fairRate(); } else { usedStrike = strike_.Value; } BusinessDayConvention bdc = swapIndex_.fixedLegConvention(); underlyingSwap_ = new MakeVanillaSwap(swapIndex_.tenor(), swapIndex_.iborIndex(), usedStrike) .withEffectiveDate(swapIndex_.valueDate(fixingDate_)) .withFixedLegCalendar(swapIndex_.fixingCalendar()) .withFixedLegDayCount(swapIndex_.dayCounter()) .withFixedLegConvention(bdc) .withFixedLegTerminationDateConvention(bdc); Swaption swaption = new Swaption(underlyingSwap_, exercise_, delivery_); swaption.setPricingEngine(engine_); return(swaption); }
//public SwapRateHelper(Quote rate, SwapIndex swapIndex) : // this(rate, swapIndex, new SimpleQuote(), new Period(0, TimeUnit.Days)) { } //public SwapRateHelper(Quote rate, SwapIndex swapIndex, Quote spread) : // this(rate, swapIndex, spread, new Period(0, TimeUnit.Days)) { } public SwapRateHelper(Handle<Quote> rate, SwapIndex swapIndex, Handle<Quote> spread, Period fwdStart) : base(rate) { tenor_ = swapIndex.tenor(); calendar_ = swapIndex.fixingCalendar(); fixedConvention_ = swapIndex.fixedLegConvention(); fixedFrequency_ = swapIndex.fixedLegTenor().frequency(); fixedDayCount_ = swapIndex.dayCounter(); iborIndex_ = swapIndex.iborIndex(); spread_ = spread; fwdStart_ = fwdStart; // add observers iborIndex_.registerWith(update); spread_.registerWith(update); initializeDates(); }
//public SwapRateHelper(double rate, SwapIndex swapIndex) // : this(rate, swapIndex, new SimpleQuote()) { } //public SwapRateHelper(double rate, SwapIndex swapIndex, Quote spread) // : this(rate, swapIndex, spread, new Period(0, TimeUnit.Days)) { } public SwapRateHelper(double rate, SwapIndex swapIndex, Handle <Quote> spread, Period fwdStart) : base(rate) { tenor_ = swapIndex.tenor(); calendar_ = swapIndex.fixingCalendar(); fixedConvention_ = swapIndex.fixedLegConvention(); fixedFrequency_ = swapIndex.fixedLegTenor().frequency(); fixedDayCount_ = swapIndex.dayCounter(); iborIndex_ = swapIndex.iborIndex(); spread_ = spread; fwdStart_ = fwdStart; // add observers iborIndex_.registerWith(update); spread_.registerWith(update); initializeDates(); }
public MakeCms(Period swapTenor, SwapIndex swapIndex, double iborSpread = 0.0, Period forwardStart = null, Date maturityDate = null) { swapTenor_ = swapTenor; swapIndex_ = swapIndex; iborIndex_ = swapIndex.iborIndex(); iborSpread_ = iborSpread; iborCap_ = null; iborFloor_ = null; useAtmSpread_ = false; forwardStart_ = forwardStart ?? new Period(0, TimeUnit.Days); cmsSpread_ = 0.0; cmsGearing_ = 1.0; cmsCap_ = null; cmsFloor_ = null; effectiveDate_ = null; cmsCalendar_ = swapIndex.fixingCalendar(); floatCalendar_ = iborIndex_.fixingCalendar(); payCms_ = true; nominal_ = 1.0; maturityDate_ = maturityDate; cmsTenor_ = new Period(3, TimeUnit.Months); floatTenor_ = iborIndex_.tenor(); cmsConvention_ = BusinessDayConvention.ModifiedFollowing; cmsTerminationDateConvention_ = BusinessDayConvention.ModifiedFollowing; floatConvention_ = iborIndex_.businessDayConvention(); floatTerminationDateConvention_ = iborIndex_.businessDayConvention(); cmsRule_ = DateGeneration.Rule.Backward; floatRule_ = DateGeneration.Rule.Backward; cmsEndOfMonth_ = false; floatEndOfMonth_ = false; cmsFirstDate_ = null; cmsNextToLastDate_ = null; floatFirstDate_ = null; floatNextToLastDate_ = null; cmsDayCount_ = new Actual360(); floatDayCount_ = iborIndex_.dayCounter(); engine_ = new DiscountingSwapEngine(swapIndex.forwardingTermStructure()); }