상속: Index, IObserver
예제 #1
0
        // constructors
        public FloatingRateCoupon(Date paymentDate,
                                  double nominal,
                                  Date startDate,
                                  Date endDate,
                                  int fixingDays,
                                  InterestRateIndex index,
                                  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, refPeriodStart, refPeriodEnd)
        {
            index_       = index;
            dayCounter_  = dayCounter ?? new DayCounter();
            fixingDays_  = fixingDays == default(int) ? index.fixingDays() : fixingDays;
            gearing_     = gearing;
            spread_      = spread;
            isInArrears_ = isInArrears;

            if (gearing_.IsEqual(0))
            {
                throw new ArgumentException("Null gearing not allowed");
            }

            if (dayCounter_.empty())
            {
                dayCounter_ = index_.dayCounter();
            }

            // add as observer
            index_.registerWith(update);
            Settings.registerWith(update);
        }
예제 #2
0
파일: CmsCoupon.cs 프로젝트: zhangz/QLNet
 // Factory - for Leg generators
 public override CashFlow factory(double nominal, Date paymentDate, Date startDate, Date endDate, int fixingDays,
                                  InterestRateIndex index, double gearing, double spread,
                                  Date refPeriodStart, Date refPeriodEnd, DayCounter dayCounter, bool isInArrears)
 {
     return(new CmsCoupon(nominal, paymentDate, startDate, endDate, fixingDays,
                          (SwapIndex)index, gearing, spread, refPeriodStart, refPeriodEnd, dayCounter, isInArrears));
 }
예제 #3
0
파일: Iborcoupon.cs 프로젝트: vdt/QLNet
 // Factory - for Leg generators
 public override CashFlow factory(double nominal, Date paymentDate, Date startDate, Date endDate, int fixingDays,
     InterestRateIndex index, double gearing, double spread,
     Date refPeriodStart, Date refPeriodEnd, DayCounter dayCounter, bool isInArrears)
 {
     return new IborCoupon(nominal, paymentDate, startDate, endDate, fixingDays,
             (IborIndex)index, gearing, spread, refPeriodStart, refPeriodEnd, dayCounter, isInArrears);
 }
예제 #4
0
 // Factory - for Leg generators
 public virtual CashFlow factory(double nominal, Date paymentDate, Date startDate, Date endDate, int fixingDays,
                                 InterestRateIndex index, double gearing, double spread,
                                 Date refPeriodStart, Date refPeriodEnd, DayCounter dayCounter, bool isInArrears)
 {
     return(new FloatingRateCoupon(paymentDate, nominal, startDate, endDate, fixingDays,
                                   index, gearing, spread, refPeriodStart, refPeriodEnd, dayCounter, isInArrears));
 }
예제 #5
0
      // constructors
      public FloatingRateCoupon(double nominal, 
                                Date paymentDate, 
                                Date startDate, 
                                Date endDate, 
                                int fixingDays, 
                                InterestRateIndex index,
                                double gearing = 1.0, 
                                double spread = 0.0, 
                                Date refPeriodStart = null, 
                                Date refPeriodEnd = null, 
                                DayCounter dayCounter = null, 
                                bool isInArrears = false) 
         : base(nominal, paymentDate, startDate, endDate, refPeriodStart, refPeriodEnd)
      {
         index_ = index;
         dayCounter_ = dayCounter == null ? new DayCounter() : dayCounter ;
         fixingDays_ = fixingDays == default(int) ? index.fixingDays() : fixingDays;
         gearing_ = gearing;
         spread_ = spread;
         isInArrears_ = isInArrears;

         if (gearing_ == 0) throw new ArgumentException("Null gearing not allowed");

         if (dayCounter_.empty())
            dayCounter_ = index_.dayCounter();

         // add as observer
         index_.registerWith(update);
         Settings.registerWith(update);
      }
예제 #6
0
        public override double swapletRate()
        {
            List <Date>       fixingDates = coupon_.fixingDates();
            InterestRateIndex index       = coupon_.index();

            int  cutoffDays = 0; // to be verified
            Date startDate  = coupon_.accrualStartDate() - cutoffDays,
                 endDate    = coupon_.accrualEndDate() - cutoffDays,
                 d1         = startDate,
                 d2         = startDate;

            if (!(fixingDates.Count > 0))
            {
                throw new ApplicationException("fixing date list empty");
            }
            if (!(index.valueDate(fixingDates.First()) <= startDate))
            {
                throw new ApplicationException("first fixing date valid after period start");
            }
            if (!(index.valueDate(fixingDates.Last()) >= endDate))
            {
                throw new ApplicationException("last fixing date valid before period end");
            }

            double avgBMA = 0.0;
            int    days   = 0;

            for (int i = 0; i < fixingDates.Count - 1; ++i)
            {
                Date valueDate     = index.valueDate(fixingDates[i]);
                Date nextValueDate = index.valueDate(fixingDates[i + 1]);

                if (fixingDates[i] >= endDate || valueDate >= endDate)
                {
                    break;
                }
                if (fixingDates[i + 1] < startDate || nextValueDate <= startDate)
                {
                    continue;
                }

                d2 = Date.Min(nextValueDate, endDate);

                avgBMA += index.fixing(fixingDates[i]) * (d2 - d1);

                days += d2 - d1;
                d1    = d2;
            }
            avgBMA /= (endDate - startDate);

            if (!(days == endDate - startDate))
            {
                throw new ApplicationException("averaging days " + days + " differ from " +
                                               "interest days " + (endDate - startDate));
            }

            return(coupon_.gearing() * avgBMA + coupon_.spread());
        }
예제 #7
0
        public FloatFloatSwap(VanillaSwap.Type type,
                              List <double> nominal1,
                              List <double> nominal2,
                              Schedule schedule1,
                              InterestRateIndex index1,
                              DayCounter dayCount1,
                              Schedule schedule2,
                              InterestRateIndex index2,
                              DayCounter dayCount2,
                              bool intermediateCapitalExchange         = false,
                              bool finalCapitalExchange                = false,
                              List <double> gearing1                   = null,
                              List <double> spread1                    = null,
                              List <double?> cappedRate1               = null,
                              List <double?> flooredRate1              = null,
                              List <double> gearing2                   = null,
                              List <double> spread2                    = null,
                              List <double?> cappedRate2               = null,
                              List <double?> flooredRate2              = null,
                              BusinessDayConvention?paymentConvention1 = null,
                              BusinessDayConvention?paymentConvention2 = null)
            : base(2)
        {
            type_         = type;
            nominal1_     = nominal1;
            nominal2_     = nominal2;
            schedule1_    = schedule1;
            schedule2_    = schedule2;
            index1_       = index1;
            index2_       = index2;
            gearing1_     = gearing1;
            gearing2_     = gearing2;
            spread1_      = spread1;
            spread2_      = spread2;
            cappedRate1_  = cappedRate1;
            flooredRate1_ = flooredRate1;
            cappedRate2_  = cappedRate2;
            flooredRate2_ = flooredRate2;
            dayCount1_    = dayCount1;
            dayCount2_    = dayCount2;
            intermediateCapitalExchange_ = intermediateCapitalExchange;
            finalCapitalExchange_        = finalCapitalExchange;

            init(paymentConvention1, paymentConvention2);
        }
예제 #8
0
        public FloatFloatSwap(VanillaSwap.Type type,
                              double nominal1,
                              double nominal2,
                              Schedule schedule1,
                              InterestRateIndex index1,
                              DayCounter dayCount1,
                              Schedule schedule2,
                              InterestRateIndex index2,
                              DayCounter dayCount2,
                              bool intermediateCapitalExchange = false,
                              bool finalCapitalExchange        = false,
                              double gearing1     = 1.0,
                              double spread1      = 0.0,
                              double?cappedRate1  = null,
                              double?flooredRate1 = null,
                              double gearing2     = 1.0,
                              double spread2      = 0.0,
                              double?cappedRate2  = null,
                              double?flooredRate2 = null,
                              BusinessDayConvention?paymentConvention1 = null,
                              BusinessDayConvention?paymentConvention2 = null)
            : base(2)
        {
            type_         = type;
            nominal1_     = new InitializedList <double> (schedule1.size() - 1, nominal1);
            nominal2_     = new InitializedList <double> (schedule2.size() - 1, nominal2);
            schedule1_    = schedule1;
            schedule2_    = schedule2;
            index1_       = index1;
            index2_       = index2;
            gearing1_     = new InitializedList <double>(schedule1.size() - 1, gearing1);
            gearing2_     = new InitializedList <double>(schedule2.size() - 1, gearing2);
            spread1_      = new InitializedList <double>(schedule1.size() - 1, spread1);
            spread2_      = new InitializedList <double>(schedule2.size() - 1, spread2);
            cappedRate1_  = new InitializedList <double?>(schedule1.size() - 1, cappedRate1);
            flooredRate1_ = new InitializedList <double?>(schedule1.size() - 1, flooredRate1);
            cappedRate2_  = new InitializedList <double?>(schedule2.size() - 1, cappedRate2);
            flooredRate2_ = new InitializedList <double?>(schedule2.size() - 1, flooredRate2);
            dayCount1_    = dayCount1; dayCount2_ = dayCount2;
            intermediateCapitalExchange_ = intermediateCapitalExchange;
            finalCapitalExchange_        = finalCapitalExchange;

            init(paymentConvention1, paymentConvention2);
        }
예제 #9
0
 // Factory - for Leg generators
 public override CashFlow factory(double nominal, Date paymentDate, Date startDate, Date endDate, int fixingDays, InterestRateIndex index, double gearing, double spread, double? cap, double? floor, Date refPeriodStart, Date refPeriodEnd, DayCounter dayCounter, bool isInArrears)
 {
    return new CappedFlooredCmsCoupon(nominal, paymentDate, startDate, endDate, fixingDays, (SwapIndex)index, gearing, spread, cap, floor, refPeriodStart, refPeriodEnd, dayCounter, isInArrears);
 }
예제 #10
0
 // Factory - for Leg generators
 public virtual CashFlow factory(double nominal, Date paymentDate, Date startDate, Date endDate, int fixingDays, InterestRateIndex index, double gearing, double spread, double? cap, double? floor, Date refPeriodStart, Date refPeriodEnd, DayCounter dayCounter, bool isInArrears)
 {
    return new CappedFlooredCoupon(new FloatingRateCoupon(nominal, paymentDate, startDate, endDate, fixingDays, index, gearing, spread, refPeriodStart, refPeriodEnd, dayCounter, isInArrears), cap, floor);
 }
예제 #11
0
 // Factory - for Leg generators
 public virtual CashFlow factory(double nominal, Date paymentDate, Date startDate, Date endDate, int fixingDays, InterestRateIndex index, double gearing, double spread, double?cap, double?floor, Date refPeriodStart, Date refPeriodEnd, DayCounter dayCounter, bool isInArrears)
 {
     return(new CappedFlooredCoupon(new IborCoupon(paymentDate, nominal, startDate, endDate, fixingDays, (IborIndex )index, gearing, spread, refPeriodStart, refPeriodEnd, dayCounter, isInArrears), cap, floor));
 }