本文整理汇总了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_);
}
示例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);
}
示例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);
}
示例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;
}
示例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);
}