本文整理匯總了C#中QLNet.Calendar.adjust方法的典型用法代碼示例。如果您正苦於以下問題:C# Calendar.adjust方法的具體用法?C# Calendar.adjust怎麽用?C# Calendar.adjust使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類QLNet.Calendar
的用法示例。
在下文中一共展示了Calendar.adjust方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: CommonVars
// todo
// cleanup
// SavedSettings backup;
// setup
public CommonVars()
{
calendar = new TARGET();
today = calendar.adjust(Date.Today);
Settings.setEvaluationDate(today);
faceAmount = 1000000.0;
}
示例2: Forward
//protected Forward(DayCounter dayCounter, Calendar calendar, BusinessDayConvention businessDayConvention,
// int settlementDays, Payoff payoff, Date valueDate, Date maturityDate,
// Handle<YieldTermStructure> discountCurve = Handle<YieldTermStructure>()) {
protected Forward(DayCounter dayCounter, Calendar calendar, BusinessDayConvention businessDayConvention,
int settlementDays, Payoff payoff, Date valueDate, Date maturityDate,
Handle<YieldTermStructure> discountCurve) {
dayCounter_ = dayCounter;
calendar_ = calendar;
businessDayConvention_ = businessDayConvention;
settlementDays_ = settlementDays;
payoff_ = payoff;
valueDate_ = valueDate;
maturityDate_ = maturityDate;
discountCurve_ = discountCurve;
maturityDate_ = calendar_.adjust(maturityDate_, businessDayConvention_);
Settings.registerWith(update);
discountCurve_.registerWith(update);
}
示例3: CommonVars
// setup
public CommonVars()
{
// option variables
nominals = new List<double>{1000000};
frequency = Frequency.Annual;
// usual setup
calendar = new UnitedKingdom();
convention = BusinessDayConvention.ModifiedFollowing;
Date today = new Date(13, Month.August, 2007);
evaluationDate = calendar.adjust(today);
Settings.setEvaluationDate(evaluationDate);
settlementDays = 0;
fixingDays = 0;
settlement = calendar.advance(today,settlementDays,TimeUnit.Days);
dc = new Thirty360();
// yoy index
// fixing data
Date from = new Date(1, Month.January, 2005);
Date to = new Date(13, Month.August, 2007);
Schedule rpiSchedule = new MakeSchedule().from(from).to(to)
.withConvention(BusinessDayConvention.ModifiedFollowing)
.withCalendar(new UnitedKingdom())
.withTenor(new Period(1,TimeUnit.Months)).value();
double[] fixData = { 189.9, 189.9, 189.6, 190.5, 191.6, 192.0,
192.2, 192.2, 192.6, 193.1, 193.3, 193.6,
194.1, 193.4, 194.2, 195.0, 196.5, 197.7,
198.5, 198.5, 199.2, 200.1, 200.4, 201.1,
202.7, 201.6, 203.1, 204.4, 205.4, 206.2,
207.3, -999.0, -999 };
// link from yoy index to yoy TS
bool interp = false;
iir = new YYUKRPIr(interp, hy);
for (int i=0; i<rpiSchedule.Count;i++)
{
iir.addFixing(rpiSchedule[i], fixData[i]);
}
YieldTermStructure nominalFF = new FlatForward(evaluationDate, 0.05, new ActualActual());
nominalTS.linkTo(nominalFF);
// now build the YoY inflation curve
Period observationLag = new Period(2,TimeUnit.Months);
Datum[] yyData = {
new Datum( new Date(13, Month.August, 2008), 2.95 ),
new Datum( new Date(13, Month.August, 2009), 2.95 ),
new Datum( new Date(13, Month.August, 2010), 2.93 ),
new Datum( new Date(15, Month.August, 2011), 2.955 ),
new Datum( new Date(13, Month.August, 2012), 2.945 ),
new Datum( new Date(13, Month.August, 2013), 2.985 ),
new Datum( new Date(13, Month.August, 2014), 3.01 ),
new Datum( new Date(13, Month.August, 2015), 3.035 ),
new Datum( new Date(13, Month.August, 2016), 3.055 ), // note that
new Datum( new Date(13, Month.August, 2017), 3.075 ), // some dates will be on
new Datum( new Date(13, Month.August, 2019), 3.105 ), // holidays but the payment
new Datum( new Date(15, Month.August, 2022), 3.135 ), // calendar will roll them
new Datum( new Date(13, Month.August, 2027), 3.155 ),
new Datum( new Date(13, Month.August, 2032), 3.145 ),
new Datum( new Date(13, Month.August, 2037), 3.145 )
};
// now build the helpers ...
List<BootstrapHelper<YoYInflationTermStructure>> helpers =
makeHelpers(yyData, yyData.Length, iir,
observationLag,
calendar, convention, dc);
double baseYYRate = yyData[0].rate/100.0;
PiecewiseYoYInflationCurve<Linear> pYYTS =
new PiecewiseYoYInflationCurve<Linear>(
evaluationDate, calendar, dc, observationLag,
iir.frequency(),iir.interpolated(), baseYYRate,
new Handle<YieldTermStructure>(nominalTS), helpers);
pYYTS.recalculate();
yoyTS = pYYTS as YoYInflationTermStructure;
// make sure that the index has the latest yoy term structure
hy.linkTo(pYYTS);
}
示例4: CommonVars
public CommonVars()
{
settlementDays = 2;
nominal = 1000000.0;
fixedConvention = BusinessDayConvention.Unadjusted;
fixedFrequency = Frequency.Annual;
fixedDayCount = new Thirty360();
index =new Euribor6M(termStructure);
floatingConvention = index.businessDayConvention();
floatingTenor = index.tenor();
calendar = index.fixingCalendar();
today = calendar.adjust(Date.Today);
Settings.setEvaluationDate(today);
settlement = calendar.advance(today, settlementDays, TimeUnit.Days);
termStructure.linkTo(Utilities.flatRate(settlement, 0.05, new Actual365Fixed()));
}
示例5: CommonVars
// cleanup
// SavedSettings backup;
// setup
public CommonVars()
{
calendar = new TARGET();
settlementDays = 2;
Date today = calendar.adjust(Date.Today);
Settings.setEvaluationDate(today);
Date settlement = calendar.advance(today, settlementDays, TimeUnit.Days);
int deposits = depositData.Length,
swaps = swapData.Length;
var instruments = new List<RateHelper>(deposits + swaps);
for (int i = 0; i < deposits; i++)
{
instruments.Add(new DepositRateHelper(depositData[i].rate / 100, new Period(depositData[i].n, depositData[i].units),
settlementDays, calendar, BusinessDayConvention.ModifiedFollowing, true, new Actual360()));
}
IborIndex index = new IborIndex("dummy", new Period(6, TimeUnit.Months), settlementDays, new Currency(),
calendar, BusinessDayConvention.ModifiedFollowing, false, new Actual360());
for (int i = 0; i < swaps; ++i)
{
instruments.Add(new SwapRateHelper(swapData[i].rate / 100, new Period(swapData[i].n, swapData[i].units),
calendar, Frequency.Annual, BusinessDayConvention.Unadjusted, new Thirty360(), index));
}
termStructure = new PiecewiseYieldCurve<Discount, LogLinear>(settlement, instruments, new Actual360());
dummyTermStructure = new PiecewiseYieldCurve<Discount, LogLinear>(settlement, instruments, new Actual360());
}
示例6: CommonVars
// setup
public CommonVars()
{
startYears = 1;
length = 5;
type = VanillaSwap.Type.Payer;
nominal = 1000.0;
settlementDays = 2;
fixedConvention = BusinessDayConvention.Unadjusted;
floatingConvention = BusinessDayConvention.ModifiedFollowing;
fixedFrequency = Frequency.Annual;
floatingFrequency = Frequency.Semiannual;
fixedDayCount = new Thirty360();
termStructure = new RelinkableHandle<YieldTermStructure>();
termStructure.linkTo(Utilities.flatRate(new Date(19, Month.February, 2002), 0.04875825, new Actual365Fixed()));
index = new Euribor6M(termStructure);
calendar = index.fixingCalendar();
today = calendar.adjust(Date.Today);
settlement = calendar.advance(today, settlementDays, TimeUnit.Days);
}
示例7: CommonVars
public CommonVars()
{
type = VanillaSwap.Type.Payer;
settlementDays = 2;
nominal = 100.0;
fixedConvention = BusinessDayConvention.Unadjusted;
floatingConvention = BusinessDayConvention.ModifiedFollowing;
fixedFrequency = Frequency.Annual;
floatingFrequency = Frequency.Semiannual;
fixedDayCount = new Thirty360();
index = new Euribor(new Period(floatingFrequency), termStructure);
calendar = index.fixingCalendar();
today = calendar.adjust(Date.Today);
Settings.setEvaluationDate(today);
settlement = calendar.advance(today, settlementDays, TimeUnit.Days);
termStructure.linkTo(Utilities.flatRate(settlement, 0.05, new Actual365Fixed()));
}
示例8: Schedule
//.........這裏部分代碼省略.........
Date seed = new Date() , exitDate;
switch (rule_)
{
case DateGeneration.Rule.Zero:
tenor_ = new Period(0, TimeUnit.Years);
dates_.Add(effectiveDate);
dates_.Add(terminationDate);
isRegular_.Add(true);
break;
case DateGeneration.Rule.Backward:
dates_.Add(terminationDate);
seed = terminationDate;
if (nextToLastDate_ != null)
{
dates_.Insert(0, nextToLastDate_);
Date temp = nullCalendar.advance(seed, -periods * tenor_, convention_, endOfMonth_);
if (temp != nextToLastDate_)
isRegular_.Insert(0, false);
else
isRegular_.Insert(0, true);
seed = nextToLastDate_;
}
exitDate = effectiveDate;
if (firstDate_ != null)
exitDate = firstDate_;
while (true)
{
Date temp = nullCalendar.advance(seed, -periods * tenor_, convention_, endOfMonth_);
if (temp < exitDate)
{
if (firstDate_ != null && (calendar_.adjust(dates_.First(), convention_) !=
calendar_.adjust(firstDate_, convention_)))
{
dates_.Insert(0, firstDate_);
isRegular_.Insert(0, false);
}
break;
}
else
{
// skip dates that would result in duplicates
// after adjustment
if (calendar_.adjust(dates_.First(), convention_) != calendar_.adjust(temp, convention_))
{
dates_.Insert(0, temp);
isRegular_.Insert(0, true);
}
++periods;
}
}
if (calendar_.adjust(dates_.First(), convention) != calendar_.adjust(effectiveDate, convention))
{
dates_.Insert(0, effectiveDate);
isRegular_.Insert(0, false);
}
break;
case DateGeneration.Rule.Twentieth:
case DateGeneration.Rule.TwentiethIMM:
case DateGeneration.Rule.ThirdWednesday:
case DateGeneration.Rule.OldCDS:
示例9: setConventions
public void setConventions()
{
calendar = new TARGET();
Date today = calendar.adjust(Date.Today);
Settings.setEvaluationDate(today);
optionBdc = BusinessDayConvention.ModifiedFollowing;
dayCounter = new Actual365Fixed();
}
示例10: CommonVars
// setup
public CommonVars()
{
nominals = new List<double>() { 100 };
frequency = Frequency.Semiannual;
index = (IborIndex)new Euribor6M(termStructure);
calendar = index.fixingCalendar();
convention = BusinessDayConvention.ModifiedFollowing;
Date today = calendar.adjust(Date.Today);
Settings.setEvaluationDate(today);
int settlementDays = 2;
fixingDays = 2;
settlement = calendar.advance(today, settlementDays, TimeUnit.Days);
termStructure.linkTo(Utilities.flatRate(settlement, 0.05,
new ActualActual(ActualActual.Convention.ISDA)));
}
示例11: Schedule
//.........這裏部分代碼省略.........
throw new ArgumentException("next to last is incompatible with " + rule_ + " date generation rule");
default:
throw new ArgumentException("Unknown DateGeneration rule: " + rule_);
}
}
// calendar needed for endOfMonth adjustment
Calendar nullCalendar = new NullCalendar();
int periods = 1;
Date seed = new Date(), exitDate;
switch (rule_) {
case DateGeneration.Rule.Zero:
tenor_ = new Period(0, TimeUnit.Years);
originalDates_.Add(effectiveDate__);
originalDates_.Add(terminationDate__);
isRegular_.Add(true);
break;
case DateGeneration.Rule.Backward:
originalDates_.Add(terminationDate__);
seed = terminationDate__;
if (nextToLastDate_ != null) {
originalDates_.Insert(0, nextToLastDate_);
Date temp = nullCalendar.advance(seed, -periods * tenor_, convention_, endOfMonth_);
isRegular_.Insert(0, temp == nextToLastDate_);
seed = nextToLastDate_;
}
exitDate = effectiveDate__;
if (firstDate_ != null)
exitDate = firstDate_;
while (true) {
Date temp = nullCalendar.advance(seed, -periods * tenor_, convention_, endOfMonth_);
if (temp < exitDate) {
if (firstDate_ != null && (calendar_.adjust(originalDates_.First(), convention_) !=
calendar_.adjust(firstDate_, convention_))) {
originalDates_.Insert(0, firstDate_);
isRegular_.Insert(0, false);
}
break;
} else {
originalDates_.Insert(0, temp);
isRegular_.Insert(0, true);
++periods;
}
}
if (endOfMonth_ && calendar_.isEndOfMonth(seed))
convention_ = BusinessDayConvention.Preceding;
if (calendar_.adjust(originalDates_[0], convention_) != calendar_.adjust(effectiveDate__, convention_)) {
originalDates_.Insert(0, effectiveDate__);
isRegular_.Insert(0, false);
}
break;
case DateGeneration.Rule.Twentieth:
case DateGeneration.Rule.TwentiethIMM:
case DateGeneration.Rule.ThirdWednesday:
case DateGeneration.Rule.OldCDS:
case DateGeneration.Rule.CDS:
if (endOfMonth_)
throw new ArgumentException("endOfMonth convention is incompatible with " + rule_ + " date generation rule");
goto case DateGeneration.Rule.Forward; // fall through
case DateGeneration.Rule.Forward:
if (rule_ == DateGeneration.Rule.CDS) {
originalDates_.Add(previousTwentieth(effectiveDate__,DateGeneration.Rule.CDS));
} else {