本文整理匯總了C#中QLNet.Calendar.advance方法的典型用法代碼示例。如果您正苦於以下問題:C# Calendar.advance方法的具體用法?C# Calendar.advance怎麽用?C# Calendar.advance使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類QLNet.Calendar
的用法示例。
在下文中一共展示了Calendar.advance方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: CommonVars
// setup
public CommonVars()
{
// force garbage collection
// garbage collection in .NET is rather weird and we do need when we run several tests in a row
GC.Collect();
// data
calendar = new TARGET();
settlementDays = 2;
today = new Date(9, Month.June, 2009);
compounding = Compounding.Continuous;
dayCount = new Actual360();
settlementDate = calendar.advance(today, settlementDays, TimeUnit.Days);
Settings.setEvaluationDate(today);
int[] ts = new int[] { 13, 41, 75, 165, 256, 345, 524, 703 };
double[] r = new double[] { 0.035, 0.033, 0.034, 0.034, 0.036, 0.037, 0.039, 0.040 };
List<double> rates = new List<double>() { 0.035 };
List<Date> dates = new List<Date>() { settlementDate };
for (int i = 0; i < 8; ++i)
{
dates.Add(calendar.advance(today, ts[i], TimeUnit.Days));
rates.Add(r[i]);
}
termStructure = new InterpolatedZeroCurve<Linear>(dates, rates, dayCount);
}
示例2: FuturesRateHelper
// overloaded constructors
public FuturesRateHelper(double price, Date immDate, int nMonths, Calendar calendar, BusinessDayConvention convention,
bool endOfMonth, DayCounter dayCounter, double convAdj)
: base(price)
{
convAdj_ = new Handle<Quote>(new SimpleQuote(convAdj));
if (!IMM.isIMMdate(immDate, false)) throw new ArgumentException(immDate + "is not a valid IMM date");
earliestDate_ = immDate;
latestDate_ = calendar.advance(immDate, new Period(nMonths, TimeUnit.Months), convention, endOfMonth);
yearFraction_ = dayCounter.yearFraction(earliestDate_, latestDate_);
}
示例3: makeAmortizingFixedBond
public static AmortizingFixedRateBond makeAmortizingFixedBond( Date startDate,
Period bondLength,
DayCounter dCounter,
Frequency payFrequency,
double amount,
double rate,
Calendar calendar)
{
AmortizingFixedRateBond bond;
Date endDate = calendar.advance(startDate,bondLength);
Schedule schedule = new Schedule(startDate,endDate,bondLength,calendar,BusinessDayConvention.Unadjusted,
BusinessDayConvention.Unadjusted,DateGeneration.Rule.Backward,false);
bond = new AmortizingFixedRateBond(0, calendar, amount, startDate, bondLength, payFrequency, rate, dCounter);
return bond;
}
示例4: 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);
}
示例5: 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()));
}
示例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: TermStructure
public TermStructure(int settlementDays, Calendar cal, DayCounter dc)
{
moving_ = true;
calendar_ = cal;
updated_ = false;
settlementDays_ = settlementDays;
dayCounter_ = dc;
// observe evaluationDate
Settings.registerWith(update);
// verify immediately if calendar and settlementDays are ok
Date today = Settings.evaluationDate();
referenceDate_ = calendar_.advance(today, settlementDays_, TimeUnit.Days);
}
示例8: CommonVars
public CommonVars()
{
type = OvernightIndexedSwap.Type.Payer;
settlementDays = 2;
nominal = 100.0;
fixedEoniaConvention = BusinessDayConvention.ModifiedFollowing;
floatingEoniaConvention = BusinessDayConvention.ModifiedFollowing;
fixedEoniaPeriod = new Period(1, TimeUnit.Years);
floatingEoniaPeriod = new Period(1, TimeUnit.Years);
fixedEoniaDayCount = new Actual360();
eoniaIndex = new Eonia(eoniaTermStructure);
fixedSwapConvention = BusinessDayConvention.ModifiedFollowing;
fixedSwapFrequency = Frequency.Annual;
fixedSwapDayCount = new Thirty360();
swapIndex = (IborIndex) new Euribor3M(swapTermStructure);
calendar = eoniaIndex.fixingCalendar();
today = new Date(5, Month.February, 2009);
//today = calendar.adjust(Date::todaysDate());
Settings.setEvaluationDate(today);
settlement = calendar.advance(today,new Period(settlementDays,TimeUnit.Days),BusinessDayConvention.Following);
eoniaTermStructure.linkTo(Utilities.flatRate(settlement, 0.05,new Actual365Fixed()));
}
示例9: 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());
}
示例10: 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()));
}
示例11: 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)));
}
示例12: makeMBSFixedBond
public static MBSFixedRateBond makeMBSFixedBond(Date startDate,
Period bondLength,
Period originalLength,
DayCounter dCounter,
Frequency payFrequency,
double amount,
double WACrate,
double PassThroughRate,
PSACurve psaCurve,
Calendar calendar)
{
MBSFixedRateBond bond;
Date endDate = calendar.advance(startDate, bondLength);
Schedule schedule = new Schedule(startDate, endDate, bondLength, calendar, BusinessDayConvention.Unadjusted,
BusinessDayConvention.Unadjusted, DateGeneration.Rule.Backward, false);
bond = new MBSFixedRateBond(0, calendar, amount, startDate, bondLength, originalLength , payFrequency, WACrate, PassThroughRate, dCounter, psaCurve);
return bond;
}