【发布时间】:2020-06-18 07:55:13
【问题描述】:
关于 C++ Quantlib 中的 date-advance 函数,我有一个小问题。 我想为具有付款工作日约定“在先”的产品使用付款抵消(以天为单位),但付款日期始终设置为周末后的第一天,而付款日期在周末。这是因为当“days”被移交给“advance”函数时,“advance”函数会忽略工作日约定,请参见此处:
Date Calendar::advance(const Date& d,
Integer n, TimeUnit unit,
BusinessDayConvention c,
bool endOfMonth) const {
QL_REQUIRE(d!=Date(), "null date");
if (n == 0) {
return adjust(d,c);
} else if (unit == Days) {
Date d1 = d;
if (n > 0) {
while (n > 0) {
d1++;
while (isHoliday(d1))
d1++;
n--;
}
} else {
while (n < 0) {
d1--;
while(isHoliday(d1))
d1--;
n++;
}
}
return d1;
} else if (unit == Weeks) {
Date d1 = d + n*unit;
return adjust(d1,c);
} else {
Date d1 = d + n*unit;
// we are sure the unit is Months or Years
if (endOfMonth && isEndOfMonth(d))
return Calendar::endOfMonth(d1);
return adjust(d1, c);
}
}
这是故意实施的吗? 附: “调整”- 函数正确使用工作日约定!
【问题讨论】:
标签: python c++ quantlib quantlib-swig