public override string name()
        {
            string res = familyName_;

            if (tenor_ == new Period(1, TimeUnit.Days))
            {
                if (fixingDays_ == 0)
                {
                    res += "ON";
                }
                else if (fixingDays_ == 1)
                {
                    res += "TN";
                }
                else if (fixingDays_ == 2)
                {
                    res += "SN";
                }
                else
                {
                    res += tenor_.ToShortString();
                }
            }
            else
            {
                res += tenor_.ToShortString();
            }
            res = res + " " + dayCounter_.name();
            return(res);
        }
Beispiel #2
0
 public virtual string name()
 {
     if (empty())
     {
         return("No implementation provided");
     }
     return(dayCounter_.name());
 }
Beispiel #3
0
        protected InterestRateIndex(string familyName,
                                    Period tenor,
                                    int fixingDays,
                                    Currency currency,
                                    Calendar fixingCalendar,
                                    DayCounter dayCounter)
        {
            familyName_     = familyName;
            tenor_          = tenor;
            fixingDays_     = fixingDays;
            currency_       = currency;
            dayCounter_     = dayCounter;
            fixingCalendar_ = fixingCalendar;


            tenor_.normalize();

            string res = familyName_;

            if (tenor_ == new Period(1, TimeUnit.Days))
            {
                if (fixingDays_ == 0)
                {
                    res += "ON";
                }
                else if (fixingDays_ == 1)
                {
                    res += "TN";
                }
                else if (fixingDays_ == 2)
                {
                    res += "SN";
                }
                else
                {
                    res += tenor_.ToShortString();
                }
            }
            else
            {
                res += tenor_.ToShortString();
            }
            res   = res + " " + dayCounter_.name();
            name_ = res;

            Settings.registerWith(update);
            // recheck
            IndexManager.instance().notifier(name()).registerWith(update);
        }
Beispiel #4
0
        public IborCoupon(Date paymentDate,
                          double nominal,
                          Date startDate,
                          Date endDate,
                          int fixingDays,
                          IborIndex iborIndex,
                          double gearing        = 1.0,
                          double spread         = 0.0,
                          Date refPeriodStart   = null,
                          Date refPeriodEnd     = null,
                          DayCounter dayCounter = null,
                          bool isInArrears      = false) :
            base(paymentDate, nominal, startDate, endDate, fixingDays, iborIndex, gearing, spread,
                 refPeriodStart, refPeriodEnd, dayCounter, isInArrears)
        {
            iborIndex_ = iborIndex;

            fixingDate_ = fixingDate();

            Calendar fixingCalendar  = index_.fixingCalendar();
            int      indexFixingDays = index_.fixingDays();

            fixingValueDate_ = fixingCalendar.advance(fixingDate_, indexFixingDays, TimeUnit.Days);

#if QL_USE_INDEXED_COUPON
            fixingEndDate_ = index_->maturityDate(fixingValueDate_);
#else
            if (isInArrears_)
            {
                fixingEndDate_ = index_.maturityDate(fixingValueDate_);
            }
            else
            {
                // par coupon approximation
                Date nextFixingDate = fixingCalendar.advance(accrualEndDate_, -fixingDays_, TimeUnit.Days);
                fixingEndDate_ = fixingCalendar.advance(nextFixingDate, indexFixingDays, TimeUnit.Days);
            }
#endif

            DayCounter dc = index_.dayCounter();
            spanningTime_ = dc.yearFraction(fixingValueDate_, fixingEndDate_);
            Utils.QL_REQUIRE(spanningTime_ > 0.0, () =>
                             "\n cannot calculate forward rate between " +
                             fixingValueDate_ + " and " + fixingEndDate_ +
                             ":\n non positive time (" + spanningTime_ +
                             ") using " + dc.name() + " daycounter");
        }