当前位置: 首页>>代码示例>>C#>>正文


C# Calendar.adjust方法代码示例

本文整理汇总了C#中QLNet.Calendar.adjust方法的典型用法代码示例。如果您正苦于以下问题:C# Calendar.adjust方法的具体用法?C# Calendar.adjust怎么用?C# Calendar.adjust使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QLNet.Calendar的用法示例。


在下文中一共展示了Calendar.adjust方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CommonVars

         // todo
         // cleanup
         // SavedSettings backup;

         // setup
         public CommonVars()
         {
            calendar = new TARGET();
            today = calendar.adjust(Date.Today);
            Settings.setEvaluationDate(today);
            faceAmount = 1000000.0;
         }
开发者ID:minikie,项目名称:OTCDerivativesCalculatorModule,代码行数:12,代码来源:T_Bonds.cs

示例2: Forward

		//protected Forward(DayCounter dayCounter, Calendar calendar, BusinessDayConvention businessDayConvention,
		//                  int settlementDays, Payoff payoff, Date valueDate, Date maturityDate,
		//                  Handle<YieldTermStructure> discountCurve = Handle<YieldTermStructure>()) {
		protected Forward(DayCounter dayCounter, Calendar calendar, BusinessDayConvention businessDayConvention,
						  int settlementDays, Payoff payoff, Date valueDate, Date maturityDate,
						  Handle<YieldTermStructure> discountCurve) {
			dayCounter_ = dayCounter;
			calendar_ = calendar;
			businessDayConvention_ = businessDayConvention;
			settlementDays_ = settlementDays;
			payoff_ = payoff;
			valueDate_ = valueDate;
			maturityDate_ = maturityDate;
			discountCurve_ = discountCurve;

			maturityDate_ = calendar_.adjust(maturityDate_, businessDayConvention_);

			Settings.registerWith(update);
			discountCurve_.registerWith(update);
		}
开发者ID:minikie,项目名称:OTCDerivativesCalculatorModule,代码行数:20,代码来源:forward.cs

示例3: CommonVars

            // setup
            public CommonVars()
            {
                // option variables
                nominals = new List<double>{1000000};
                frequency = Frequency.Annual;
                // usual setup
                calendar = new UnitedKingdom();
                convention = BusinessDayConvention.ModifiedFollowing;
                Date today = new Date(13, Month.August, 2007);
                evaluationDate = calendar.adjust(today);
                Settings.setEvaluationDate(evaluationDate);
                settlementDays = 0;
                fixingDays = 0;
                settlement = calendar.advance(today,settlementDays,TimeUnit.Days);
                dc = new Thirty360();

                // yoy index
                //      fixing data
                Date from = new Date(1, Month.January, 2005);
                Date to = new Date(13, Month.August, 2007);
                Schedule rpiSchedule = new MakeSchedule().from(from).to(to)
                .withConvention(BusinessDayConvention.ModifiedFollowing)
                .withCalendar(new UnitedKingdom())
                .withTenor(new Period(1,TimeUnit.Months)).value();
                double[] fixData = { 189.9, 189.9, 189.6, 190.5, 191.6, 192.0,
                        192.2, 192.2, 192.6, 193.1, 193.3, 193.6,
                        194.1, 193.4, 194.2, 195.0, 196.5, 197.7,
                        198.5, 198.5, 199.2, 200.1, 200.4, 201.1,
                        202.7, 201.6, 203.1, 204.4, 205.4, 206.2,
                        207.3, -999.0, -999 };
                // link from yoy index to yoy TS
                bool interp = false;
                iir = new YYUKRPIr(interp, hy);
                for (int i=0; i<rpiSchedule.Count;i++)
                {
                        iir.addFixing(rpiSchedule[i], fixData[i]);
                }

                YieldTermStructure nominalFF = new FlatForward(evaluationDate, 0.05, new ActualActual());
                nominalTS.linkTo(nominalFF);

                // now build the YoY inflation curve
                Period observationLag = new Period(2,TimeUnit.Months);

                Datum[] yyData =  {
                        new Datum( new Date(13, Month.August, 2008), 2.95 ),
                        new Datum( new Date(13, Month.August, 2009), 2.95 ),
                        new Datum( new Date(13, Month.August, 2010), 2.93 ),
                        new Datum( new Date(15, Month.August, 2011), 2.955 ),
                        new Datum( new Date(13, Month.August, 2012), 2.945 ),
                        new Datum( new Date(13, Month.August, 2013), 2.985 ),
                        new Datum( new Date(13, Month.August, 2014), 3.01 ),
                        new Datum( new Date(13, Month.August, 2015), 3.035 ),
                        new Datum( new Date(13, Month.August, 2016), 3.055 ),  // note that
                        new Datum( new Date(13, Month.August, 2017), 3.075 ),  // some dates will be on
                        new Datum( new Date(13, Month.August, 2019), 3.105 ),  // holidays but the payment
                        new Datum( new Date(15, Month.August, 2022), 3.135 ),  // calendar will roll them
                        new Datum( new Date(13, Month.August, 2027), 3.155 ),
                        new Datum( new Date(13, Month.August, 2032), 3.145 ),
                        new Datum( new Date(13, Month.August, 2037), 3.145 )
                };

                // now build the helpers ...
                List<BootstrapHelper<YoYInflationTermStructure>> helpers =
                makeHelpers(yyData, yyData.Length, iir,
                                            observationLag,
                                            calendar, convention, dc);

                double baseYYRate = yyData[0].rate/100.0;
                PiecewiseYoYInflationCurve<Linear>  pYYTS =
                        new PiecewiseYoYInflationCurve<Linear>(
                                evaluationDate, calendar, dc, observationLag,
                                iir.frequency(),iir.interpolated(), baseYYRate,
                                new Handle<YieldTermStructure>(nominalTS), helpers);
                pYYTS.recalculate();
                yoyTS = pYYTS as YoYInflationTermStructure;

                // make sure that the index has the latest yoy term structure
                hy.linkTo(pYYTS);
            }
开发者ID:Yenyenx,项目名称:qlnet,代码行数:81,代码来源:T_InflationCapFloorTest.cs

示例4: CommonVars

            public CommonVars()
            {
                settlementDays = 2;
                nominal = 1000000.0;
                fixedConvention = BusinessDayConvention.Unadjusted;

                fixedFrequency = Frequency.Annual;
                fixedDayCount = new Thirty360();

                index =new Euribor6M(termStructure);
                floatingConvention = index.businessDayConvention();
                floatingTenor = index.tenor();
                calendar = index.fixingCalendar();
                today = calendar.adjust(Date.Today);
                Settings.setEvaluationDate(today);
                settlement = calendar.advance(today, settlementDays, TimeUnit.Days);

                termStructure.linkTo(Utilities.flatRate(settlement, 0.05, new Actual365Fixed()));
            }
开发者ID:akasolace,项目名称:qlnet,代码行数:19,代码来源:T_Swaption.cs

示例5: CommonVars

            // cleanup
            // SavedSettings backup;
            // setup
            public CommonVars()
            {
                calendar = new TARGET();
                settlementDays = 2;
                Date today = calendar.adjust(Date.Today);
                Settings.setEvaluationDate(today);
                Date settlement = calendar.advance(today, settlementDays, TimeUnit.Days);

                int deposits = depositData.Length,
                swaps = swapData.Length;

                var instruments = new List<RateHelper>(deposits + swaps);
                for (int i = 0; i < deposits; i++)
                {
                   instruments.Add(new DepositRateHelper(depositData[i].rate / 100, new Period(depositData[i].n, depositData[i].units),
                               settlementDays, calendar, BusinessDayConvention.ModifiedFollowing, true, new Actual360()));
                }

                IborIndex index = new IborIndex("dummy", new Period(6, TimeUnit.Months), settlementDays, new Currency(),
                                            calendar, BusinessDayConvention.ModifiedFollowing, false, new Actual360());
                for (int i = 0; i < swaps; ++i)
                {
                   instruments.Add(new SwapRateHelper(swapData[i].rate / 100, new Period(swapData[i].n, swapData[i].units),
                               calendar, Frequency.Annual, BusinessDayConvention.Unadjusted, new Thirty360(), index));
                }
                termStructure = new PiecewiseYieldCurve<Discount, LogLinear>(settlement, instruments, new Actual360());
                dummyTermStructure = new PiecewiseYieldCurve<Discount, LogLinear>(settlement, instruments, new Actual360());
            }
开发者ID:akasolace,项目名称:qlnet,代码行数:31,代码来源:T_TermStructures.cs

示例6: CommonVars

            // setup
            public CommonVars()
            {
                startYears = 1;
                length = 5;
                type = VanillaSwap.Type.Payer;
                nominal = 1000.0;
                settlementDays = 2;
                fixedConvention = BusinessDayConvention.Unadjusted;
                floatingConvention = BusinessDayConvention.ModifiedFollowing;
                fixedFrequency = Frequency.Annual;
                floatingFrequency = Frequency.Semiannual;
                fixedDayCount = new Thirty360();

                termStructure = new RelinkableHandle<YieldTermStructure>();
                termStructure.linkTo(Utilities.flatRate(new Date(19, Month.February, 2002), 0.04875825, new Actual365Fixed()));

                index = new Euribor6M(termStructure);
                calendar = index.fixingCalendar();
                today = calendar.adjust(Date.Today);
                settlement = calendar.advance(today, settlementDays, TimeUnit.Days);
            }
开发者ID:Yenyenx,项目名称:qlnet,代码行数:22,代码来源:T_Bermudanswaption.cs

示例7: CommonVars

            public CommonVars()
            {
                type = VanillaSwap.Type.Payer;
                settlementDays = 2;
                nominal = 100.0;
                fixedConvention = BusinessDayConvention.Unadjusted;
                floatingConvention = BusinessDayConvention.ModifiedFollowing;
                fixedFrequency = Frequency.Annual;
                floatingFrequency = Frequency.Semiannual;
                fixedDayCount = new Thirty360();

                index = new Euribor(new Period(floatingFrequency), termStructure);

                calendar = index.fixingCalendar();
                today = calendar.adjust(Date.Today);
                Settings.setEvaluationDate(today);
                settlement = calendar.advance(today, settlementDays, TimeUnit.Days);

                termStructure.linkTo(Utilities.flatRate(settlement, 0.05, new Actual365Fixed()));
            }
开发者ID:Yenyenx,项目名称:qlnet,代码行数:20,代码来源:T_Swaps.cs

示例8: Schedule


//.........这里部分代码省略.........
         Date seed = new Date() , exitDate;
         switch (rule_)
         {
            case DateGeneration.Rule.Zero:
               tenor_ = new Period(0, TimeUnit.Years);
               dates_.Add(effectiveDate);
               dates_.Add(terminationDate);
               isRegular_.Add(true);
               break;

            case DateGeneration.Rule.Backward:
               dates_.Add(terminationDate);

               seed = terminationDate;
               if (nextToLastDate_ != null)
               {
                  dates_.Insert(0, nextToLastDate_);
                  Date temp = nullCalendar.advance(seed, -periods * tenor_, convention_, endOfMonth_);
                  if (temp != nextToLastDate_)
                     isRegular_.Insert(0, false);
                  else
                     isRegular_.Insert(0, true);
                  seed = nextToLastDate_;
               }
               exitDate = effectiveDate;
               if (firstDate_ != null)
                  exitDate = firstDate_;

               while (true)
               {
                  Date temp = nullCalendar.advance(seed, -periods * tenor_, convention_, endOfMonth_);
                  if (temp < exitDate)
                  {
                     if (firstDate_ != null && (calendar_.adjust(dates_.First(), convention_) !=
                          calendar_.adjust(firstDate_, convention_)))
                     {
                        dates_.Insert(0, firstDate_);
                        isRegular_.Insert(0, false);
                     }
                     break;
                  }
                  else
                  {
                     // skip dates that would result in duplicates
                     // after adjustment
                     if (calendar_.adjust(dates_.First(), convention_) != calendar_.adjust(temp, convention_))
                     {
                        dates_.Insert(0, temp);
                        isRegular_.Insert(0, true);
                     }
                     ++periods;
                  }
               }

               if (calendar_.adjust(dates_.First(), convention) != calendar_.adjust(effectiveDate, convention))
               {
                  dates_.Insert(0, effectiveDate);
                  isRegular_.Insert(0, false);
               }

               break;

            case DateGeneration.Rule.Twentieth:
            case DateGeneration.Rule.TwentiethIMM:
            case DateGeneration.Rule.ThirdWednesday:
            case DateGeneration.Rule.OldCDS:
开发者ID:minikie,项目名称:OTCDerivativesCalculatorModule,代码行数:67,代码来源:Schedule.cs

示例9: setConventions

 public void setConventions()
 {
     calendar = new TARGET();
     Date today = calendar.adjust(Date.Today);
     Settings.setEvaluationDate(today);
     optionBdc = BusinessDayConvention.ModifiedFollowing;
     dayCounter = new  Actual365Fixed();
 }
开发者ID:akasolace,项目名称:qlnet,代码行数:8,代码来源:T_SwaptionVolatilitymatrix.cs

示例10: CommonVars

 // setup
 public CommonVars()
 {
     nominals = new List<double>() { 100 };
     frequency = Frequency.Semiannual;
     index = (IborIndex)new Euribor6M(termStructure);
     calendar = index.fixingCalendar();
     convention = BusinessDayConvention.ModifiedFollowing;
     Date today = calendar.adjust(Date.Today);
     Settings.setEvaluationDate(today);
     int settlementDays = 2;
     fixingDays = 2;
     settlement = calendar.advance(today, settlementDays, TimeUnit.Days);
     termStructure.linkTo(Utilities.flatRate(settlement, 0.05,
                                   new ActualActual(ActualActual.Convention.ISDA)));
 }
开发者ID:tickzoom,项目名称:QLNet,代码行数:16,代码来源:T_CapFloor.cs

示例11: Schedule


//.........这里部分代码省略.........
                        throw new ArgumentException("next to last is incompatible with " + rule_ + " date generation rule");
                    default:
                        throw new ArgumentException("Unknown DateGeneration rule: " + rule_);
                }
            }

            // calendar needed for endOfMonth adjustment
            Calendar nullCalendar = new NullCalendar();
            int periods = 1;
            Date seed = new Date(), exitDate;
            switch (rule_) {
                case DateGeneration.Rule.Zero:
                    tenor_ = new Period(0, TimeUnit.Years);
                    originalDates_.Add(effectiveDate__);
                    originalDates_.Add(terminationDate__);
                    isRegular_.Add(true);
                    break;

                case DateGeneration.Rule.Backward:
                    originalDates_.Add(terminationDate__);
                    seed = terminationDate__;
                    if (nextToLastDate_ != null) {
                        originalDates_.Insert(0, nextToLastDate_);
                        Date temp = nullCalendar.advance(seed, -periods * tenor_, convention_, endOfMonth_);
                        isRegular_.Insert(0, temp == nextToLastDate_);
                        seed = nextToLastDate_;
                    }
                    exitDate = effectiveDate__;
                    if (firstDate_ != null)
                        exitDate = firstDate_;
                    while (true) {
                        Date temp = nullCalendar.advance(seed, -periods * tenor_, convention_, endOfMonth_);
                        if (temp < exitDate) {
                            if (firstDate_ != null && (calendar_.adjust(originalDates_.First(), convention_) !=
                                 calendar_.adjust(firstDate_, convention_))) {
                                originalDates_.Insert(0, firstDate_);
                                isRegular_.Insert(0, false);
                            }
                            break;
                        } else {
                            originalDates_.Insert(0, temp);
                            isRegular_.Insert(0, true);
                            ++periods;
                        }
                    }
                    if (endOfMonth_ && calendar_.isEndOfMonth(seed))
                        convention_ = BusinessDayConvention.Preceding;
                    if (calendar_.adjust(originalDates_[0], convention_) != calendar_.adjust(effectiveDate__, convention_)) {
                        originalDates_.Insert(0, effectiveDate__);
                        isRegular_.Insert(0, false);
                    }
                    break;

                case DateGeneration.Rule.Twentieth:
                case DateGeneration.Rule.TwentiethIMM:
                case DateGeneration.Rule.ThirdWednesday:
                case DateGeneration.Rule.OldCDS:
                case DateGeneration.Rule.CDS:
                    if (endOfMonth_)
                        throw new ArgumentException("endOfMonth convention is incompatible with " + rule_ + " date generation rule");
                    goto case DateGeneration.Rule.Forward;			// fall through

                case DateGeneration.Rule.Forward:
                    if (rule_ == DateGeneration.Rule.CDS) {
                       originalDates_.Add(previousTwentieth(effectiveDate__,DateGeneration.Rule.CDS));
                    } else {
开发者ID:ammachado,项目名称:QLNet,代码行数:67,代码来源:Schedule.cs


注:本文中的QLNet.Calendar.adjust方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。