32 : defaultTS_(
std::move(defaultTS)),
33 recoveryRate_(recoveryRate),
34 yieldTS_(
std::move(yieldTS)) {
43 Date d1 = std::max(npvDate, startDate);
46 Real settlementValue = 0.0;
51 Real weightedCouponAmount = cf->amount() *
defaultTS()->survivalProbability(d2);
52 NPV += weightedCouponAmount *
yieldTS()->discount(d2);
53 if (d2 > settlementDate)
54 settlementValue += weightedCouponAmount *
yieldTS()->discount(d2);
56 auto coupon = ext::dynamic_pointer_cast<Coupon>(cf);
57 if (coupon !=
nullptr) {
58 Date defaultDate = d1 + (d2 - d1) / 2;
62 NPV += weightedRecovery *
yieldTS()->discount(defaultDate);
63 if (d2 > settlementDate)
64 settlementValue += weightedRecovery *
yieldTS()->discount(defaultDate);
Cash-flow analysis functions.
static Date startDate(const Leg &leg)
Bond::arguments arguments_
Shared handle to an observable.
std::pair< iterator, bool > registerWith(const ext::shared_ptr< Observable > &)
Handle< DefaultProbabilityTermStructure > defaultTS() const
void calculate() const override
Handle< DefaultProbabilityTermStructure > defaultTS_
Handle< YieldTermStructure > yieldTS() const
Real recoveryRate() const
RiskyBondEngine(Handle< DefaultProbabilityTermStructure > defaultTS, Real recoveryRate, Handle< YieldTermStructure > yieldTS)
Handle< YieldTermStructure > yieldTS_
Coupon accruing over a fixed period.