public OvernightIndexedCoupon(
            Date paymentDate,
            double nominal,
            Date startDate,
            Date endDate,
            OvernightIndex overnightIndex,
            double gearing        = 1.0,
            double spread         = 0.0,
            Date refPeriodStart   = null,
            Date refPeriodEnd     = null,
            DayCounter dayCounter = null)
            : base(nominal, paymentDate, startDate, endDate,
                   overnightIndex.fixingDays(), overnightIndex,
                   gearing, spread,
                   refPeriodStart, refPeriodEnd,
                   dayCounter, false)
        {
            // value dates
            Schedule sch = new MakeSchedule()
                           .from(startDate)
                           .to(endDate)
                           .withTenor(new Period(1, TimeUnit.Days))
                           .withCalendar(overnightIndex.fixingCalendar())
                           .withConvention(overnightIndex.businessDayConvention())
                           .backwards()
                           .value();

            valueDates_ = sch.dates();
            if (valueDates_.Count < 2)
            {
                throw new ArgumentException("degenerate schedule");
            }

            // fixing dates
            n_ = valueDates_.Count() - 1;
            if (overnightIndex.fixingDays() == 0)
            {
                fixingDates_ = new List <Date>(valueDates_);
            }
            else
            {
                fixingDates_ = new List <Date>(n_);
                for (int i = 0; i < n_; ++i)
                {
                    fixingDates_[i] = overnightIndex.fixingDate(valueDates_[i]);
                }
            }

            // accrual (compounding) periods
            dt_ = new List <double>(n_);
            DayCounter dc = overnightIndex.dayCounter();

            for (int i = 0; i < n_; ++i)
            {
                dt_.Add(dc.yearFraction(valueDates_[i], valueDates_[i + 1]));
            }

            setPricer(new OvernightIndexedCouponPricer());
        }
Beispiel #2
0
        public OvernightIndexedSwap(Type type,
                                    double fixedNominal,
                                    Schedule fixedSchedule,
                                    double fixedRate,
                                    DayCounter fixedDC,
                                    double overnightNominal,
                                    Schedule overnightSchedule,
                                    OvernightIndex overnightIndex,
                                    double spread) :
            base(2)
        {
            type_                      = type;
            fixedNominal_              = fixedNominal;
            overnightNominal_          = overnightNominal;
            fixedPaymentFrequency_     = fixedSchedule.tenor().frequency();
            overnightPaymentFrequency_ = overnightSchedule.tenor().frequency();
            fixedRate_                 = fixedRate;
            fixedDC_                   = fixedDC;
            overnightIndex_            = overnightIndex;
            spread_                    = spread;

            if (fixedDC_ == null)
            {
                fixedDC_ = overnightIndex_.dayCounter();
            }

            legs_[0] = new FixedRateLeg(fixedSchedule)
                       .withCouponRates(fixedRate_, fixedDC_)
                       .withNotionals(fixedNominal_);

            legs_[1] = new OvernightLeg(overnightSchedule, overnightIndex_)
                       .withNotionals(overnightNominal_)
                       .withSpreads(spread_);

            for (int j = 0; j < 2; ++j)
            {
                for (int i = 0; i < legs_[j].Count; i++)
                {
                    legs_[j][i].registerWith(update);
                }
            }

            switch (type_)
            {
            case Type.Payer:
                payer_[0] = -1.0;
                payer_[1] = +1.0;
                break;

            case Type.Receiver:
                payer_[0] = +1.0;
                payer_[1] = -1.0;
                break;

            default:
                Utils.QL_FAIL("Unknown overnight-swap type");
                break;
            }
        }
Beispiel #3
0
 public OvernightIndexedSwapIndex(
     string familyName,
     Period tenor,
     int settlementDays,
     Currency currency,
     OvernightIndex overnightIndex)
     : base(familyName, tenor, settlementDays,
            currency, overnightIndex.fixingCalendar(),
            new Period(1, TimeUnit.Years), BusinessDayConvention.ModifiedFollowing,
            overnightIndex.dayCounter(), overnightIndex)
 {
     overnightIndex_ = overnightIndex;
 }
Beispiel #4
0
 public OvernightIndexedSwapIndex(
           string familyName,
           Period tenor,
           int settlementDays,
           Currency currency,
           OvernightIndex overnightIndex)
     : base(familyName, tenor, settlementDays,
         currency, overnightIndex.fixingCalendar(),
         new Period(1,TimeUnit.Years),BusinessDayConvention.ModifiedFollowing, 
         overnightIndex.dayCounter(),overnightIndex)
 {
     overnightIndex_ = overnightIndex;
 }
      public OvernightIndexedSwap(Type type,
                                  double nominal,
                                  Schedule schedule,
                                  double fixedRate,
                                  DayCounter fixedDC,
                                  OvernightIndex overnightIndex,
                                  double spread) : 
      base(2)
      {
      
         type_= type;
         nominal_ = nominal;
         paymentFrequency_ = schedule.tenor().frequency();
         fixedRate_ = fixedRate;
         fixedDC_ = fixedDC;
         overnightIndex_ = overnightIndex;
         spread_ = spread;

         if (fixedDC_== null)
            fixedDC_ = overnightIndex_.dayCounter();

         legs_[0] = new FixedRateLeg(schedule)
            .withCouponRates(fixedRate_, fixedDC_)
            .withNotionals(nominal_);

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

         for (int j = 0; j < 2; ++j)
         {
            for (int i = 0; i < legs_[j].Count; i++)
               legs_[j][i].registerWith(update);
         }

         switch (type_) 
         {
            case Type.Payer:
               payer_[0] = -1.0;
               payer_[1] = +1.0;
               break;
            case Type.Receiver:
               payer_[0] = +1.0;
               payer_[1] = -1.0;
               break;
            default:
               throw new ApplicationException("Unknown overnight-swap type"); 
         
         }
      }
Beispiel #6
0
 public MakeOIS(Period swapTenor, OvernightIndex overnightIndex, double?fixedRate = null, Period fwdStart = null)
 {
     swapTenor_        = swapTenor;
     overnightIndex_   = overnightIndex;
     fixedRate_        = fixedRate;
     forwardStart_     = fwdStart ?? new Period(0, TimeUnit.Days);
     settlementDays_   = 2;
     calendar_         = overnightIndex.fixingCalendar();
     paymentFrequency_ = Frequency.Annual;
     rule_             = DateGeneration.Rule.Backward;
     // any value here for endOfMonth_ would not be actually used
     isDefaultEOM_    = true;
     type_            = OvernightIndexedSwap.Type.Payer;
     nominal_         = 1.0;
     overnightSpread_ = 0.0;
     fixedDayCount_   = overnightIndex.dayCounter();
 }
 public MakeOIS(Period swapTenor, OvernightIndex overnightIndex,
                double?fixedRate, Period fwdStart)
 {
     swapTenor_        = swapTenor;
     overnightIndex_   = overnightIndex;
     fixedRate_        = fixedRate;
     forwardStart_     = fwdStart;
     fixingDays_       = 2;
     paymentFrequency_ = Frequency.Annual;
     rule_             = DateGeneration.Rule.Backward;
     endOfMonth_       = (new Period(1, TimeUnit.Months) <= swapTenor && swapTenor <= new Period(2, TimeUnit.Years) ? true : false);
     type_             = OvernightIndexedSwap.Type.Payer;
     nominal_          = 1.0;
     overnightSpread_  = 0.0;
     fixedDayCount_    = overnightIndex.dayCounter();
     engine_           = new DiscountingSwapEngine(overnightIndex_.forwardingTermStructure());
 }
Beispiel #8
0
 public MakeOIS(Period swapTenor, OvernightIndex overnightIndex,
              double? fixedRate, Period fwdStart)
 {
     swapTenor_=swapTenor;
      overnightIndex_ = overnightIndex;
      fixedRate_= fixedRate;
      forwardStart_= fwdStart;
      fixingDays_ = 2;
      paymentFrequency_ = Frequency.Annual;
      rule_ = DateGeneration.Rule.Backward;
      endOfMonth_ = (new Period(1,TimeUnit.Months)<=swapTenor && swapTenor<=new Period(2,TimeUnit.Years) ? true : false);
      type_ = OvernightIndexedSwap.Type.Payer;
      nominal_ = 1.0;
      overnightSpread_ = 0.0;
      fixedDayCount_ = overnightIndex.dayCounter();
      engine_ = new DiscountingSwapEngine(overnightIndex_.forwardingTermStructure());
 }
Beispiel #9
0
 public MakeOIS(Period swapTenor, OvernightIndex overnightIndex, double?fixedRate = null, Period fwdStart = null)
 {
     swapTenor_        = swapTenor;
     overnightIndex_   = overnightIndex;
     fixedRate_        = fixedRate;
     forwardStart_     = fwdStart ?? new Period(0, TimeUnit.Days);
     settlementDays_   = 2;
     calendar_         = overnightIndex.fixingCalendar();
     paymentFrequency_ = Frequency.Annual;
     rule_             = DateGeneration.Rule.Backward;
     // any value here for endOfMonth_ would not be actually used
     isDefaultEOM_ = true;
     //endOfMonth_ = (new Period(1,TimeUnit.Months)<=swapTenor && swapTenor<=new Period(2,TimeUnit.Years) ? true : false);
     type_            = OvernightIndexedSwap.Type.Payer;
     nominal_         = 1.0;
     overnightSpread_ = 0.0;
     fixedDayCount_   = overnightIndex.dayCounter();
     //engine_ = new DiscountingSwapEngine(overnightIndex_.forwardingTermStructure());
 }
        public OvernightIndexedCoupon(
            Date paymentDate,
            double nominal,
            Date startDate,
            Date endDate,
            OvernightIndex overnightIndex,
            double gearing = 1.0,
            double spread = 0.0,
            Date refPeriodStart = null,
            Date refPeriodEnd = null,
            DayCounter dayCounter = null)
            : base(nominal, paymentDate,startDate, endDate,
                         overnightIndex.fixingDays(), overnightIndex,
                         gearing, spread,
                         refPeriodStart, refPeriodEnd,
                         dayCounter, false)
        {
            // value dates
             Schedule sch = new MakeSchedule()
                      .from(startDate)
                      .to(endDate)
                      .withTenor(new Period(1,TimeUnit.Days))
                      .withCalendar(overnightIndex.fixingCalendar())
                      .withConvention(overnightIndex.businessDayConvention())
                      .backwards()
                      .value();

             valueDates_ = sch.dates();
             if (valueDates_.Count < 2)
            throw new ArgumentException("degenerate schedule");

             // fixing dates
             n_ = valueDates_.Count()-1;
             if (overnightIndex.fixingDays()==0)
             {
            fixingDates_ = new List<Date>(valueDates_);
             }
             else
             {
            fixingDates_ = new List<Date>(n_);
            for (int i=0; i<n_; ++i)
                fixingDates_[i] = overnightIndex.fixingDate(valueDates_[i]);
             }

             // accrual (compounding) periods
             dt_ = new List<double>(n_);
             DayCounter dc = overnightIndex.dayCounter();
             for (int i=0; i<n_; ++i)
            dt_.Add(dc.yearFraction(valueDates_[i], valueDates_[i+1]));

             setPricer(new OvernightIndexedCouponPricer());
        }