本文整理匯總了C#中QLNet.Period類的典型用法代碼示例。如果您正苦於以下問題:C# Period類的具體用法?C# Period怎麽用?C# Period使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Period類屬於QLNet命名空間,在下文中一共展示了Period類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: dates
//! \name Volatility
/*! by default, inflation is observed with the lag
of the term structure.
Because inflation is highly linked to dates (for
interpolation, periods, etc) time-based overload of the
methods are not provided.
*/
//@{
//! Returns the volatility for a given maturity date and strike rate.
double volatility(Date maturityDate, double strike,
Period obsLag = null,
bool extrapolate = false)
{
if (obsLag == null)
obsLag = new Period(-1, TimeUnit.Days);
Period useLag = obsLag;
if (obsLag == new Period(-1, TimeUnit.Days))
{
useLag = observationLag();
}
if (indexIsInterpolated())
{
checkRange(maturityDate - useLag, strike, extrapolate);
double t = timeFromReference(maturityDate - useLag);
return volatilityImpl(t, strike);
}
else
{
KeyValuePair<Date, Date> dd = Utils.inflationPeriod(maturityDate - useLag, frequency());
checkRange(dd.Key, strike, extrapolate);
double t = timeFromReference(dd.Key);
return volatilityImpl(t, strike);
}
}
示例2: CallableBondConstantVolatility
public CallableBondConstantVolatility(int settlementDays, Calendar calendar, double volatility, DayCounter dayCounter)
:base(settlementDays, calendar)
{
volatility_ = new Handle<Quote>(new SimpleQuote(volatility));
dayCounter_ = dayCounter;
maxBondTenor_ = new Period(100,TimeUnit.Years);
}
示例3: 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();
}
示例4: BlackVanillaOptionPricer
public BlackVanillaOptionPricer(double forwardValue, Date expiryDate, Period swapTenor, SwaptionVolatilityStructure volatilityStructure) {
forwardValue_ = forwardValue;
expiryDate_ = expiryDate;
swapTenor_ = swapTenor;
volatilityStructure_ = volatilityStructure;
smile_ = volatilityStructure_.smileSection(expiryDate_, swapTenor_);
}
示例5: SwapRateHelper
public SwapRateHelper(double rate, Period tenor, Calendar calendar,
Frequency fixedFrequency, BusinessDayConvention fixedConvention, DayCounter fixedDayCount,
IborIndex iborIndex)
: this(rate, tenor, calendar, fixedFrequency, fixedConvention, fixedDayCount, iborIndex,
new Handle<Quote>(), new Period(0, TimeUnit.Days))
{
}
示例6: volatility
//! returns the volatility for a given option date and swap tenor
public double volatility(Date optionDate, Period swapTenor, double strike, bool extrapolate = false)
{
checkSwapTenor(swapTenor, extrapolate);
checkRange(optionDate, extrapolate);
checkStrike(strike, extrapolate);
return volatilityImpl(optionDate, swapTenor, strike);
}
示例7: testCashedValues
public void testCashedValues()
{
Date startDate = new Date(01, 03, 2007);
Period period = new Period(360, TimeUnit.Months);
Calendar calendar = new TARGET();
Date endDate = calendar.advance(startDate,period,BusinessDayConvention.Unadjusted);
Schedule schedule = new Schedule( startDate, endDate, new Period(1,TimeUnit.Months), calendar,
BusinessDayConvention.Unadjusted,
BusinessDayConvention.Unadjusted,
DateGeneration.Rule.Backward, false);
// PSA 100%
PSACurve psa100 = new PSACurve(startDate);
double[] listCPR = {0.2000,0.4000,0.6000,0.8000,1.0000,1.2000,1.4000,1.6000,1.8000,2.0000,2.2000,2.4000,2.6000,2.8000,
3.0000,3.2000,3.4000,3.6000,3.8000,4.0000,4.2000,4.4000,4.6000,4.8000,5.0000,5.2000,5.4000,5.6000,
5.8000,6.0000};
for (int i = 0; i < schedule.Count; i++)
{
if ( i <= 29 )
Assert.AreEqual(listCPR[i], psa100.getCPR(schedule[i])*100,0.001);
else
Assert.AreEqual(6.0000, psa100.getCPR(schedule[i])*100);
}
}
示例8: YoYInflationCoupon
public YoYInflationCoupon(Date paymentDate, double nominal, Date startDate, Date endDate, int fixingDays, YoYInflationIndex yoyIndex, Period observationLag, DayCounter dayCounter, double gearing, double spread, Date refPeriodStart, Date refPeriodEnd)
: base(paymentDate, nominal, startDate, endDate, fixingDays, yoyIndex, observationLag, dayCounter, refPeriodStart, refPeriodEnd)
{
yoyIndex_ = yoyIndex;
gearing_ = gearing;
spread_ = spread;
}
示例9: 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 );
}
示例10: 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");
}
示例11: IborIndex
public IborIndex(string familyName, Period tenor, int settlementDays, Currency currency,
Calendar fixingCalendar, BusinessDayConvention convention, bool endOfMonth,
DayCounter dayCounter)
: this(familyName, tenor, settlementDays, currency,
fixingCalendar, convention, endOfMonth,
dayCounter, new Handle<YieldTermStructure>())
{
}
示例12: EURLibor
public EURLibor(Period tenor, Handle<YieldTermStructure> h)
: base("EURLibor", tenor, 2, new EURCurrency(), new JointCalendar(new UnitedKingdom(UnitedKingdom.Market.Exchange), new TARGET(),
JointCalendar.JointCalendarRule.JoinHolidays),
Utils.eurliborConvention(tenor), Utils.eurliborEOM(tenor), new Actual360(), h) {
target_ = new TARGET();
if (!(this.tenor().units() != TimeUnit.Days))
throw new ApplicationException("for daily tenors (" + this.tenor() + ") dedicated DailyTenor constructor must be used");
}
示例13: Euribor365
public Euribor365(Period tenor, Handle<YieldTermStructure> h)
: base("Euribor365", tenor,
2, // settlement days
new EURCurrency(), new TARGET(), Utils.euriborConvention(tenor), Utils.euriborEOM(tenor),
new Actual365Fixed(), h) {
if (this.tenor().units() == TimeUnit.Days)
throw new ApplicationException("for daily tenors (" + this.tenor() + ") dedicated DailyTenor constructor must be used");
}
示例14: DepositRateHelper
public DepositRateHelper(double rate, Period tenor, int fixingDays, Calendar calendar,
BusinessDayConvention convention, bool endOfMonth, DayCounter dayCounter)
: base(rate)
{
iborIndex_ = new IborIndex("no-fix", tenor, fixingDays, new Currency(), calendar, convention,
endOfMonth, dayCounter, termStructureHandle_);
initializeDates();
}
示例15: withExCouponPeriod
public CPILegBase withExCouponPeriod(Period period, Calendar cal, BusinessDayConvention convention, bool endOfMonth = false)
{
exCouponPeriod_ = period;
exCouponCalendar_ = cal;
exCouponAdjustment_ = convention;
exCouponEndOfMonth_ = endOfMonth;
return this;
}