當前位置: 首頁>>代碼示例>>C#>>正文


C# Schedule.businessDayConvention方法代碼示例

本文整理匯總了C#中QLNet.Schedule.businessDayConvention方法的典型用法代碼示例。如果您正苦於以下問題:C# Schedule.businessDayConvention方法的具體用法?C# Schedule.businessDayConvention怎麽用?C# Schedule.businessDayConvention使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在QLNet.Schedule的用法示例。


在下文中一共展示了Schedule.businessDayConvention方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: BasisSwap

      public BasisSwap(Type type, double nominal,
                         Schedule float1Schedule, IborIndex iborIndex1, double spread1, DayCounter float1DayCount,
                         Schedule float2Schedule, IborIndex iborIndex2, double spread2, DayCounter float2DayCount,
                         BusinessDayConvention? paymentConvention) :
         base(2)
      {
         type_ = type;
         nominal_ = nominal;
         floating1Schedule_ = float1Schedule;
         spread1_ = spread1;
         floating1DayCount_ = float1DayCount;
         iborIndex1_ = iborIndex1;
         floating2Schedule_ = float2Schedule;
         spread2_ = spread2;
         floating2DayCount_ = float2DayCount;
         iborIndex2_ = iborIndex2;

         if (paymentConvention.HasValue)
            paymentConvention_ = paymentConvention.Value;
         else
            paymentConvention_ = floating1Schedule_.businessDayConvention();

         List<CashFlow> floating1Leg = new IborLeg(float1Schedule, iborIndex1)
                                     .withPaymentDayCounter(float1DayCount)
                                     .withSpreads(spread1)
                                     .withNotionals(nominal)
                                     .withPaymentAdjustment(paymentConvention_);

         List<CashFlow> floating2Leg = new IborLeg(float2Schedule, iborIndex2)
                                     .withPaymentDayCounter(float2DayCount)
                                     .withSpreads(spread2)
                                     .withNotionals(nominal)
                                     .withPaymentAdjustment(paymentConvention_);

         foreach (var cf in floating1Leg)
            cf.registerWith(update);
         foreach (var cf in floating2Leg)
            cf.registerWith(update);


         legs_[0] = floating1Leg;
         legs_[1] = floating2Leg;
         if (type_ == Type.Payer)
         {
            payer_[0] = -1;
            payer_[1] = +1;
         }
         else
         {
            payer_[0] = +1;
            payer_[1] = -1;
         }
      }
開發者ID:minikie,項目名稱:OTCDerivativesCalculatorModule,代碼行數:53,代碼來源:BasisSwap.cs

示例2: FloatingLoan

        public FloatingLoan(Type type, double nominal,
            Schedule floatingSchedule, double floatingSpread, DayCounter floatingDayCount,
            Schedule principalSchedule, BusinessDayConvention? paymentConvention, IborIndex index)
            : base(2)
        {
            type_ = type;
            nominal_ = nominal;
            floatingSchedule_ = floatingSchedule;
            floatingSpread_ = floatingSpread;
            floatingDayCount_ = floatingDayCount;
            principalSchedule_ = principalSchedule;
            iborIndex_ = index;

            if (paymentConvention.HasValue)
                paymentConvention_ = paymentConvention.Value;
            else
                paymentConvention_ = floatingSchedule_.businessDayConvention();

            List<CashFlow> principalLeg = new PricipalLeg(principalSchedule, floatingDayCount)
                .withNotionals(nominal)
                .withPaymentAdjustment(paymentConvention_)
                .withSign(type == Type.Loan ? -1 : 1);

            // temporary
            for (int i = 0; i < principalLeg.Count - 1; i++)
            {
                Principal p = (Principal)principalLeg[i];
                notionals_.Add(p.nominal());
            }

            List<CashFlow> floatingLeg = new IborLeg(floatingSchedule, iborIndex_)
                .withPaymentDayCounter(floatingDayCount_)
                .withSpreads(floatingSpread_)
                .withPaymentAdjustment(paymentConvention_)
                .withNotionals(notionals_);

            legs_[0] = floatingLeg;
            legs_[1] = principalLeg;
            if (type_ == Type.Loan)
            {
                payer_[0] = -1;
                payer_[1] = +1;
            }
            else
            {
                payer_[0] = +1;
                payer_[1] = -1;
            }
        }
開發者ID:ammachado,項目名稱:QLNet,代碼行數:49,代碼來源:FloatingLoan.cs

示例3: FixedLoan

        public FixedLoan(Type type, double nominal, Schedule fixedSchedule, double fixedRate, DayCounter fixedDayCount, Schedule principalSchedule, BusinessDayConvention? paymentConvention)
            : base(2)
        {
            type_ = type;
            nominal_ = nominal;
            fixedSchedule_ = fixedSchedule;
            fixedRate_ = fixedRate;
            fixedDayCount_ = fixedDayCount;
            principalSchedule_ = principalSchedule;

            if (paymentConvention.HasValue)
                paymentConvention_ = paymentConvention.Value;
            else
                paymentConvention_ = fixedSchedule_.businessDayConvention();

            List<CashFlow> principalLeg = new PricipalLeg(principalSchedule, fixedDayCount)
                .withNotionals(nominal)
                .withPaymentAdjustment(paymentConvention_)
                .withSign(type == Type.Loan ? -1 : 1);

            // temporary
            for (int i = 0; i < principalLeg.Count - 1; i++)
            {
                Principal p = (Principal)principalLeg[i];
                notionals_.Add(p.nominal());
            }

            List<CashFlow> fixedLeg = new FixedRateLeg(fixedSchedule)
                .withCouponRates(fixedRate, fixedDayCount)
                .withPaymentAdjustment(paymentConvention_)
                .withNotionals(notionals_);

            legs_[0] = fixedLeg;
            legs_[1] = principalLeg;
            if (type_ == Type.Loan)
            {
                payer_[0] = +1;
                payer_[1] = -1;
            }
            else
            {
                payer_[0] = -1;
                payer_[1] = +1;
            }
        }
開發者ID:vdt,項目名稱:QLNet,代碼行數:45,代碼來源:FixedLoan.cs

示例4: BMASwap

        public BMASwap(Type type, double nominal,
                // Libor leg
                Schedule liborSchedule, double liborFraction, double liborSpread, IborIndex liborIndex, DayCounter liborDayCount,
                // BMA leg
                Schedule bmaSchedule, BMAIndex bmaIndex, DayCounter bmaDayCount)
            : base(2)
        {
            type_ = type;
            nominal_ = nominal;
            liborFraction_ = liborFraction;
            liborSpread_ = liborSpread;

            BusinessDayConvention convention = liborSchedule.businessDayConvention();

            legs_[0] = new IborLeg(liborSchedule, liborIndex)
                        .withPaymentDayCounter(liborDayCount)
                        .withFixingDays(liborIndex.fixingDays())
                        .withGearings(liborFraction)
                        .withSpreads(liborSpread)
                        .withNotionals(nominal)
                        .withPaymentAdjustment(convention);

            legs_[1] = new AverageBMALeg(bmaSchedule, bmaIndex)
                        .withPaymentDayCounter(bmaDayCount)
                        .withNotionals(nominal)
                        .withPaymentAdjustment(bmaSchedule.businessDayConvention());

            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 BMA-swap type");
            }
        }
開發者ID:Yenyenx,項目名稱:qlnet,代碼行數:45,代碼來源:bmaswap.cs

示例5: testBondFromScheduleWithDateVector

        public void testBondFromScheduleWithDateVector()
        {
            // Testing South African R2048 bond price using Schedule constructor with Date vector
             SavedSettings backup = new SavedSettings();

             //When pricing bond from Yield To Maturity, use NullCalendar()
             Calendar calendar = new NullCalendar();

             int settlementDays = 3;

             Date issueDate = new Date(29, Month.June, 2012);
             Date today = new Date(7, Month.September, 2015);
             Date evaluationDate = calendar.adjust(today);
             Date settlementDate = calendar.advance(evaluationDate, new Period(settlementDays, TimeUnit.Days));
             Settings.setEvaluationDate(evaluationDate);

             // For the schedule to generate correctly for Feb-28's, make maturity date on Feb 29
             Date maturityDate = new Date(29, Month.February, 2048);

             double coupon = 0.0875;
             Compounding comp = Compounding.Compounded;
             Frequency freq = Frequency.Semiannual;
             DayCounter dc = new ActualActual(ActualActual.Convention.Bond);

             // Yield as quoted in market
             InterestRate yield = new InterestRate(0.09185, dc, comp, freq);

             Period tenor = new Period(6, TimeUnit.Months);
             Period exCouponPeriod = new Period(10, TimeUnit.Days);

             // Generate coupon dates for 31 Aug and end of Feb each year
             // For leap years, this will generate 29 Feb, but the bond
             // actually pays coupons on 28 Feb, regardsless of whether
             // it is a leap year or not.
             Schedule schedule = new Schedule(issueDate, maturityDate, tenor,
            new NullCalendar(), BusinessDayConvention.Unadjusted, BusinessDayConvention.Unadjusted,
            DateGeneration.Rule.Backward, true);

             // Adjust the 29 Feb's to 28 Feb
             List<Date> dates = new List<Date>();
             for (int i = 0; i < schedule.Count; ++i)
             {
            Date d = schedule.date(i);
            if (d.Month == 2 && d.Day == 29)
               dates.Add(new Date(28, Month.February, d.Year));
            else
               dates.Add(d);
             }

             schedule = new Schedule(dates,
                                 schedule.calendar(),
                                 schedule.businessDayConvention(),
                                 schedule.terminationDateBusinessDayConvention(),
                                 schedule.tenor(),
                                 schedule.rule(),
                                 schedule.endOfMonth(),
                                 schedule.isRegular());

             FixedRateBond bond = new FixedRateBond(
             0,
             100.0,
             schedule,
             new List<double>() { coupon },
             dc, BusinessDayConvention.Following, 100.0,
             issueDate, calendar,
             exCouponPeriod, calendar, BusinessDayConvention.Unadjusted, false);

             double calculatedPrice = BondFunctions.dirtyPrice(bond, yield, settlementDate);
             double expectedPrice = 95.75706;
             double tolerance = 1e-5;
             if (Math.Abs(calculatedPrice - expectedPrice) > tolerance)
             {
            Assert.Fail(string.Format("failed to reproduce R2048 dirty price\nexpected: {0}\ncalculated: {1}", expectedPrice, calculatedPrice));
             }
        }
開發者ID:akasolace,項目名稱:qlnet,代碼行數:75,代碼來源:T_Bonds.cs

示例6: VanillaSwap

        // constructor
        public VanillaSwap(Type type, double nominal,
                         Schedule fixedSchedule, double fixedRate, DayCounter fixedDayCount,
                         Schedule floatSchedule, IborIndex iborIndex, double spread, DayCounter floatingDayCount,
                         BusinessDayConvention? paymentConvention = null)
            : base(2)
        {
            type_ = type;
             nominal_ = nominal;
             fixedSchedule_ = fixedSchedule;
             fixedRate_ = fixedRate;
             fixedDayCount_ = fixedDayCount;
             floatingSchedule_ = floatSchedule;
             iborIndex_ = iborIndex;
             spread_ = spread;
             floatingDayCount_ = floatingDayCount;

             if (paymentConvention.HasValue)
            paymentConvention_ = paymentConvention.Value;
             else
            paymentConvention_ = floatingSchedule_.businessDayConvention();

             legs_[0] = new FixedRateLeg(fixedSchedule)
                                     .withCouponRates(fixedRate, fixedDayCount)
                                     .withPaymentAdjustment(paymentConvention_)
                                     .withNotionals(nominal);

             legs_[1] = new IborLeg(floatSchedule, iborIndex)
                                     .withPaymentDayCounter(floatingDayCount)
            //.withFixingDays(iborIndex.fixingDays())
                                     .withSpreads(spread)
                                     .withNotionals(nominal)
                                     .withPaymentAdjustment(paymentConvention_);

             foreach (var cf in legs_[1])
            cf.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 vanilla-swap type");
             }
        }
開發者ID:Yenyenx,項目名稱:qlnet,代碼行數:51,代碼來源:VanillaSwap.cs

示例7: testDateConstructor

        public void testDateConstructor()
        {
            // Testing the constructor taking a vector of dates and possibly additional meta information

             List<Date> dates = new List<Date>();
             dates.Add(new Date(16, Month.May, 2015));
             dates.Add(new Date(18, Month.May, 2015));
             dates.Add(new Date(18, Month.May, 2016));
             dates.Add(new Date(31, Month.December, 2017));

             // schedule without any additional information
             Schedule schedule1 = new Schedule(dates);
             if (schedule1.Count != dates.Count)
            Assert.Fail("schedule1 has size {0}, expected {1}", schedule1.Count, dates.Count);
             for (int i = 0; i < dates.Count; ++i)
            if (schedule1[i] != dates[i])
               Assert.Fail("schedule1 has {0} at position {1}, expected {2}", schedule1[i], i, dates[i]);
             if (schedule1.calendar() != new NullCalendar())
            Assert.Fail("schedule1 has calendar {0}, expected null calendar", schedule1.calendar().name());
             if (schedule1.businessDayConvention() != BusinessDayConvention.Unadjusted)
            Assert.Fail("schedule1 has convention {0}, expected unadjusted", schedule1.businessDayConvention());

             // schedule with metadata
             List<bool> regular = new List<bool>();
             regular.Add(false);
             regular.Add(true);
             regular.Add(false);

             Schedule schedule2 = new Schedule(dates, new TARGET(), BusinessDayConvention.Following, BusinessDayConvention.ModifiedPreceding, new Period(1, TimeUnit.Years),
                            DateGeneration.Rule.Backward, true, regular);
             for (int i = 1; i < dates.Count; ++i)
            if (schedule2.isRegular(i) != regular[i - 1])
               Assert.Fail("schedule2 has a {0} period at position {1}, expected {2}", (schedule2.isRegular(i) ? "regular" : "irregular"), i, (regular[i - 1] ? "regular" : "irregular"));
             if (schedule2.calendar() != new TARGET())
            Assert.Fail("schedule1 has calendar {0}, expected TARGET", schedule2.calendar().name());
             if (schedule2.businessDayConvention() != BusinessDayConvention.Following)
            Assert.Fail("schedule2 has convention {0}, expected Following", schedule2.businessDayConvention());
             if (schedule2.terminationDateBusinessDayConvention() != BusinessDayConvention.ModifiedPreceding)
            Assert.Fail("schedule2 has convention {0}, expected Modified Preceding", schedule2.terminationDateBusinessDayConvention());
             if (schedule2.tenor() != new Period(1, TimeUnit.Years))
            Assert.Fail("schedule2 has tenor {0}, expected 1Y", schedule2.tenor());
             if (schedule2.rule() != DateGeneration.Rule.Backward)
            Assert.Fail("schedule2 has rule {0}, expected Backward", schedule2.rule());
             if (schedule2.endOfMonth() != true)
            Assert.Fail("schedule2 has end of month flag false, expected true");
        }
開發者ID:akasolace,項目名稱:qlnet,代碼行數:46,代碼來源:T_Schedule.cs

示例8: CommercialPaper

        public CommercialPaper(Loan.Type type, double nominal, Schedule fixedSchedule, double fixedRate, DayCounter fixedDayCount, Schedule principalSchedule, BusinessDayConvention? paymentConvention)
            : base(2)
        {
            type_ = type;
            nominal_ = nominal;
            fixedSchedule_ = fixedSchedule;
            fixedRate_ = fixedRate;
            fixedDayCount_ = fixedDayCount;
            principalSchedule_ = principalSchedule;

            if (paymentConvention.HasValue)
                paymentConvention_ = paymentConvention.Value;
            else
                paymentConvention_ = fixedSchedule_.businessDayConvention();

            List<CashFlow> principalLeg = new PricipalLeg(principalSchedule, fixedDayCount)
                .withNotionals(nominal)
                .withPaymentAdjustment(paymentConvention_)
                .withSign(type == Type.Loan ? -1 : 1);

            // temporary
            for (int i = 0; i < principalLeg.Count - 1; i++)
            {
                Principal p = (Principal)principalLeg[i];
                notionals_.Add(p.nominal());
            }

            List<CashFlow> fixedLeg = new FixedRateLeg(fixedSchedule)
                .withCouponRates(fixedRate, fixedDayCount)
                .withPaymentAdjustment(paymentConvention_)
                .withNotionals(notionals_);

            // Discounting Pricipal
            notionals_.Clear();
            double n;
            for (int i = 0; i < fixedLeg.Count; i++)
            {
                FixedRateCoupon c = (FixedRateCoupon)fixedLeg[i];
                n = i > 0 ? notionals_.Last() : c.nominal();
                notionals_.Add(n / (1 + (c.rate() * c.dayCounter().yearFraction(c.refPeriodStart, c.refPeriodEnd))));
            }

            // New Leg
            List<CashFlow> discountedFixedLeg = new FixedRateLeg(fixedSchedule)
                .withCouponRates(fixedRate, fixedDayCount)
                .withPaymentAdjustment(paymentConvention_)
                .withNotionals(notionals_);
            // Adjust Principal
            Principal p0 = (Principal)principalLeg[0];
            p0.setAmount(notionals_.Last());

            legs_[0] = discountedFixedLeg;
            legs_[1] = principalLeg;
            if (type_ == Type.Loan)
            {
                payer_[0] = +1;
                payer_[1] = -1;
            }
            else
            {
                payer_[0] = -1;
                payer_[1] = +1;
            }
        }
開發者ID:ammachado,項目名稱:QLNet,代碼行數:64,代碼來源:CommercialPaper.cs

示例9: ConvertibleFloatingRateBond

      public ConvertibleFloatingRateBond( Exercise exercise,
                                          double conversionRatio,
                                          DividendSchedule dividends,
                                          CallabilitySchedule callability,
                                          Handle<Quote> creditSpread,
                                          Date issueDate,
                                          int settlementDays,
                                          IborIndex index,
                                          int fixingDays,
                                          List<double> spreads,
                                          DayCounter dayCounter,
                                          Schedule schedule,
                                          double redemption = 100)
         : base(exercise, conversionRatio, dividends, callability, creditSpread, issueDate, settlementDays, schedule, redemption) 

      {
        // !!! notional forcibly set to 100
        cashflows_ = new IborLeg(schedule, index)
                        .withPaymentDayCounter(dayCounter)
                        .withFixingDays(fixingDays)
                        .withSpreads(spreads)
                        .withNotionals(100.0)
                        .withPaymentAdjustment(schedule.businessDayConvention());

        addRedemptionsToCashflows(new List<double>{redemption});

        Utils.QL_REQUIRE( redemptions_.Count == 1, () => "multiple redemptions created" );

        option_ = new option(this, exercise, conversionRatio, dividends, callability, creditSpread, cashflows_, dayCounter, schedule,
                             issueDate, settlementDays, redemption);
    
      }
開發者ID:minikie,項目名稱:test,代碼行數:32,代碼來源:ConvertibleBond.cs

示例10: ConvertibleFixedCouponBond

      public ConvertibleFixedCouponBond( Exercise exercise,
                                         double conversionRatio,
                                         DividendSchedule dividends,
                                         CallabilitySchedule callability,
                                         Handle<Quote> creditSpread,
                                         Date issueDate,
                                         int settlementDays,
                                         List<double> coupons,
                                         DayCounter dayCounter,
                                         Schedule schedule,
                                         double redemption = 100)
         : base(exercise, conversionRatio, dividends, callability, creditSpread, issueDate, settlementDays, schedule, redemption) 
      {

        // !!! notional forcibly set to 100
        cashflows_ = new FixedRateLeg(schedule)
                           .withCouponRates(coupons, dayCounter)
                           .withNotionals(100.0)
                           .withPaymentAdjustment(schedule.businessDayConvention());

        addRedemptionsToCashflows(new List<double>(){redemption});

        Utils.QL_REQUIRE(redemptions_.Count == 1, "multiple redemptions created");

        option_ = new option(this, exercise, conversionRatio, dividends, callability, creditSpread, cashflows_, dayCounter, schedule,
                             issueDate, settlementDays, redemption);
    }
開發者ID:jrviala,項目名稱:qlnet,代碼行數:27,代碼來源:ConvertibleBond.cs


注:本文中的QLNet.Schedule.businessDayConvention方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。