量化庫

如何在 python 中使用 QuantLib.IborIndex?

  • March 10, 2020

QuantLib 使用者。

我正在嘗試ql.IborIndex(...)使用此範例,但用於美元貨幣。但是,我收到以下類型錯誤。我怎樣才能用這個代替ql.USDLibor(...)?謝謝你。

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
c:\Users\sc92841\repos\market-risk-model-validation\jira_models\abr409.py in 
----> 1 ql.IborIndex('USDLibor', ql.Period('1M'), 2, ql.USDCurrency, ql.UnitedKingdom(), ql.ModifiedFollowing,  True, ql.Actual360())

~\AppData\Local\Continuum\anaconda3\lib\site-packages\QuantLib\QuantLib.py in __init__(self, *args)
  5431 
  5432     def __init__(self, *args):
-> 5433         _QuantLib.IborIndex_swiginit(self, _QuantLib.new_IborIndex(*args))
  5434 
  5435     def businessDayConvention(self):

TypeError: Wrong number or type of arguments for overloaded function 'new_IborIndex'.
 Possible C/C++ prototypes are:
   IborIndex::IborIndex(std::string const &,Period const &,Integer,Currency const &,Calendar const &,BusinessDayConvention,bool,DayCounter const &,Handle< YieldTermStructure > const &)
   IborIndex::IborIndex(std::string const &,Period const &,Integer,Currency const &,Calendar const &,BusinessDayConvention,bool,DayCounter const &)

要創建貨幣類的實例,您必須呼叫它:

嘗試ql.USDCurrency()代替ql.USDCurrency

您可以查看此站點以獲取有關 QuantLib Python 模組的對象構造的參考。

https://quantlib-python-docs.readthedocs.io

引用自:https://quant.stackexchange.com/questions/51568