本文整理匯總了C#中QLNet.Period.units方法的典型用法代碼示例。如果您正苦於以下問題:C# Period.units方法的具體用法?C# Period.units怎麽用?C# Period.units使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類QLNet.Period
的用法示例。
在下文中一共展示了Period.units方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: eurliborEOM
public static bool eurliborEOM(Period p) {
switch (p.units()) {
case TimeUnit.Days:
case TimeUnit.Weeks:
return false;
case TimeUnit.Months:
case TimeUnit.Years:
return true;
default:
throw new ArgumentException("Unknown TimeUnit: " + p.units());
}
}
示例2: eurliborConvention
public static BusinessDayConvention eurliborConvention(Period p) {
switch (p.units()) {
case TimeUnit.Days:
case TimeUnit.Weeks:
return BusinessDayConvention.Following;
case TimeUnit.Months:
case TimeUnit.Years:
return BusinessDayConvention.ModifiedFollowing;
default:
throw new ArgumentException("Unknown TimeUnit: " + p.units());
}
}
示例3: shiborConvention
private static BusinessDayConvention shiborConvention(Period p)
{
switch (p.units()) {
case TimeUnit.Days:
case TimeUnit.Weeks:
return BusinessDayConvention.Following;
case TimeUnit.Months:
case TimeUnit.Years:
return BusinessDayConvention.ModifiedFollowing;
default:
Utils.QL_FAIL("invalid time units");
return BusinessDayConvention.Unadjusted;
}
}
示例4: daysMinMax
KeyValuePair<int, int> daysMinMax(Period p)
{
switch (p.units()) {
case TimeUnit.Days:
return new KeyValuePair<int, int>(p.length(), p.length());
case TimeUnit.Weeks:
return new KeyValuePair<int, int>(7*p.length(), 7*p.length());
case TimeUnit.Months:
return new KeyValuePair<int, int>(28*p.length(), 31*p.length());
case TimeUnit.Years:
return new KeyValuePair<int, int>(365 * p.length(), 366 * p.length());
default:
throw new ApplicationException("unknown time unit (" + p.units() + ")");
}
}
示例5: pair
public pair(Period p)
{
switch (p.units()) {
case TimeUnit.Days:
lo = hi = p.length(); break;
case TimeUnit.Weeks:
lo = hi = 7 * p.length(); break;
case TimeUnit.Months:
lo = 28 * p.length(); hi = 31 * p.length(); break;
case TimeUnit.Years:
lo = 365 * p.length(); hi = 366 * p.length(); break;
default:
throw new ArgumentException("Unknown TimeUnit: " + p.units());
}
}
示例6: liborEOM
public static bool liborEOM(Period p) {
switch (p.units()) {
case TimeUnit.Days:
case TimeUnit.Weeks:
return false;
case TimeUnit.Months:
case TimeUnit.Years:
return true;
default:
throw new ApplicationException("invalid time units");
}
}
示例7: liborConvention
public static BusinessDayConvention liborConvention(Period p) {
switch (p.units()) {
case TimeUnit.Days:
case TimeUnit.Weeks:
return BusinessDayConvention.Following;
case TimeUnit.Months:
case TimeUnit.Years:
return BusinessDayConvention.ModifiedFollowing;
default:
throw new ApplicationException("invalid time units");
}
}
示例8: seasonalityFactor
//! The factor returned is NOT normalized relative to ANYTHING.
public virtual double seasonalityFactor(Date to)
{
Date from = seasonalityBaseDate();
Frequency factorFrequency = frequency();
int nFactors = seasonalityFactors().Count;
Period factorPeriod = new Period(factorFrequency);
int which = 0;
if (from==to)
{
which = 0;
}
else
{
// days, weeks, months, years are the only time unit possibilities
int diffDays = Math.Abs(to - from); // in days
int dir = 1;
if(from > to)dir = -1;
int diff;
if (factorPeriod.units() == TimeUnit.Days)
{
diff = dir*diffDays;
}
else if (factorPeriod.units() == TimeUnit.Weeks)
{
diff = dir * (diffDays / 7);
}
else if (factorPeriod.units() == TimeUnit.Months)
{
KeyValuePair<Date,Date> lim = Utils.inflationPeriod(to, factorFrequency);
diff = diffDays / (31*factorPeriod.length());
Date go = from + dir*diff*factorPeriod;
while ( !(lim.Key <= go && go <= lim.Value) )
{
go += dir*factorPeriod;
diff++;
}
diff=dir*diff;
}
else if (factorPeriod.units() == TimeUnit.Years)
{
throw new ApplicationException(
"seasonality period time unit is not allowed to be : " + factorPeriod.units());
}
else
{
throw new ApplicationException("Unknown time unit: " + factorPeriod.units());
}
// now adjust to the available number of factors, direction dependent
if (dir==1)
{
which = diff % nFactors;
}
else
{
which = (nFactors - (-diff % nFactors)) % nFactors;
}
}
return seasonalityFactors()[which];
}
示例9: swapLength
//! implements the conversion between swap tenor and swap (time) length
public double swapLength(Period swapTenor)
{
Utils.QL_REQUIRE(swapTenor.length() > 0, "non-positive swap tenor (" + swapTenor + ") given");
switch (swapTenor.units())
{
case TimeUnit.Months:
return swapTenor.length() / 12.0;
case TimeUnit.Years:
return swapTenor.length();
default:
Utils.QL_FAIL("invalid Time Unit (" + swapTenor.units() + ") for swap length");
return 0;
}
}
示例10: advance
public Date advance(Date d, Period p, BusinessDayConvention c, bool endOfMonth)
{
return advance(d, p.length(), p.units(), c, endOfMonth);
}
示例11: advance
/// <summary>
/// Advances the given date as specified by the given period and
/// returns the result.
/// </summary>
/// <remarks>The input date is not modified.</remarks>
public Date advance( Date d, Period p, BusinessDayConvention c = BusinessDayConvention.Following, bool endOfMonth = false)
{
return advance(d, p.length(), p.units(), c, endOfMonth);
}