本文整理匯總了C#中QLNet.IborIndex.businessDayConvention方法的典型用法代碼示例。如果您正苦於以下問題:C# IborIndex.businessDayConvention方法的具體用法?C# IborIndex.businessDayConvention怎麽用?C# IborIndex.businessDayConvention使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類QLNet.IborIndex
的用法示例。
在下文中一共展示了IborIndex.businessDayConvention方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: ForwardRateAgreement
// Handle<YieldTermStructure> discountCurve = Handle<YieldTermStructure>());
public ForwardRateAgreement(Date valueDate, Date maturityDate, Position.Type type, double strikeForwardRate,
double notionalAmount, IborIndex index, Handle<YieldTermStructure> discountCurve)
: base(index.dayCounter(), index.fixingCalendar(), index.businessDayConvention(), index.fixingDays(), new Payoff(),
valueDate, maturityDate, discountCurve) {
fraType_ = type;
notionalAmount_ = notionalAmount;
index_ = index;
if (notionalAmount <= 0.0)
throw new ApplicationException("notional Amount must be positive");
// do I adjust this ?
// valueDate_ = calendar_.adjust(valueDate_,businessDayConvention_);
Date fixingDate = calendar_.advance(valueDate_, -settlementDays_, TimeUnit.Days);
forwardRate_ = new InterestRate(index.fixing(fixingDate), index.dayCounter(), Compounding.Simple, Frequency.Once);
strikeForwardRate_ = new InterestRate(strikeForwardRate, index.dayCounter(), Compounding.Simple, Frequency.Once);
double strike = notionalAmount_ * strikeForwardRate_.compoundFactor(valueDate_, maturityDate_);
payoff_ = new ForwardTypePayoff(fraType_, strike);
// incomeDiscountCurve_ is irrelevant to an FRA
incomeDiscountCurve_ = discountCurve_;
// income is irrelevant to FRA - set it to zero
underlyingIncome_ = 0.0;
index_.registerWith(update);
}
示例2: DepositRateHelper
public DepositRateHelper(double rate, IborIndex i)
: base(rate)
{
iborIndex_ = new IborIndex("no-fix", // never take fixing into account
i.tenor(), i.fixingDays(), new Currency(),
i.fixingCalendar(), i.businessDayConvention(),
i.endOfMonth(), i.dayCounter(), termStructureHandle_);
initializeDates();
}
示例3: FuturesRateHelper
public FuturesRateHelper(double price, Date immDate, IborIndex i, 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;
Calendar cal = i.fixingCalendar();
latestDate_ = cal.advance(immDate, i.tenor(), i.businessDayConvention());
yearFraction_ = i.dayCounter().yearFraction(earliestDate_, latestDate_);
}
示例4: FRARateHelper
public FRARateHelper(double rate, int monthsToStart, IborIndex i)
: base(rate)
{
periodToStart_ = new Period(monthsToStart, TimeUnit.Months);
iborIndex_ = new IborIndex("no-fix", // never take fixing into account
i.tenor(), i.fixingDays(), new Currency(),
i.fixingCalendar(), i.businessDayConvention(),
i.endOfMonth(), i.dayCounter(), termStructureHandle_);
initializeDates();
}
示例5: SwaptionHelper
public SwaptionHelper(Period maturity,
Period length,
Handle<Quote> volatility,
IborIndex index,
Period fixedLegTenor,
DayCounter fixedLegDayCounter,
DayCounter floatingLegDayCounter,
Handle<YieldTermStructure> termStructure,
bool calibrateVolatility /*= false*/)
: base(volatility,termStructure, calibrateVolatility)
{
Calendar calendar = index.fixingCalendar();
Period indexTenor = index.tenor();
int fixingDays = index.fixingDays();
Date exerciseDate = calendar.advance(termStructure.link.referenceDate(),
maturity,
index.businessDayConvention());
Date startDate = calendar.advance(exerciseDate,
fixingDays, TimeUnit.Days,
index.businessDayConvention());
Date endDate = calendar.advance(startDate, length,
index.businessDayConvention());
Schedule fixedSchedule=new Schedule(startDate, endDate, fixedLegTenor, calendar,
index.businessDayConvention(),
index.businessDayConvention(),
DateGeneration.Rule.Forward, false);
Schedule floatSchedule=new Schedule(startDate, endDate, index.tenor(), calendar,
index.businessDayConvention(),
index.businessDayConvention(),
DateGeneration.Rule.Forward, false);
IPricingEngine swapEngine=new DiscountingSwapEngine(termStructure);
VanillaSwap temp=new VanillaSwap(VanillaSwap.Type.Receiver, 1.0,
fixedSchedule, 0.0, fixedLegDayCounter,
floatSchedule, index, 0.0, floatingLegDayCounter);
temp.setPricingEngine(swapEngine);
exerciseRate_ = temp.fairRate();
swap_ = new VanillaSwap(VanillaSwap.Type.Receiver, 1.0,
fixedSchedule, exerciseRate_, fixedLegDayCounter,
floatSchedule, index, 0.0, floatingLegDayCounter);
swap_.setPricingEngine(swapEngine);
Exercise exercise=new EuropeanExercise(exerciseDate);
swaption_ = new Swaption(swap_, exercise);
marketValue_ = blackPrice(volatility_.link.value());
}
示例6: MakeVanillaSwap
public MakeVanillaSwap(Period swapTenor, IborIndex index, double? fixedRate, Period forwardStart) {
swapTenor_ = swapTenor;
iborIndex_ = index;
fixedRate_ = fixedRate;
forwardStart_ = forwardStart;
effectiveDate_ = null;
fixedCalendar_ = floatCalendar_ = index.fixingCalendar();
type_ = VanillaSwap.Type.Payer;
nominal_ = 1.0;
fixedTenor_ = new Period(1, TimeUnit.Years);
floatTenor_ = index.tenor();
fixedConvention_ = fixedTerminationDateConvention_ = BusinessDayConvention.ModifiedFollowing;
floatConvention_ = floatTerminationDateConvention_ = index.businessDayConvention();
fixedRule_ = floatRule_ = DateGeneration.Rule.Backward;
fixedEndOfMonth_ = floatEndOfMonth_ = false;
fixedFirstDate_ = fixedNextToLastDate_ = floatFirstDate_ = floatNextToLastDate_ = null;
floatSpread_ = 0.0;
fixedDayCount_ = new Thirty360(Thirty360.Thirty360Convention.BondBasis);
floatDayCount_ = index.dayCounter();
engine_ = new DiscountingSwapEngine(index.forwardingTermStructure());
}
示例7: MakeBasisSwap
public MakeBasisSwap(Period swapTenor, IborIndex index1, IborIndex index2, Period forwardStart)
{
swapTenor_ = swapTenor;
iborIndex1_ = index1;
iborIndex2_ = index2;
forwardStart_ = forwardStart;
effectiveDate_ = null;
float1Calendar_ = float2Calendar_ = index1.fixingCalendar();
type_ = BasisSwap.Type.Payer;
nominal_ = 1.0;
float1Tenor_ = index1.tenor();
float2Tenor_ = index2.tenor();
float1Convention_ = float1TerminationDateConvention_ = index1.businessDayConvention();
float2Convention_ = float2TerminationDateConvention_ = index2.businessDayConvention();
float1Rule_ = float2Rule_ = DateGeneration.Rule.Backward;
float1EndOfMonth_ = float2EndOfMonth_ = false;
float1FirstDate_ = float1NextToLastDate_ = float2FirstDate_ = float2NextToLastDate_ = null;
float1Spread_ = float2Spread_ = 0.0;
float1DayCount_ = index1.dayCounter();
float2DayCount_ = index2.dayCounter();
engine_ = new DiscountingBasisSwapEngine(index1.forwardingTermStructure(), index2.forwardingTermStructure());
}
示例8: 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()));
}
示例9: CapHelper
public CapHelper(Period length,
Handle<Quote> volatility,
IborIndex index,
// data for ATM swap-rate calculation
Frequency fixedLegFrequency,
DayCounter fixedLegDayCounter,
bool includeFirstSwaplet,
Handle<YieldTermStructure> termStructure,
bool calibrateVolatility /*= false*/)
: base(volatility, termStructure, calibrateVolatility)
{
Period indexTenor = index.tenor();
double fixedRate = 0.04; // dummy value
Date startDate, maturity;
if (includeFirstSwaplet) {
startDate = termStructure.link.referenceDate();
maturity = termStructure.link.referenceDate() + length;
} else {
startDate = termStructure.link.referenceDate() + indexTenor;
maturity = termStructure.link.referenceDate() + length;
}
IborIndex dummyIndex=new
IborIndex("dummy",
indexTenor,
index.fixingDays(),
index.currency(),
index.fixingCalendar(),
index.businessDayConvention(),
index.endOfMonth(),
termStructure.link.dayCounter(),
termStructure);
List<double> nominals = new InitializedList<double>(1,1.0);
Schedule floatSchedule=new Schedule(startDate, maturity,
index.tenor(), index.fixingCalendar(),
index.businessDayConvention(),
index.businessDayConvention(),
DateGeneration.Rule.Forward, false);
List<CashFlow> floatingLeg;
IborLeg iborLeg = (IborLeg) new IborLeg(floatSchedule, index)
.withFixingDays(0)
.withNotionals(nominals)
.withPaymentAdjustment(index.businessDayConvention());
floatingLeg = iborLeg.value();
Schedule fixedSchedule=new Schedule(startDate, maturity, new Period(fixedLegFrequency),
index.fixingCalendar(),
BusinessDayConvention.Unadjusted, BusinessDayConvention.Unadjusted,
DateGeneration.Rule.Forward, false);
List<CashFlow> fixedLeg = new FixedRateLeg(fixedSchedule)
.withCouponRates(fixedRate, fixedLegDayCounter)
.withNotionals(nominals)
.withPaymentAdjustment(index.businessDayConvention());
Swap swap = new Swap(floatingLeg, fixedLeg);
swap.setPricingEngine(new DiscountingSwapEngine(termStructure));
double bp = 1.0e-4;
double fairRate = fixedRate - (double)(swap.NPV()/(swap.legBPS(1) / bp));
List<double> exerciceRate = new InitializedList<double>(1,fairRate);
cap_ = new Cap(floatingLeg, exerciceRate);
marketValue_ = blackPrice(volatility_.link.value());
}
示例10: AssetSwap
public AssetSwap(bool payBondCoupon,
Bond bond,
double bondCleanPrice,
IborIndex iborIndex,
double spread,
Schedule floatSchedule = null,
DayCounter floatingDayCount = null,
bool parAssetSwap = true)
: base(2)
{
bond_ = bond;
bondCleanPrice_ = bondCleanPrice;
nonParRepayment_ = 100;
spread_ = spread;
parSwap_ = parAssetSwap;
Schedule schedule = floatSchedule;
if (floatSchedule == null)
schedule = new Schedule(bond_.settlementDate(),
bond_.maturityDate(),
iborIndex.tenor(),
iborIndex.fixingCalendar(),
iborIndex.businessDayConvention(),
iborIndex.businessDayConvention(),
DateGeneration.Rule.Backward,
false); // endOfMonth
// the following might become an input parameter
BusinessDayConvention paymentAdjustment = BusinessDayConvention.Following;
Date finalDate = schedule.calendar().adjust(schedule.endDate(), paymentAdjustment);
Date adjBondMaturityDate = schedule.calendar().adjust(bond_.maturityDate(), paymentAdjustment);
Utils.QL_REQUIRE( finalDate == adjBondMaturityDate, () =>
"adjusted schedule end date (" +
finalDate +
") must be equal to adjusted bond maturity date (" +
adjBondMaturityDate + ")");
// bondCleanPrice must be the (forward) clean price
// at the floating schedule start date
upfrontDate_ = schedule.startDate();
double dirtyPrice = bondCleanPrice_ +
bond_.accruedAmount(upfrontDate_);
double notional = bond_.notional(upfrontDate_);
/* In the market asset swap, the bond is purchased in return for
payment of the full price. The notional of the floating leg is
then scaled by the full price. */
if (!parSwap_)
notional *= dirtyPrice / 100.0;
if (floatingDayCount == null)
legs_[1] = new IborLeg(schedule, iborIndex)
.withSpreads(spread)
.withNotionals(notional)
.withPaymentAdjustment(paymentAdjustment);
else
legs_[1] = new IborLeg(schedule, iborIndex)
.withSpreads(spread)
.withPaymentDayCounter(floatingDayCount)
.withNotionals(notional)
.withPaymentAdjustment(paymentAdjustment);
foreach (CashFlow c in legs_[1])
c.registerWith(update);
List<CashFlow> bondLeg = bond_.cashflows();
foreach (CashFlow c in bondLeg)
{
// whatever might be the choice for the discounting engine
// bond flows on upfrontDate_ must be discarded
bool upfrontDateBondFlows = false;
if (!(c.hasOccurred(upfrontDate_, upfrontDateBondFlows)))
legs_[0].Add(c);
}
Utils.QL_REQUIRE( !legs_[0].empty(), () => "empty bond leg to start with" );
// special flows
if (parSwap_)
{
// upfront on the floating leg
double upfront = (dirtyPrice - 100.0) / 100.0 * notional;
CashFlow upfrontCashFlow = new SimpleCashFlow(upfront, upfrontDate_);
legs_[1].Insert(0, upfrontCashFlow);
// backpayment on the floating leg
// (accounts for non-par redemption, if any)
double backPayment = notional;
CashFlow backPaymentCashFlow = new SimpleCashFlow(backPayment, finalDate);
legs_[1].Add(backPaymentCashFlow);
}
else
{
// final notional exchange
CashFlow finalCashFlow = new SimpleCashFlow(notional, finalDate);
legs_[1].Add(finalCashFlow);
}
Utils.QL_REQUIRE( !legs_[0].empty(), () => "empty bond leg" );
//.........這裏部分代碼省略.........