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


C# DayCounter.yearFraction方法代码示例

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


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

示例1: FuturesRateHelper

        // overloaded constructors
        public FuturesRateHelper(double price, Date immDate, int nMonths, Calendar calendar, BusinessDayConvention convention,
            bool endOfMonth, DayCounter dayCounter, double convAdj)
            : base(price)
        {
            convAdj_ = new Handle<Quote>(new SimpleQuote(convAdj));

            if (!IMM.isIMMdate(immDate, false)) throw new ArgumentException(immDate + "is not a valid IMM date");
            earliestDate_ = immDate;

            latestDate_ = calendar.advance(immDate, new Period(nMonths, TimeUnit.Months), convention, endOfMonth);
            yearFraction_ = dayCounter.yearFraction(earliestDate_, latestDate_);
        }
开发者ID:StreetConnect,项目名称:QLNet,代码行数:13,代码来源:FuturesRateHelper.cs

示例2: equivalentRate

 public InterestRate equivalentRate(Date d1, Date d2, DayCounter resultDC, Compounding comp, Frequency freq)
 {
     if (!(d2 > d1)) throw new ArgumentException("d1 (" + d1 + ") " +
                                                 "later than or equal to d2 (" + d2 + ")");
     double t1 = dc_.yearFraction(d1, d2);
     double t2 = resultDC.yearFraction(d1, d2);
     return impliedRate(compoundFactor(t1), t2, resultDC, comp, freq);
 }
开发者ID:ammachado,项目名称:QLNet,代码行数:8,代码来源:InterestRate.cs

示例3: impliedRate

 public static InterestRate impliedRate(double compound, Date d1, Date d2,
     DayCounter resultDC, Compounding comp, Frequency freq)
 {
     if (!(d2 > d1))
         throw new ArgumentException("d1 (" + d1 + ") " + "later than or equal to d2 (" + d2 + ")");
     double t = resultDC.yearFraction(d1, d2);
     return impliedRate(compound, t, resultDC, comp, freq);
 }
开发者ID:ammachado,项目名称:QLNet,代码行数:8,代码来源:InterestRate.cs

示例4: seasonalityCorrection

        protected virtual double seasonalityCorrection(double rate, Date atDate, DayCounter dc,
            Date curveBaseDate, bool isZeroRate)
        {
            // need _two_ corrections in order to get: seasonality = factor[atDate-seasonalityBase] / factor[reference-seasonalityBase]
             // i.e. for ZERO inflation rates you have the true fixing at the curve base so this factor must be normalized to one
             //      for YoY inflation rates your reference point is the year before

             double factorAt = this.seasonalityFactor(atDate);

             //Getting seasonality correction for either ZC or YoY
             double f;
             if (isZeroRate)
             {
            double factorBase = this.seasonalityFactor(curveBaseDate);
            double seasonalityAt = factorAt / factorBase;
            double timeFromCurveBase = dc.yearFraction(curveBaseDate, atDate);
            f = Math.Pow(seasonalityAt, 1 / timeFromCurveBase);
             }
             else
             {
            double factor1Ybefore = this.seasonalityFactor(atDate - new Period(1, TimeUnit.Years));
            f = factorAt / factor1Ybefore;
             }

             return (rate + 1) * f - 1;
        }
开发者ID:vdt,项目名称:QLNet,代码行数:26,代码来源:Seasonality.cs

示例5: impliedYield

 /*! Simple yield calculation based on underlying spot and
 forward values, taking into account underlying income.
 When \f$ t>0 \f$, call with:
 underlyingSpotValue=spotValue(t),
 forwardValue=strikePrice, to get current yield. For a
 repo, if \f$ t=0 \f$, impliedYield should reproduce the
 spot repo rate. For FRA's, this should reproduce the
 relevant zero rate at the FRA's maturityDate_;
 */
 public InterestRate impliedYield(double underlyingSpotValue, double forwardValue, Date settlementDate,
     Compounding compoundingConvention, DayCounter dayCounter)
 {
     double tenor = dayCounter.yearFraction(settlementDate,maturityDate_) ;
     double compoundingFactor = forwardValue/ (underlyingSpotValue-spotIncome(incomeDiscountCurve_)) ;
     return InterestRate.impliedRate(compoundingFactor,
                                     tenor,
                                     dayCounter,
                                     compoundingConvention);
 }
开发者ID:ammachado,项目名称:QLNet,代码行数:19,代码来源:forward.cs


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