Exemple #1
0
        public DatedOISRateHelper(Date startDate,
                                Date endDate,
                                Handle<Quote> fixedRate,
                                OvernightIndex overnightIndex)
            : base(fixedRate)
        {
            overnightIndex.registerWith(update);

            // dummy OvernightIndex with curve/swap arguments
            // review here
            IborIndex clonedIborIndex = overnightIndex.clone(termStructureHandle_);
            OvernightIndex clonedOvernightIndex = clonedIborIndex as OvernightIndex;

             swap_ = new MakeOIS(new Period(), clonedOvernightIndex, 0.0)
                              .withEffectiveDate(startDate)
                              .withTerminationDate(endDate)
                              .withDiscountingTermStructure(termStructureHandle_);

             earliestDate_ = swap_.startDate();
             latestDate_ = swap_.maturityDate();
        }
Exemple #2
0
        public OvernightIndexedSwap value()
        {
            Date startDate;

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

            // OIS end of month default
            bool usedEndOfMonth =
                isDefaultEOM_ ? calendar_.isEndOfMonth(startDate) : endOfMonth_;

            Date endDate = terminationDate_;

            if (endDate == null)
            {
                if (usedEndOfMonth)
                {
                    endDate = calendar_.advance(startDate,
                                                swapTenor_,
                                                BusinessDayConvention.ModifiedFollowing,
                                                usedEndOfMonth);
                }
                else
                {
                    endDate = startDate + swapTenor_;
                }
            }



            Schedule schedule = new Schedule(startDate, endDate,
                                             new Period(paymentFrequency_),
                                             calendar_,
                                             BusinessDayConvention.ModifiedFollowing,
                                             BusinessDayConvention.ModifiedFollowing,
                                             rule_,
                                             usedEndOfMonth);

            double?usedFixedRate = fixedRate_;

            if (fixedRate_ == null)
            {
                OvernightIndexedSwap temp = new OvernightIndexedSwap(type_, nominal_,
                                                                     schedule,
                                                                     0.0, // fixed rate
                                                                     fixedDayCount_,
                                                                     overnightIndex_, overnightSpread_);
                if (engine_ == null)
                {
                    Handle <YieldTermStructure> disc = overnightIndex_.forwardingTermStructure();
                    Utils.QL_REQUIRE(!disc.empty(), () => "null term structure set to this instance of " +
                                     overnightIndex_.name());
                    bool           includeSettlementDateFlows = false;
                    IPricingEngine engine = new DiscountingSwapEngine(disc, includeSettlementDateFlows);
                    temp.setPricingEngine(engine);
                }
                else
                {
                    temp.setPricingEngine(engine_);
                }

                usedFixedRate = temp.fairRate();
            }

            OvernightIndexedSwap ois = new OvernightIndexedSwap(type_, nominal_,
                                                                schedule,
                                                                usedFixedRate.Value, fixedDayCount_,
                                                                overnightIndex_, overnightSpread_);

            if (engine_ == null)
            {
                Handle <YieldTermStructure> disc          = overnightIndex_.forwardingTermStructure();
                bool           includeSettlementDateFlows = false;
                IPricingEngine engine = new DiscountingSwapEngine(disc, includeSettlementDateFlows);
                ois.setPricingEngine(engine);
            }
            else
            {
                ois.setPricingEngine(engine_);
            }

            return(ois);
        }
        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);
        }
Exemple #4
0
 public MakeOIS withType(OvernightIndexedSwap.Type type) 
 {
    type_ = type;
    return this;
 }
Exemple #5
0
      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;
      }
Exemple #6
0
        protected override void initializeDates()
        {
            // dummy OvernightIndex with curve/swap arguments
             // review here
             IborIndex clonedIborIndex = overnightIndex_.clone(termStructureHandle_);
             OvernightIndex clonedOvernightIndex = clonedIborIndex as OvernightIndex;

             swap_ = new MakeOIS(tenor_, clonedOvernightIndex, 0.0)
                     .withSettlementDays(settlementDays_)
                     .withDiscountingTermStructure(termStructureHandle_);

             earliestDate_ = swap_.startDate();
             latestDate_ = swap_.maturityDate();
        }