在 python 中使用 quantlib 如何获取两个日期之间的天数?

Using quantlib in python how do i get the number of days between two dates?

我已经试过了,但是没用

将 QuantLib 导入为 ql

ql.Thirty360().yearFraction((6, 6, 2020),(7, 7, 2020))

您需要使用

tuple 值转换为 ql.Date
date = ql.Date(day, month, year)

因此,您的代码将变为:

import QuantLib as ql

ql.Thirty360().yearFraction(ql.Date(6, 6, 2020), ql.Date(7, 7, 2020))

有关更多信息,请参阅文档:https://quantlib-python-docs.readthedocs.io/en/latest/dates.html