Skip to content

Commit

Permalink
check if end of calendar day before moving
Browse files Browse the repository at this point in the history
  • Loading branch information
DeimosXing committed Feb 26, 2024
1 parent cddfec4 commit 4ed9da4
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions ql/time/calendar.cpp
Expand Up @@ -159,11 +159,12 @@ namespace QuantLib {
Date d1 = d + n*unit;

// we are sure the unit is Months or Years
if (endOfMonth && isEndOfMonth(d)){
if (c == Unadjusted){
// move to end of calendar day if using Unadjusted convention
if (endOfMonth){
if (c == Unadjusted && Date::isEndOfMonth(d)){
// move to end of calendar day if using Unadjusted convention and d is last calendar day
return Date::endOfMonth(d1);
} else {
} else if (isEndOfMonth(d)) {
// move to end of business day if d is last bussiness day
return Calendar::endOfMonth(d1);
}
}
Expand Down

0 comments on commit 4ed9da4

Please sign in to comment.