本文整理汇总了C#中Bond.maturityDate方法的典型用法代码示例。如果您正苦于以下问题:C# Bond.maturityDate方法的具体用法?C# Bond.maturityDate怎么用?C# Bond.maturityDate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Bond
的用法示例。
在下文中一共展示了Bond.maturityDate方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BondHelper
/*! \warning Setting a pricing engine to the passed bond from
external code will cause the bootstrap to fail or
to give wrong results. It is advised to discard
the bond after creating the helper, so that the
helper has sole ownership of it.
*/
public BondHelper(Handle<Quote> cleanPrice, Bond bond) : base(cleanPrice) {
bond_ = bond;
latestDate_ = bond_.maturityDate();
initializeDates();
IPricingEngine bondEngine = new DiscountingBondEngine(termStructureHandle_);
bond_.setPricingEngine(bondEngine);
}
示例2: accrualPeriod
public static double accrualPeriod(Bond bond, Date settlementDate = null)
{
if (settlementDate == null)
settlementDate = bond.settlementDate();
Utils.QL_REQUIRE(BondFunctions.isTradable(bond, settlementDate),
"non tradable at " + settlementDate +
" (maturity being " + bond.maturityDate() + ")");
return CashFlows.accrualPeriod(bond.cashflows(), false, settlementDate);
}
示例3: 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" );
//.........这里部分代码省略.........
示例4: zSpread
public static double zSpread(Bond bond, double cleanPrice, YieldTermStructure discount, DayCounter dayCounter, Compounding compounding,
Frequency frequency, Date settlementDate = null, double accuracy = 1.0e-10, int maxIterations = 100,
double guess = 0.0)
{
if (settlementDate == null)
settlementDate = bond.settlementDate();
Utils.QL_REQUIRE( BondFunctions.isTradable( bond, settlementDate ), () =>
"non tradable at " + settlementDate +
" (maturity being " + bond.maturityDate() + ")");
double dirtyPrice = cleanPrice + bond.accruedAmount(settlementDate);
dirtyPrice /= 100.0 / bond.notional(settlementDate);
return CashFlows.zSpread(bond.cashflows(),
discount,
dirtyPrice,
dayCounter, compounding, frequency,
false, settlementDate, settlementDate,
accuracy, maxIterations, guess);
}
示例5: cleanPrice
public static double cleanPrice(Bond bond, YieldTermStructure discount, double zSpread, DayCounter dayCounter, Compounding compounding,
Frequency frequency, Date settlementDate = null)
{
if (settlementDate == null)
settlementDate = bond.settlementDate();
Utils.QL_REQUIRE( BondFunctions.isTradable( bond, settlementDate ), () =>
"non tradable at " + settlementDate +
" (maturity being " + bond.maturityDate() + ")");
double dirtyPrice = CashFlows.npv(bond.cashflows(), discount, zSpread, dayCounter, compounding, frequency, false, settlementDate) *
100.0 / bond.notional(settlementDate);
return dirtyPrice - bond.accruedAmount(settlementDate);
}
示例6: yieldValueBasisPoint
public static double yieldValueBasisPoint(Bond bond, InterestRate yield, Date settlementDate = null)
{
if (settlementDate == null)
settlementDate = bond.settlementDate();
Utils.QL_REQUIRE( BondFunctions.isTradable( bond, settlementDate ), () =>
"non tradable at " + settlementDate +
" (maturity being " + bond.maturityDate() + ")");
return CashFlows.yieldValueBasisPoint(bond.cashflows(), yield,
false, settlementDate);
}
示例7: duration
public static double duration(Bond bond, InterestRate yield, Duration.Type type = Duration.Type.Modified,
Date settlementDate = null)
{
if (settlementDate == null)
settlementDate = bond.settlementDate();
Utils.QL_REQUIRE( BondFunctions.isTradable( bond, settlementDate ), () =>
"non tradable at " + settlementDate +
" (maturity being " + bond.maturityDate() + ")");
return CashFlows.duration(bond.cashflows(), yield, type, false, settlementDate);
}
示例8: dirtyPrice
public static double dirtyPrice(Bond bond, InterestRate yield, Date settlementDate = null)
{
if (settlementDate == null)
settlementDate = bond.settlementDate();
Utils.QL_REQUIRE( BondFunctions.isTradable( bond, settlementDate ), () =>
"non tradable at " + settlementDate +
" (maturity being " + bond.maturityDate() + ")");
double dirtyPrice = CashFlows.npv(bond.cashflows(), yield, false, settlementDate) *
100.0 / bond.notional(settlementDate);
return dirtyPrice;
}
示例9: atmRate
public static double atmRate(Bond bond, YieldTermStructure discountCurve, Date settlementDate = null, double? cleanPrice = null)
{
if (settlementDate == null)
settlementDate = bond.settlementDate();
Utils.QL_REQUIRE( BondFunctions.isTradable( bond, settlementDate ), () =>
"non tradable at " + settlementDate +
" (maturity being " + bond.maturityDate() + ")");
double? dirtyPrice = cleanPrice == null ? null : cleanPrice + bond.accruedAmount(settlementDate);
double currentNotional = bond.notional(settlementDate);
double? npv = dirtyPrice / 100.0 * currentNotional;
return CashFlows.atmRate(bond.cashflows(), discountCurve, false, settlementDate, settlementDate, npv);
}
示例10: bps
public static double bps(Bond bond, YieldTermStructure discountCurve, Date settlementDate = null)
{
if (settlementDate == null)
settlementDate = bond.settlementDate();
Utils.QL_REQUIRE( BondFunctions.isTradable( bond, settlementDate ), () =>
"non tradable at " + settlementDate +
" (maturity being " + bond.maturityDate() + ")");
return CashFlows.bps(bond.cashflows(), discountCurve, false, settlementDate) * 100.0 / bond.notional(settlementDate);
}
示例11: accruedAmount
public static double accruedAmount(Bond bond, Date settlementDate = null)
{
if (settlementDate == null)
settlementDate = bond.settlementDate();
Utils.QL_REQUIRE( BondFunctions.isTradable( bond, settlementDate ), () =>
"non tradable at " + settlementDate +
" (maturity being " + bond.maturityDate() + ")");
return CashFlows.accruedAmount(bond.cashflows(), false, settlementDate) * 100.0 / bond.notional(settlementDate);
}
示例12: referencePeriodStart
public static Date referencePeriodStart(Bond bond, Date settlementDate = null)
{
if (settlementDate == null)
settlementDate = bond.settlementDate();
Utils.QL_REQUIRE( BondFunctions.isTradable( bond, settlementDate ), () =>
"non tradable at " + settlementDate +
" (maturity being " + bond.maturityDate() + ")");
return CashFlows.referencePeriodStart(bond.cashflows(), false, settlementDate);
}