Esempio n. 1
0
 BMAIndex::BMAIndex(const Handle<YieldTermStructure>& h)
 : InterestRateIndex("BMA",
                     1 * Weeks,
                     1,
                     USDCurrency(),
                     UnitedStates(UnitedStates::NYSE),
                     ActualActual(ActualActual::ISDA)),
   termStructure_(h) {
     registerWith (h);
 }
Esempio n. 2
0
 USCPI(bool interpolated,
        const Handle<ZeroInflationTermStructure>& ts =
                                  Handle<ZeroInflationTermStructure>())
 : ZeroInflationIndex("CPI",
                      USRegion(),
                      false,
                      interpolated,
                      Monthly,
                      Period(1, Months), // availability
                      USDCurrency(),
                      ts) {}
Esempio n. 3
0
 YYUSCPIr(bool interpolated,
           const Handle<YoYInflationTermStructure>& ts =
                                   Handle<YoYInflationTermStructure>())
 : YoYInflationIndex("YYR_CPI",
                     USRegion(),
                     false,
                     interpolated,
                     true,
                     Monthly,
                     Period(1, Months),
                     USDCurrency(),
                     ts) {}
Esempio n. 4
0
 UsdLiborSwapIsdaFixPm::UsdLiborSwapIsdaFixPm(
                             const Period& tenor,
                             const Handle<YieldTermStructure>& h)
 : SwapIndex("UsdLiborSwapIsdaFixPm", // familyName
             tenor,
             2, // settlementDays
             USDCurrency(),
             UnitedStates(UnitedStates::GovernmentBond),
             6*Months, // fixedLegTenor
             ModifiedFollowing, // fixedLegConvention
             Thirty360(Thirty360::BondBasis), // fixedLegDaycounter
             boost::shared_ptr<IborIndex>(new USDLibor(3*Months, h))) {}
Esempio n. 5
0
 UsdLiborSwapIsdaFixPm::UsdLiborSwapIsdaFixPm(
                             const Period& tenor,
                             const Handle<YieldTermStructure>& forwarding,
                             const Handle<YieldTermStructure>& discounting)
 : SwapIndex("UsdLiborSwapIsdaFixPm", // familyName
             tenor,
             2, // settlementDays
             USDCurrency(),
             TARGET(),
             6*Months, // fixedLegTenor
             ModifiedFollowing, // fixedLegConvention
             Thirty360(Thirty360::BondBasis), // fixedLegDaycounter
             boost::shared_ptr<IborIndex>(new USDLibor(3*Months, forwarding)),
             discounting) {}
Esempio n. 6
0
 FedFunds::FedFunds(const Handle<YieldTermStructure>& h)
 : OvernightIndex("FedFunds", 0,
                  USDCurrency(),
                  UnitedStates(UnitedStates::Settlement),
                  Actual360(), h) {}
Esempio n. 7
0
    MakeVanillaSwap::operator ext::shared_ptr<VanillaSwap>() const {

        Date startDate;
        if (effectiveDate_ != Date())
            startDate = effectiveDate_;
        else {
            Date refDate = Settings::instance().evaluationDate();
            // if the evaluation date is not a business day
            // then move to the next business day
            refDate = floatCalendar_.adjust(refDate);
            Date spotDate = floatCalendar_.advance(refDate,
                                                   settlementDays_*Days);
            startDate = spotDate+forwardStart_;
            if (forwardStart_.length()<0)
                startDate = floatCalendar_.adjust(startDate,
                                                  Preceding);
            else
                startDate = floatCalendar_.adjust(startDate,
                                                  Following);
        }

        Date endDate = terminationDate_;
        if (endDate == Date()) {
            if (floatEndOfMonth_)
                endDate = floatCalendar_.advance(startDate,
                                                 swapTenor_,
                                                 ModifiedFollowing,
                                                 floatEndOfMonth_);
            else
                endDate = startDate + swapTenor_;
        }

        const Currency& curr = iborIndex_->currency();
        Period fixedTenor;
        if (fixedTenor_ != Period())
            fixedTenor = fixedTenor_;
        else {
            if ((curr == EURCurrency()) ||
                (curr == USDCurrency()) ||
                (curr == CHFCurrency()) ||
                (curr == SEKCurrency()) ||
                (curr == GBPCurrency() && swapTenor_ <= 1 * Years))
                fixedTenor = Period(1, Years);
            else if ((curr == GBPCurrency() && swapTenor_ > 1 * Years) ||
                (curr == JPYCurrency()) ||
                (curr == AUDCurrency() && swapTenor_ >= 4 * Years))
                fixedTenor = Period(6, Months);
            else if ((curr == HKDCurrency() ||
                     (curr == AUDCurrency() && swapTenor_ < 4 * Years)))
                fixedTenor = Period(3, Months);
            else
                QL_FAIL("unknown fixed leg default tenor for " << curr);
        }

        Schedule fixedSchedule(startDate, endDate,
                               fixedTenor, fixedCalendar_,
                               fixedConvention_,
                               fixedTerminationDateConvention_,
                               fixedRule_, fixedEndOfMonth_,
                               fixedFirstDate_, fixedNextToLastDate_);

        Schedule floatSchedule(startDate, endDate,
                               floatTenor_, floatCalendar_,
                               floatConvention_,
                               floatTerminationDateConvention_,
                               floatRule_, floatEndOfMonth_,
                               floatFirstDate_, floatNextToLastDate_);

        DayCounter fixedDayCount;
        if (fixedDayCount_ != DayCounter())
            fixedDayCount = fixedDayCount_;
        else {
            if (curr == USDCurrency())
                fixedDayCount = Actual360();
            else if (curr == EURCurrency() || curr == CHFCurrency() ||
                     curr == SEKCurrency())
                fixedDayCount = Thirty360(Thirty360::BondBasis);
            else if (curr == GBPCurrency() || curr == JPYCurrency() ||
                     curr == AUDCurrency() || curr == HKDCurrency())
                fixedDayCount = Actual365Fixed();
            else
                QL_FAIL("unknown fixed leg day counter for " << curr);
        }

        Rate usedFixedRate = fixedRate_;
        if (fixedRate_ == Null<Rate>()) {
            VanillaSwap temp(type_, nominal_,
                             fixedSchedule,
                             0.0, // fixed rate
                             fixedDayCount,
                             floatSchedule, iborIndex_,
                             floatSpread_, floatDayCount_);
            if (engine_ == 0) {
                Handle<YieldTermStructure> disc =
                                        iborIndex_->forwardingTermStructure();
                QL_REQUIRE(!disc.empty(),
                           "null term structure set to this instance of " <<
                           iborIndex_->name());
                bool includeSettlementDateFlows = false;
                ext::shared_ptr<PricingEngine> engine(new
                    DiscountingSwapEngine(disc, includeSettlementDateFlows));
                temp.setPricingEngine(engine);
            } else
                temp.setPricingEngine(engine_);

            usedFixedRate = temp.fairRate();
        }

        ext::shared_ptr<VanillaSwap> swap(new
            VanillaSwap(type_, nominal_,
                        fixedSchedule,
                        usedFixedRate, fixedDayCount,
                        floatSchedule,
                        iborIndex_, floatSpread_, floatDayCount_));

        if (engine_ == 0) {
            Handle<YieldTermStructure> disc =
                                    iborIndex_->forwardingTermStructure();
            bool includeSettlementDateFlows = false;
            ext::shared_ptr<PricingEngine> engine(new
                DiscountingSwapEngine(disc, includeSettlementDateFlows));
            swap->setPricingEngine(engine);
        } else
            swap->setPricingEngine(engine_);

        return swap;
    }