OvernightIndexedSwap::OvernightIndexedSwap(
                    Type type,
                    Real nominal,
                    const Schedule& schedule,
                    Rate fixedRate,
                    const DayCounter& fixedDC,
                    const boost::shared_ptr<OvernightIndex>& overnightIndex,
                    Spread spread)
      : Swap(2), type_(type), nominal_(nominal),
        paymentFrequency_(schedule.tenor().frequency()),
        //schedule_(schedule),
        fixedRate_(fixedRate), fixedDC_(fixedDC),
        overnightIndex_(overnightIndex), spread_(spread) {

        if (fixedDC_==DayCounter())
            fixedDC_ = overnightIndex_->dayCounter();
        legs_[0] = FixedRateLeg(schedule)
            .withNotionals(nominal_)
            .withCouponRates(fixedRate_, fixedDC_);

        legs_[1] = OvernightLeg(schedule, overnightIndex_)
            .withNotionals(nominal_)
            .withSpreads(spread_);

        for (Size j=0; j<2; ++j) {
            for (Leg::iterator i = legs_[j].begin(); i!= legs_[j].end(); ++i)
                registerWith(*i);
        }

        switch (type_) {
          case Payer:
            payer_[0] = -1.0;
            payer_[1] = +1.0;
            break;
          case Receiver:
            payer_[0] = +1.0;
            payer_[1] = -1.0;
            break;
          default:
            QL_FAIL("Unknown overnight-swap type");
        }
    }
Ejemplo n.º 2
0
    void IBOROISBasisSwap::initialize() {
		
        legs_[0] = IborLeg(floatingSchedule_, iborIndex_)
            .withNotionals(nominals_)
			.withPaymentDayCounter(floatingDayCount_)
            .withPaymentAdjustment(paymentConvention_);

        legs_[1] = OvernightLeg(overnightSchedule_, overnightIndex_)
            .withNotionals(nominals_)
			.withPaymentDayCounter(overnightDayCount_)
			.withPaymentAdjustment(paymentConvention_)
            .withSpreads(spread_);
		if(arithmeticAveragedCoupon_) {
			boost::shared_ptr<FloatingRateCouponPricer> arithmeticPricer(
								new ArithmeticAveragedOvernightIndexedCouponPricer());
			for(Size i = 0; i < legs_[1].size(); i++) {
				boost::shared_ptr<OvernightIndexedCoupon> c =
					boost::dynamic_pointer_cast<OvernightIndexedCoupon> (legs_[1][i]);
				c->setPricer(arithmeticPricer);
			}
		}

        for (Size j=0; j<2; ++j) {
            for (Leg::iterator i = legs_[j].begin(); i!= legs_[j].end(); ++i)
                registerWith(*i);
        }

        switch (type_) {
          case Payer:
            payer_[0] = -1.0;
            payer_[1] = +1.0;
            break;
          case Receiver:
            payer_[0] = +1.0;
            payer_[1] = -1.0;
            break;
          default:
            QL_FAIL("Unknown overnight-basis-swap type");
        }
    }