本文整理汇总了C#中QLNet.DayCounter类的典型用法代码示例。如果您正苦于以下问题:C# DayCounter类的具体用法?C# DayCounter怎么用?C# DayCounter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DayCounter类属于QLNet命名空间,在下文中一共展示了DayCounter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FloatingRateCoupon
// constructors
public FloatingRateCoupon(double nominal,
Date paymentDate,
Date startDate,
Date endDate,
int fixingDays,
InterestRateIndex index,
double gearing = 1.0,
double spread = 0.0,
Date refPeriodStart = null,
Date refPeriodEnd = null,
DayCounter dayCounter = null,
bool isInArrears = false)
: base(nominal, paymentDate, startDate, endDate, refPeriodStart, refPeriodEnd)
{
index_ = index;
dayCounter_ = dayCounter == null ? new DayCounter() : dayCounter ;
fixingDays_ = fixingDays == default(int) ? index.fixingDays() : fixingDays;
gearing_ = gearing;
spread_ = spread;
isInArrears_ = isInArrears;
if (gearing_ == 0) throw new ArgumentException("Null gearing not allowed");
if (dayCounter_.empty())
dayCounter_ = index_.dayCounter();
// add as observer
index_.registerWith(update);
Settings.registerWith(update);
}
示例2: BlackConstantVol
public BlackConstantVol(int settlementDays, Calendar cal, Handle<Quote> volatility, DayCounter dc)
: base(settlementDays, cal, BusinessDayConvention.Following, dc)
{
volatility_ = volatility;
volatility_.registerWith(update);
}
示例3: TermStructure
public TermStructure(DayCounter dc)
{
moving_ = false;
updated_ = true;
settlementDays_ = default(int);
dayCounter_ = dc;
}
示例4: FixedRateBond
//! fixed-rate bond
/*! \ingroup instruments
\test calculations are tested by checking results against
cached values.
*/
//! simple annual compounding coupon rates
public FixedRateBond(int settlementDays, double faceAmount, Schedule schedule,List<double> coupons,
DayCounter accrualDayCounter, BusinessDayConvention paymentConvention = BusinessDayConvention.Following,
double redemption = 100, Date issueDate = null,Calendar paymentCalendar = null,
Period exCouponPeriod = null,
Calendar exCouponCalendar = null,
BusinessDayConvention exCouponConvention = BusinessDayConvention.Unadjusted,
bool exCouponEndOfMonth = false)
: base(settlementDays, paymentCalendar == null ? schedule.calendar() : paymentCalendar,
issueDate)
{
frequency_ = schedule.tenor().frequency();
dayCounter_ = accrualDayCounter;
maturityDate_ = schedule.endDate();
cashflows_ = new FixedRateLeg(schedule)
.withCouponRates(coupons, accrualDayCounter)
.withExCouponPeriod(exCouponPeriod,
exCouponCalendar,
exCouponConvention,
exCouponEndOfMonth)
.withPaymentCalendar(calendar_)
.withNotionals(faceAmount)
.withPaymentAdjustment(paymentConvention);
addRedemptionsToCashflows(new List<double>() { redemption });
if (cashflows().Count == 0)
throw new ApplicationException("bond with no cashflows!");
if (redemptions_.Count != 1)
throw new ApplicationException("multiple redemptions created");
}
示例5: FixedRateCoupon
// constructors
public FixedRateCoupon(double nominal, Date paymentDate, double rate, DayCounter dayCounter,
Date accrualStartDate, Date accrualEndDate,
Date refPeriodStart = null, Date refPeriodEnd = null,double? amount = null)
: base(nominal, paymentDate, accrualStartDate, accrualEndDate, refPeriodStart, refPeriodEnd, amount)
{
rate_ = new InterestRate(rate, dayCounter, Compounding.Simple,Frequency.Annual);
}
示例6: BasisSwap
// results
//private double? fairSpread1_;
//private double? fairSpread2_;
// constructor
public BasisSwap(Type type, double nominal,
Schedule float1Schedule, IborIndex iborIndex1, double spread1, DayCounter float1DayCount,
Schedule float2Schedule, IborIndex iborIndex2, double spread2, DayCounter float2DayCount)
: this(type, nominal, float1Schedule, iborIndex1, spread1, float1DayCount,
float2Schedule, iborIndex2, spread2, float2DayCount, null)
{
}
示例7: DiscretizedSwap
public DiscretizedSwap(VanillaSwap.Arguments args,
Date referenceDate,
DayCounter dayCounter)
{
arguments_ = args;
fixedResetTimes_ = new InitializedList<double>(args.fixedResetDates.Count);
for (int i = 0; i < fixedResetTimes_.Count; ++i)
fixedResetTimes_[i] =
dayCounter.yearFraction(referenceDate,
args.fixedResetDates[i]);
fixedPayTimes_ = new InitializedList<double>(args.fixedPayDates.Count);
for (int i = 0; i < fixedPayTimes_.Count; ++i)
fixedPayTimes_[i] =
dayCounter.yearFraction(referenceDate,
args.fixedPayDates[i]);
floatingResetTimes_ = new InitializedList<double>(args.floatingResetDates.Count);
for (int i = 0; i < floatingResetTimes_.Count; ++i)
floatingResetTimes_[i] =
dayCounter.yearFraction(referenceDate,
args.floatingResetDates[i]);
floatingPayTimes_ = new InitializedList<double>(args.floatingPayDates.Count);
for (int i = 0; i < floatingPayTimes_.Count; ++i)
floatingPayTimes_[i] =
dayCounter.yearFraction(referenceDate,
args.floatingPayDates[i]);
}
示例8: referenceDate
// There are three ways in which a term structure can keep
// track of its reference date. The first is that such date
// is fixed; the second is that it is determined by advancing
// the current date of a given number of business days; and
// the third is that it is based on the reference date of
// some other structure.
//
// In the first case, the constructor taking a date is to be
// used; the default implementation of referenceDate() will
// then return such date. In the second case, the constructor
// taking a number of days and a calendar is to be used;
// referenceDate() will return a date calculated based on the
// current evaluation date, and the term structure and its
// observers will be notified when the evaluation date
// changes. In the last case, the referenceDate() method must
// be overridden in derived classes so that it fetches and
// return the appropriate date.
//! default constructor
/*! \warning term structures initialized by means of this
constructor must manage their own reference date
by overriding the referenceDate() method.
*/
public TermStructure(DayCounter dc = null)
{
moving_ = false;
updated_ = true;
settlementDays_ = null;
dayCounter_ = dc;
}
示例9: BlackSwaptionEngine
public BlackSwaptionEngine(Handle<YieldTermStructure> termStructure,
double vol, DayCounter dc )
{
termStructure_ = termStructure;
volatility_ = new Handle<SwaptionVolatilityStructure>(new ConstantSwaptionVolatility(0, new NullCalendar(), BusinessDayConvention.Following, vol, dc));
termStructure_.registerWith(update);
}
示例10: FloatingRateBond
public FloatingRateBond(int settlementDays, double faceAmount, Schedule schedule, IborIndex index,
DayCounter paymentDayCounter)
: this(settlementDays, faceAmount, schedule, index, paymentDayCounter, BusinessDayConvention.Following,
0, new List<double>() { 1 }, new List<double>() { 0 }, new List<double>(), new List<double>(),
false, 100, null)
{
}
示例11: FloatingRateBond
public FloatingRateBond(int settlementDays, double faceAmount, Schedule schedule, IborIndex index, DayCounter paymentDayCounter,
BusinessDayConvention paymentConvention, int fixingDays, List<double> gearings, List<double> spreads,
List<double> caps, List<double> floors, bool inArrears, double redemption, Date issueDate)
: base(settlementDays, schedule.calendar(), issueDate) {
maturityDate_ = schedule.endDate();
cashflows_ = new IborLeg(schedule, index)
.withPaymentDayCounter(paymentDayCounter)
.withFixingDays(fixingDays)
.withGearings(gearings)
.withSpreads(spreads)
.withCaps(caps)
.withFloors(floors)
.inArrears(inArrears)
.withNotionals(faceAmount)
.withPaymentAdjustment(paymentConvention);
addRedemptionsToCashflows(new List<double>() { redemption });
if (cashflows().Count == 0)
throw new ApplicationException("bond with no cashflows!");
if (redemptions_.Count != 1)
throw new ApplicationException("multiple redemptions created");
index.registerWith(update);
}
示例12: SwaptionHelper
SwaptionHelper( Date exerciseDate,
Period length,
Handle<Quote> volatility,
IborIndex index,
Period fixedLegTenor,
DayCounter fixedLegDayCounter,
DayCounter floatingLegDayCounter,
Handle<YieldTermStructure> termStructure,
CalibrationErrorType errorType = CalibrationErrorType.RelativePriceError,
double? strike = null,
double nominal = 1.0)
: base(volatility, termStructure, errorType)
{
exerciseDate_ = exerciseDate;
endDate_ = null;
maturity_ = new Period(0,TimeUnit.Days);
length_ = length;
fixedLegTenor_ = fixedLegTenor;
index_ = index;
fixedLegDayCounter_ = fixedLegDayCounter;
floatingLegDayCounter_ = floatingLegDayCounter;
strike_ = strike;
nominal_ = nominal;
index_.registerWith( update );
}
示例13: AmortizingFixedRateBond
public AmortizingFixedRateBond(
int settlementDays,
Calendar calendar,
double faceAmount,
Date startDate,
Period bondTenor,
Frequency sinkingFrequency,
double coupon,
DayCounter accrualDayCounter,
BusinessDayConvention paymentConvention = BusinessDayConvention.Following,
Date issueDate = null)
:base(settlementDays, calendar, issueDate)
{
frequency_ = sinkingFrequency;
dayCounter_ = accrualDayCounter;
Utils.QL_REQUIRE( bondTenor.length() > 0,() =>
"bond tenor must be positive. "
+ bondTenor + " is not allowed." );
maturityDate_ = startDate + bondTenor;
maturityDate_ = startDate + bondTenor;
schedule_ = sinkingSchedule(startDate, bondTenor, sinkingFrequency, calendar);
cashflows_ = new FixedRateLeg(schedule_)
.withCouponRates(coupon, accrualDayCounter)
.withNotionals(sinkingNotionals(bondTenor, sinkingFrequency, coupon, faceAmount))
.withPaymentAdjustment(paymentConvention).value();
addRedemptionsToCashflows();
}
示例14: factory
// Factory - for Leg generators
public override CashFlow factory(double nominal, Date paymentDate, Date startDate, Date endDate, int fixingDays,
InterestRateIndex index, double gearing, double spread,
Date refPeriodStart, Date refPeriodEnd, DayCounter dayCounter, bool isInArrears)
{
return new CmsCoupon(nominal, paymentDate, startDate, endDate, fixingDays,
(SwapIndex)index, gearing, spread, refPeriodStart, refPeriodEnd, dayCounter, isInArrears);
}
示例15: FlatForward
public FlatForward(Date referenceDate, double forward, DayCounter dayCounter, Compounding compounding, Frequency frequency)
: base(referenceDate, new Calendar(), dayCounter)
{
forward_ = new SimpleQuote(forward);
compounding_ = compounding;
frequency_ = frequency;
}