Python Quantlib ->TypeError:重载函数“new_Thirty360”的参数数量或类型错误

dar*_*uss 1 python quantlib

我正在尝试运行下面的代码,但由于某种原因,在一台电脑上它运行正常,在第二台电脑上它失败并显示以下错误消息;1台电脑正常运行,第2台就失败的原因是什么?

代码来源:http://gouthamanbalaraman.com/blog/quantlib-bond-modeling.html

!pip install QuantLib
import QuantLib as ql
todaysDate = ql.Date(15, 1, 2015)
ql.Settings.instance().evaluationDate = todaysDate
spotDates = [ql.Date(15, 1, 2015), ql.Date(15, 7, 2015), ql.Date(15, 1, 2016)]
spotRates = [0.0, 0.005, 0.007]
dayCount = ql.Thirty360()
calendar = ql.UnitedStates()
interpolation = ql.Linear()
compounding = ql.Compounded
compoundingFrequency = ql.Annual
spotCurve = ql.ZeroCurve(spotDates, spotRates, dayCount, calendar, interpolation,
                             compounding, compoundingFrequency)
spotCurveHandle = ql.YieldTermStructureHandle(spotCurve)


> TypeError: Wrong number or type of arguments for overloaded function
> 'new_Thirty360'.   Possible C/C++ prototypes are:
>     QuantLib::Thirty360::Thirty360(QuantLib::Thirty360::Convention,Date
> const &)
>     QuantLib::Thirty360::Thirty360(QuantLib::Thirty360::Convention)
Run Code Online (Sandbox Code Playgroud)

Lui*_*bio 7

根据发行说明,这预计在 1.28 版本中出现(请参阅https://github.com/lballabio/QuantLib-SWIG/releases/tag/QuantLib-SWIG-v1.28)。默认构造函数在底层 C++ 库中不再可用,因此在 1.23 版本中已弃用它们。

理由是存在多种不同的 30/360 惯例。默认构造函数用于选择一种特定约定(即 30/360 债券基础),但这使得用户可能只指定 30/360 并在不知不觉中获得错误的日期计数器。自此版本以来,您需要指定确切的约定。如果您想要像以前一样的行为,请替换ql.Thirty360()ql.Thirty360(ql.Thirty360.BondBasis)。相反,如果您意识到这些不是您想要的实际约定,请将正确的约定传递给日计数器的构造函数。

这同样适用于ql.ActualActual(),它过去默认为 ISDA,但在 1.28 中需要明确的约定:ql.ActualActual(ql.ActualActual.ISDA)