Ejemplo n.º 1
0
    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)));
    }
Ejemplo n.º 2
0
    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_;
    }
Ejemplo n.º 3
0
 Schedule BMAIndex::fixingSchedule(const Date& start, const Date& end) {
     return MakeSchedule().from(previousWednesday(start))
                          .to(nextWednesday(end))
                          .withFrequency(Weekly)
                          .withCalendar(fixingCalendar())
                          .withConvention(Following)
                          .forwards();
 }
Ejemplo n.º 4
0
 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);
 }
Ejemplo n.º 5
0
boost::shared_ptr<IborIndex> OvernightIndex::clone(
    const Handle<YieldTermStructure>& h) const {
    return boost::shared_ptr<IborIndex>(
               new OvernightIndex(familyName(),
                                  fixingDays(),
                                  currency(),
                                  fixingCalendar(),
                                  dayCounter(),
                                  h));
}
Ejemplo n.º 6
0
 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);
 }
Ejemplo n.º 7
0
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));
}
Ejemplo n.º 8
0
    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);
    }
Ejemplo n.º 9
0
Date IborIndex::maturityDate(const Date& valueDate) const {
    return fixingCalendar().advance(valueDate,
                                    tenor_,
                                    convention_,
                                    endOfMonth_);
}
Ejemplo n.º 10
0
 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);
 }
Ejemplo n.º 11
0
inline bool FxIndex::isValidFixingDate(const Date &d) const {
    return fixingCalendar().isBusinessDay(d);
}
Ejemplo n.º 12
0
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);
}
Ejemplo n.º 13
0
inline Date FxIndex::fixingDate(const Date &valueDate) const {
    Date fixingDate = fixingCalendar().advance(
        valueDate, -static_cast<Integer>(fixingDays_), Days);
    return fixingDate;
}