public OISRateHelper(int settlementDays,
                      Period tenor, // swap maturity
                      Handle<Quote> fixedRate,
                      OvernightIndex overnightIndex)
    : base(fixedRate)
 {
    settlementDays_ = settlementDays;
    tenor_ = tenor;
    overnightIndex_ = overnightIndex;
    overnightIndex_.registerWith(update);
    initializeDates();
 }
Ejemplo n.º 2
0
        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());
        }
Ejemplo n.º 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;
 }
Ejemplo n.º 4
0
      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"); 
         
         }
      }
Ejemplo n.º 5
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());
 }
Ejemplo n.º 6
0
        public static List <CashFlow> OvernightLeg(List <double> nominals,
                                                   Schedule schedule,
                                                   BusinessDayConvention paymentAdjustment,
                                                   OvernightIndex overnightIndex,
                                                   List <double> gearings,
                                                   List <double> spreads,
                                                   DayCounter paymentDayCounter)
        {
            Utils.QL_REQUIRE(!nominals.empty(), () => "no nominal given");

            List <CashFlow> leg = new List <CashFlow>();

            // the following is not always correct
            Calendar calendar = schedule.calendar();

            Date refStart, start, refEnd, end;
            Date paymentDate;

            int n = schedule.Count;

            for (int i = 0; i < n - 1; ++i)
            {
                refStart    = start = schedule.date(i);
                refEnd      = end = schedule.date(i + 1);
                paymentDate = calendar.adjust(end, paymentAdjustment);
                if (i == 0 && !schedule.isRegular(i + 1))
                {
                    refStart = calendar.adjust(end - schedule.tenor(), paymentAdjustment);
                }
                if (i == n - 1 && !schedule.isRegular(i + 1))
                {
                    refEnd = calendar.adjust(start + schedule.tenor(), paymentAdjustment);
                }

                leg.Add(new OvernightIndexedCoupon(paymentDate,
                                                   Utils.Get(nominals, i),
                                                   start, end,
                                                   overnightIndex,
                                                   Utils.Get(gearings, i, 1.0),
                                                   Utils.Get(spreads, i, 0.0),
                                                   refStart, refEnd,
                                                   paymentDayCounter));
            }
            return(leg);
        }
Ejemplo n.º 7
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());
 }
Ejemplo n.º 8
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();
        }
Ejemplo n.º 9
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();
        }
        public override double swapletRate()
        {
            OvernightIndex index = coupon_.index() as OvernightIndex;

            List <Date>   fixingDates = coupon_.fixingDates();
            List <double> dt          = coupon_.dt();

            int n = dt.Count();
            int i = 0;

            double compoundFactor = 1.0;

            // already fixed part
            Date today = Settings.evaluationDate();

            while (fixingDates[i] < today && i < n)
            {
                // rate must have been fixed
                double pastFixing = IndexManager.instance().getHistory(
                    index.name()).value()[fixingDates[i]];

                if (pastFixing == default(double))
                {
                    throw new ApplicationException("Missing " + index.name() + " fixing for "
                                                   + fixingDates[i].ToString());
                }

                compoundFactor *= (1.0 + pastFixing * dt[i]);
                ++i;
            }

            // today is a border case
            if (fixingDates[i] == today && i < n)
            {
                // might have been fixed
                try
                {
                    double pastFixing = IndexManager.instance().getHistory(
                        index.name()).value()[fixingDates[i]];

                    if (pastFixing != default(double))
                    {
                        compoundFactor *= (1.0 + pastFixing * dt[i]);
                        ++i;
                    }
                    else
                    {
                        ; // fall through and forecast
                    }
                }
                catch (Exception e)
                {
                    ;  // fall through and forecast
                }
            }

            // forward part using telescopic property in order
            // to avoid the evaluation of multiple forward fixings
            if (i < n)
            {
                Handle <YieldTermStructure> curve = index.forwardingTermStructure();
                if (curve.empty())
                {
                    throw new ArgumentException("null term structure set to this instance of" +
                                                index.name());
                }

                List <Date> dates         = coupon_.valueDates();
                double      startDiscount = curve.link.discount(dates[i]);
                double      endDiscount   = curve.link.discount(dates[n]);

                compoundFactor *= startDiscount / endDiscount;
            }

            double rate = (compoundFactor - 1.0) / coupon_.accrualPeriod();

            return(coupon_.gearing() * rate + coupon_.spread());
        }
 public OvernightLeg(Schedule schedule, OvernightIndex overnightIndex)
 {
     schedule_          = schedule;
     overnightIndex_    = overnightIndex;
     paymentAdjustment_ = BusinessDayConvention.Following;
 }
 public MakeOIS(Period swapTenor, OvernightIndex overnightIndex)
     : this(swapTenor, overnightIndex, null, new Period(0, TimeUnit.Days))
 {
 }
 public MakeOIS(Period swapTenor, OvernightIndex overnightIndex,
                double?fixedRate) : this(swapTenor, overnightIndex, fixedRate, new Period(0, TimeUnit.Days))
 {
 }
Ejemplo n.º 14
0
 public OvernightLeg(Schedule schedule,OvernightIndex overnightIndex)
 {
     schedule_ = schedule;
       overnightIndex_ = overnightIndex;
       paymentAdjustment_ = BusinessDayConvention.Following;
 }
Ejemplo n.º 15
0
 public MakeOIS(Period swapTenor, OvernightIndex overnightIndex) 
    : this(swapTenor, overnightIndex, null, new Period(0, TimeUnit.Days))
 {}
Ejemplo n.º 16
0
 public MakeOIS(Period swapTenor, OvernightIndex overnightIndex,
                double? fixedRate) : this(swapTenor,overnightIndex,fixedRate,new Period (0,TimeUnit.Days))
 {}