コード例 #1
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(paymentDate, nominal, 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();
            Utils.QL_REQUIRE(valueDates_.Count >= 2, () => "degenerate schedule");

            // fixing dates
            n_ = valueDates_.Count - 1;
            if (overnightIndex.fixingDays() == 0)
            {
                fixingDates_ = new List <Date>(valueDates_);
            }
            else
            {
                fixingDates_ = new InitializedList <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());
        }
コード例 #2
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();
 }