简体   繁体   English

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

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

i have tried this but it isnt working我已经尝试过了,但它不起作用

import QuantLib as ql将 QuantLib 导入为 ql

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

You need to convert your tuple values to ql.Date values using您需要使用将您的tuple值转换为ql.Date

date = ql.Date(day, month, year)

So, your code would become:因此,您的代码将变为:

import QuantLib as ql

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

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM