public OvernightIndexedCoupon( Date paymentDate, double nominal, Date startDate, Date endDate, OvernightIndex overnightIndex, double gearing = 1.0, double spread = 0.0, Date refPeriodStart = null, Date refPeriodEnd = null, DayCounter dayCounter = null) : base(nominal, paymentDate, startDate, endDate, overnightIndex.fixingDays(), overnightIndex, gearing, spread, refPeriodStart, refPeriodEnd, dayCounter, false) { // value dates Schedule sch = new MakeSchedule() .from(startDate) .to(endDate) .withTenor(new Period(1, TimeUnit.Days)) .withCalendar(overnightIndex.fixingCalendar()) .withConvention(overnightIndex.businessDayConvention()) .backwards() .value(); valueDates_ = sch.dates(); if (valueDates_.Count < 2) { throw new ArgumentException("degenerate schedule"); } // fixing dates n_ = valueDates_.Count() - 1; if (overnightIndex.fixingDays() == 0) { fixingDates_ = new List <Date>(valueDates_); } else { fixingDates_ = new List <Date>(n_); for (int i = 0; i < n_; ++i) { fixingDates_[i] = overnightIndex.fixingDate(valueDates_[i]); } } // accrual (compounding) periods dt_ = new List <double>(n_); DayCounter dc = overnightIndex.dayCounter(); for (int i = 0; i < n_; ++i) { dt_.Add(dc.yearFraction(valueDates_[i], valueDates_[i + 1])); } setPricer(new OvernightIndexedCouponPricer()); }
public OvernightIndexedCoupon( Date paymentDate, double nominal, Date startDate, Date endDate, OvernightIndex overnightIndex, double gearing = 1.0, double spread = 0.0, Date refPeriodStart = null, Date refPeriodEnd = null, DayCounter dayCounter = null) : base(nominal, paymentDate,startDate, endDate, overnightIndex.fixingDays(), overnightIndex, gearing, spread, refPeriodStart, refPeriodEnd, dayCounter, false) { // value dates Schedule sch = new MakeSchedule() .from(startDate) .to(endDate) .withTenor(new Period(1,TimeUnit.Days)) .withCalendar(overnightIndex.fixingCalendar()) .withConvention(overnightIndex.businessDayConvention()) .backwards() .value(); valueDates_ = sch.dates(); if (valueDates_.Count < 2) throw new ArgumentException("degenerate schedule"); // fixing dates n_ = valueDates_.Count()-1; if (overnightIndex.fixingDays()==0) { fixingDates_ = new List<Date>(valueDates_); } else { fixingDates_ = new List<Date>(n_); for (int i=0; i<n_; ++i) fixingDates_[i] = overnightIndex.fixingDate(valueDates_[i]); } // accrual (compounding) periods dt_ = new List<double>(n_); DayCounter dc = overnightIndex.dayCounter(); for (int i=0; i<n_; ++i) dt_.Add(dc.yearFraction(valueDates_[i], valueDates_[i+1])); setPricer(new OvernightIndexedCouponPricer()); }
public OvernightIndexedSwapIndex( string familyName, Period tenor, int settlementDays, Currency currency, OvernightIndex overnightIndex) : base(familyName, tenor, settlementDays, currency, overnightIndex.fixingCalendar(), new Period(1, TimeUnit.Years), BusinessDayConvention.ModifiedFollowing, overnightIndex.dayCounter(), overnightIndex) { overnightIndex_ = overnightIndex; }
public OvernightIndexedSwapIndex( string familyName, Period tenor, int settlementDays, Currency currency, OvernightIndex overnightIndex) : base(familyName, tenor, settlementDays, currency, overnightIndex.fixingCalendar(), new Period(1,TimeUnit.Years),BusinessDayConvention.ModifiedFollowing, overnightIndex.dayCounter(),overnightIndex) { overnightIndex_ = overnightIndex; }
public MakeOIS(Period swapTenor, OvernightIndex overnightIndex, double?fixedRate = null, Period fwdStart = null) { swapTenor_ = swapTenor; overnightIndex_ = overnightIndex; fixedRate_ = fixedRate; forwardStart_ = fwdStart ?? new Period(0, TimeUnit.Days); settlementDays_ = 2; calendar_ = overnightIndex.fixingCalendar(); paymentFrequency_ = Frequency.Annual; rule_ = DateGeneration.Rule.Backward; // any value here for endOfMonth_ would not be actually used isDefaultEOM_ = true; type_ = OvernightIndexedSwap.Type.Payer; nominal_ = 1.0; overnightSpread_ = 0.0; fixedDayCount_ = overnightIndex.dayCounter(); }
public MakeOIS(Period swapTenor, OvernightIndex overnightIndex, double?fixedRate = null, Period fwdStart = null) { swapTenor_ = swapTenor; overnightIndex_ = overnightIndex; fixedRate_ = fixedRate; forwardStart_ = fwdStart ?? new Period(0, TimeUnit.Days); settlementDays_ = 2; calendar_ = overnightIndex.fixingCalendar(); paymentFrequency_ = Frequency.Annual; rule_ = DateGeneration.Rule.Backward; // any value here for endOfMonth_ would not be actually used isDefaultEOM_ = true; //endOfMonth_ = (new Period(1,TimeUnit.Months)<=swapTenor && swapTenor<=new Period(2,TimeUnit.Years) ? true : false); type_ = OvernightIndexedSwap.Type.Payer; nominal_ = 1.0; overnightSpread_ = 0.0; fixedDayCount_ = overnightIndex.dayCounter(); //engine_ = new DiscountingSwapEngine(overnightIndex_.forwardingTermStructure()); }
public OvernightIndexedSwap value() { Calendar calendar = overnightIndex_.fixingCalendar(); Date startDate; if (effectiveDate_ != null) { startDate = effectiveDate_; } else { Date referenceDate = Settings.evaluationDate(); Date spotDate = calendar.advance(referenceDate, new Period(fixingDays_, TimeUnit.Days)); startDate = spotDate + forwardStart_; } Date endDate; if (terminationDate_ != null) { endDate = terminationDate_; } else { if (endOfMonth_) { endDate = calendar.advance(startDate, swapTenor_, BusinessDayConvention.ModifiedFollowing, endOfMonth_); } else { endDate = startDate + swapTenor_; } } Schedule schedule = new Schedule(startDate, endDate, new Period(paymentFrequency_), calendar, BusinessDayConvention.ModifiedFollowing, BusinessDayConvention.ModifiedFollowing, rule_, endOfMonth_); double?usedFixedRate = fixedRate_; if (fixedRate_ == null) { if (overnightIndex_.forwardingTermStructure().empty()) { throw new ApplicationException("null term structure set to this instance of " + overnightIndex_.name()); } OvernightIndexedSwap temp = new OvernightIndexedSwap(type_, nominal_, schedule, 0.0, // fixed rate fixedDayCount_, overnightIndex_, overnightSpread_); // ATM on the forecasting curve //bool includeSettlementDateFlows = false; temp.setPricingEngine(new DiscountingSwapEngine( overnightIndex_.forwardingTermStructure())); usedFixedRate = temp.fairRate(); } OvernightIndexedSwap ois = new OvernightIndexedSwap(type_, nominal_, schedule, usedFixedRate.Value, fixedDayCount_, overnightIndex_, overnightSpread_); ois.setPricingEngine(engine_); return(ois); }