Skip to content

Commit

Permalink
Manage accrual ex-coupon between end coupon date and payment date.
Browse files Browse the repository at this point in the history
  • Loading branch information
lballabio committed Aug 8, 2020
1 parent a081649 commit e6353d1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion ql/cashflows/fixedratecoupon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,15 @@ namespace QuantLib {

Real FixedRateCoupon::accruedAmount(const Date& d) const {
if (d <= accrualStartDate_ || d > paymentDate_) {
// out of coupon range
return 0.0;
} else if (tradingExCoupon(d)) {
return -nominal()*(rate_.compoundFactor(d,
accrualEndDate_,
std::max(d, accrualEndDate_),
refPeriodStart_,
refPeriodEnd_) - 1.0);
} else {
// usual case
return nominal()*(rate_.compoundFactor(accrualStartDate_,
std::min(d,accrualEndDate_),
refPeriodStart_,
Expand Down
4 changes: 3 additions & 1 deletion ql/cashflows/floatingratecoupon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,14 @@ namespace QuantLib {

Real FloatingRateCoupon::accruedAmount(const Date& d) const {
if (d <= accrualStartDate_ || d > paymentDate_) {
// out of coupon range
return 0.0;
} else if (tradingExCoupon(d)) {
return -nominal() * rate() *
dayCounter().yearFraction(d, accrualEndDate_,
dayCounter().yearFraction(d, std::max(d, accrualEndDate_),
refPeriodStart_, refPeriodEnd_);
} else {
// usual case
return nominal() * rate() *
dayCounter().yearFraction(accrualStartDate_,
std::min(d, accrualEndDate_),
Expand Down

0 comments on commit e6353d1

Please sign in to comment.