shared_ptr<SwapIndex> SwapIndex::clone(const Handle<YieldTermStructure>& forwarding) const { if (exogenousDiscount_) return shared_ptr<SwapIndex>(new SwapIndex(familyName(), tenor(), fixingDays(), currency(), fixingCalendar(), fixedLegTenor(), fixedLegConvention(), dayCounter(), iborIndex_->clone(forwarding), discount_)); else return shared_ptr<SwapIndex>(new SwapIndex(familyName(), tenor(), fixingDays(), currency(), fixingCalendar(), fixedLegTenor(), fixedLegConvention(), dayCounter(), iborIndex_->clone(forwarding))); }
shared_ptr<VanillaSwap> SwapIndex::underlyingSwap(const Date& fixingDate) const { QL_REQUIRE(fixingDate!=Date(), "null fixing date"); // caching mechanism if (lastFixingDate_!=fixingDate) { Rate fixedRate = 0.0; if (exogenousDiscount_) lastSwap_ = MakeVanillaSwap(tenor_, iborIndex_, fixedRate) .withEffectiveDate(valueDate(fixingDate)) .withFixedLegCalendar(fixingCalendar()) .withFixedLegDayCount(dayCounter_) .withFixedLegTenor(fixedLegTenor_) .withFixedLegConvention(fixedLegConvention_) .withFixedLegTerminationDateConvention(fixedLegConvention_) .withDiscountingTermStructure(discount_); else lastSwap_ = MakeVanillaSwap(tenor_, iborIndex_, fixedRate) .withEffectiveDate(valueDate(fixingDate)) .withFixedLegCalendar(fixingCalendar()) .withFixedLegDayCount(dayCounter_) .withFixedLegTenor(fixedLegTenor_) .withFixedLegConvention(fixedLegConvention_) .withFixedLegTerminationDateConvention(fixedLegConvention_); lastFixingDate_ = fixingDate; } return lastSwap_; }
Schedule BMAIndex::fixingSchedule(const Date& start, const Date& end) { return MakeSchedule().from(previousWednesday(start)) .to(nextWednesday(end)) .withFrequency(Weekly) .withCalendar(fixingCalendar()) .withConvention(Following) .forwards(); }
Rate BMAIndex::forecastFixing(const Date& fixingDate) const { QL_REQUIRE(!termStructure_.empty(), "null term structure set to this instance of " << name()); Date start = fixingCalendar().advance(fixingDate, 1, Days); Date end = maturityDate(start); return termStructure_->forwardRate(start, end, dayCounter_, Simple); }
boost::shared_ptr<IborIndex> OvernightIndex::clone( const Handle<YieldTermStructure>& h) const { return boost::shared_ptr<IborIndex>( new OvernightIndex(familyName(), fixingDays(), currency(), fixingCalendar(), dayCounter(), h)); }
bool BMAIndex::isValidFixingDate(const Date& date) const { Calendar cal = fixingCalendar(); // either the fixing date is last Wednesday, or all days // between last Wednesday included and the fixing date are // holidays for (Date d = previousWednesday(date); d<date; ++d) { if (cal.isBusinessDay(d)) return false; } // also, the fixing date itself must be a business day return cal.isBusinessDay(date); }
boost::shared_ptr<IborIndex> IborIndex::clone( const Handle<YieldTermStructure>& h) const { return boost::shared_ptr<IborIndex>( new IborIndex(familyName(), tenor(), fixingDays(), currency(), fixingCalendar(), businessDayConvention(), endOfMonth(), dayCounter(), h)); }
Date Libor::valueDate(const Date& fixingDate) const { QL_REQUIRE(isValidFixingDate(fixingDate), "Fixing date " << fixingDate << " is not valid"); // http://www.bba.org.uk/bba/jsp/polopoly.jsp?d=225&a=1412 : // For all currencies other than EUR and GBP the period between // Fixing Date and Value Date will be two London business days // after the Fixing Date, or if that day is not both a London // business day and a business day in the principal financial centre // of the currency concerned, the next following day which is a // business day in both centres shall be the Value Date. Date d = fixingCalendar().advance(fixingDate, fixingDays_, Days); return jointCalendar_.adjust(d); }
Date IborIndex::maturityDate(const Date& valueDate) const { return fixingCalendar().advance(valueDate, tenor_, convention_, endOfMonth_); }
Date BMAIndex::maturityDate(const Date& valueDate) const { Calendar cal = fixingCalendar(); Date fixingDate = cal.advance(valueDate, -1, Days); Date nextWednesday = previousWednesday(fixingDate+7); return cal.advance(nextWednesday, 1, Days); }
inline bool FxIndex::isValidFixingDate(const Date &d) const { return fixingCalendar().isBusinessDay(d); }
inline Date FxIndex::valueDate(const Date &fixingDate) const { QL_REQUIRE(isValidFixingDate(fixingDate), fixingDate << " is not a valid fixing date"); return fixingCalendar().advance(fixingDate, fixingDays_, Days); }
inline Date FxIndex::fixingDate(const Date &valueDate) const { Date fixingDate = fixingCalendar().advance( valueDate, -static_cast<Integer>(fixingDays_), Days); return fixingDate; }