本文整理匯總了C#中QLNet.Schedule類的典型用法代碼示例。如果您正苦於以下問題:C# Schedule類的具體用法?C# Schedule怎麽用?C# Schedule使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Schedule類屬於QLNet命名空間,在下文中一共展示了Schedule類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: FixedRateBond
public FixedRateBond(int settlementDays, double faceAmount, Schedule schedule,
List<double> coupons, DayCounter accrualDayCounter,
BusinessDayConvention paymentConvention, double redemption, Date issueDate)
: this(settlementDays, faceAmount, schedule, coupons, accrualDayCounter,
paymentConvention, redemption, issueDate, new Calendar())
{
}
示例2: CmsLeg
public CmsLeg(Schedule schedule, SwapIndex swapIndex) {
schedule_ = schedule;
index_ = swapIndex;
paymentAdjustment_ = BusinessDayConvention.Following;
inArrears_ = false;
zeroPayments_ = false;
}
示例3: 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");
}
示例4: FloatingRateBond
public FloatingRateBond(int settlementDays, double faceAmount, Schedule schedule, IborIndex index,
DayCounter paymentDayCounter, BusinessDayConvention paymentConvention, int fixingDays,
List<double> gearings, List<double> spreads)
: this(settlementDays, faceAmount, schedule, index, paymentDayCounter, BusinessDayConvention.Following,
fixingDays, gearings, spreads, new List<double>(), new List<double>(), false, 100, null)
{
}
示例5: testFairRate
public void testFairRate()
{
Calendar calendar = new TARGET();
Date settlementDate = new Date(10, Month.Mar, 2010);
/*********************
* LOAN TO BE PRICED *
**********************/
// constant nominal 1,000,000 Euro
double nominal = 1000000.0;
// fixed leg
Frequency fixedLegFrequency = Frequency.Monthly;
BusinessDayConvention fixedLegConvention = BusinessDayConvention.Unadjusted;
BusinessDayConvention principalLegConvention = BusinessDayConvention.ModifiedFollowing;
DayCounter fixedLegDayCounter = new Thirty360(Thirty360.Thirty360Convention.European);
double fixedRate = 0.04;
// Principal leg
Frequency pricipalLegFrequency = Frequency.Annual;
int lenghtInMonths = 3;
Loan.Type loanType = Loan.Type.Payer;
Date maturity = settlementDate + new Period(lenghtInMonths, TimeUnit.Years);
Schedule fixedSchedule = new Schedule(settlementDate, maturity, new Period(fixedLegFrequency),
calendar, fixedLegConvention, fixedLegConvention, DateGeneration.Rule.Forward, false);
Schedule principalSchedule = new Schedule(settlementDate, maturity, new Period(pricipalLegFrequency),
calendar, principalLegConvention, principalLegConvention, DateGeneration.Rule.Forward, false);
Loan testLoan = new FixedLoan(loanType, nominal, fixedSchedule, fixedRate, fixedLegDayCounter,
principalSchedule, principalLegConvention);
}
示例6: BasisSwap
// 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: AmortizingFixedRateBond
public AmortizingFixedRateBond(
int settlementDays,
List<double> notionals,
Schedule schedule,
List<double> coupons,
DayCounter accrualDayCounter,
BusinessDayConvention paymentConvention = BusinessDayConvention.Following,
Date issueDate = null)
:base(settlementDays, schedule.calendar(), issueDate)
{
frequency_ = schedule.tenor().frequency();
dayCounter_ = accrualDayCounter;
schedule_ = schedule;
maturityDate_ = schedule.endDate();
cashflows_ = new FixedRateLeg(schedule)
.withCouponRates(coupons, accrualDayCounter)
.withNotionals(notionals)
.withPaymentAdjustment(paymentConvention).value();
addRedemptionsToCashflows();
if ( cashflows().empty())
throw new ApplicationException("bond with no cashflows!");
}
示例8: 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);
}
示例9: 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);
}
}
示例10: ConvertibleBond
protected ConvertibleBond( Exercise exercise,
double conversionRatio,
DividendSchedule dividends,
CallabilitySchedule callability,
Handle<Quote> creditSpread,
Date issueDate,
int settlementDays,
Schedule schedule,
double redemption)
: base(settlementDays, schedule.calendar(), issueDate)
{
conversionRatio_ = conversionRatio;
callability_ = callability;
dividends_ = dividends;
creditSpread_ = creditSpread;
maturityDate_ = schedule.endDate();
if (!callability.empty())
{
Utils.QL_REQUIRE( callability.Last().date() <= maturityDate_, () =>
"last callability date ("
+ callability.Last().date()
+ ") later than maturity ("
+ maturityDate_.ToShortDateString() + ")");
}
creditSpread.registerWith(update);
}
示例11: FixedRateBondHelper
//public FixedRateBondHelper(Quote cleanPrice, int settlementDays, double faceAmount, Schedule schedule,
// List<double> coupons, DayCounter dayCounter,
// BusinessDayConvention paymentConv = Following,
// double redemption = 100.0,
// Date issueDate = null);
public FixedRateBondHelper(Handle<Quote> cleanPrice, int settlementDays, double faceAmount, Schedule schedule,
List<double> coupons, DayCounter dayCounter, BusinessDayConvention paymentConvention,
double redemption, Date issueDate)
: base(cleanPrice, new FixedRateBond(settlementDays, faceAmount, schedule,
coupons, dayCounter, paymentConvention,
redemption, issueDate)) {
fixedRateBond_ = bond_ as FixedRateBond;
}
示例12: testATMRate
public void testATMRate()
{
CommonVars vars = new CommonVars();
int[] lengths = { 1, 2, 3, 5, 7, 10, 15, 20 };
double[] strikes = { 0.0, 0.03, 0.04, 0.05, 0.06, 0.07 };
double[] vols = { 0.01, 0.05, 0.10, 0.15, 0.20 };
Date startDate = vars.termStructure.link.referenceDate();
for (int i = 0; i < lengths.Length; i++) {
List<CashFlow> leg = vars.makeLeg(startDate, lengths[i]);
Date maturity = vars.calendar.advance(startDate, lengths[i], TimeUnit.Years, vars.convention);
Schedule schedule = new Schedule(startDate, maturity,
new Period(vars.frequency), vars.calendar,
vars.convention, vars.convention,
DateGeneration.Rule.Forward, false);
for (int j = 0; j < strikes.Length; j++) {
for (int k = 0; k < vols.Length; k++) {
CapFloor cap = vars.makeCapFloor(CapFloorType.Cap, leg, strikes[j], vols[k]);
CapFloor floor = vars.makeCapFloor(CapFloorType.Floor, leg, strikes[j], vols[k]);
double capATMRate = cap.atmRate(vars.termStructure);
double floorATMRate = floor.atmRate(vars.termStructure);
if (!checkAbsError(floorATMRate, capATMRate, 1.0e-10))
Assert.Fail(
"Cap ATM Rate and floor ATM Rate should be equal :\n"
+ " length: " + lengths[i] + " years\n"
+ " volatility: " + vols[k] + "\n"
+ " strike: " + strikes[j] + "\n"
+ " cap ATM rate: " + capATMRate + "\n"
+ " floor ATM rate:" + floorATMRate + "\n"
+ " relative Error:"
+ Utilities.relativeError(capATMRate, floorATMRate, capATMRate) * 100 + "%");
VanillaSwap swap = new VanillaSwap(VanillaSwap.Type.Payer, vars.nominals[0],
schedule, floorATMRate,
vars.index.dayCounter(),
schedule, vars.index, 0.0,
vars.index.dayCounter());
swap.setPricingEngine((IPricingEngine)(
new DiscountingSwapEngine(vars.termStructure)));
double swapNPV = swap.NPV();
if (!checkAbsError(swapNPV, 0, 1.0e-10))
Assert.Fail(
"the NPV of a Swap struck at ATM rate "
+ "should be equal to 0:\n"
+ " length: " + lengths[i] + " years\n"
+ " volatility: " + vols[k] + "\n"
+ " ATM rate: " + floorATMRate + "\n"
+ " swap NPV: " + swapNPV);
}
}
}
}
示例13: AverageBMACoupon
private int bmaCutoffDays = 0; // to be verified
// double gearing = 1.0, double spread = 0.0,
// Date refPeriodStart = Date(), Date refPeriodEnd = Date(), DayCounter dayCounter = DayCounter());
public AverageBMACoupon(double nominal, Date paymentDate, Date startDate, Date endDate, BMAIndex index,
double gearing, double spread, Date refPeriodStart, Date refPeriodEnd, DayCounter dayCounter)
: base(nominal, paymentDate, startDate, endDate, index.fixingDays(), index, gearing, spread,
refPeriodStart, refPeriodEnd, dayCounter, false) {
fixingSchedule_ = index.fixingSchedule(
index.fixingCalendar()
.advance(startDate, new Period(-index.fixingDays() + bmaCutoffDays, TimeUnit.Days),
BusinessDayConvention.Preceding), endDate);
setPricer(new AverageBMACouponPricer());
}
示例14: yoyInflationLeg
public yoyInflationLeg(Schedule schedule,Calendar cal,
YoYInflationIndex index,
Period observationLag)
{
schedule_ = schedule;
index_ = index;
observationLag_ = observationLag;
paymentAdjustment_ = BusinessDayConvention.ModifiedFollowing;
paymentCalendar_ = cal;
}
示例15: DigitalIborLeg
public DigitalIborLeg(Schedule schedule, IborIndex index)
{
schedule_ = schedule;
index_ = index;
paymentAdjustment_ = BusinessDayConvention.Following;
inArrears_ = false;
longCallOption_ = Position.Type.Long;
callATM_ = false;
longPutOption_ = Position.Type.Long;
putATM_ = false;
}