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;
            }
        }
        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());
        }
Exemple #3
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();
 }