简体   繁体   English

Python Quantlib:如何处理 RuntimeError 'addFixing(date, value)'

[英]Python Quantlib : How to deal with RuntimeError 'addFixing(date, value)'

for t_ccy in rate_dates.keys():
    libor_base = ql.AUDLibor(ql.Period(3,ql.Months),ql.YieldTermStructureHandle(term_structure[t_ccy]))
    libor_up = ql.AUDLibor(ql.Period(3,ql.Months),ql.YieldTermStructureHandle(term_structure_up[t_ccy])) 
    for key in hist_rates_dict.keys():
        try:     
            libor_base.addFixing(key,hist_rates_dict[key])
            libor_up.addFixing(key,hist_rates_dict[key])
        except:
            print("Following Exception in Schedule creation " +str (key))
            print((sys.exc_info()))

RuntimeError('At least one invalid fixing provided: Monday May 6th, 2019, 0.015491',). RuntimeError('至少提供了一个无效的修复:2019 年 5 月 6 日星期一,0.015491',)。

This date is from the 'hist_rates_dict' where the 'key' are the Dates and 'values' are the Rates.该日期来自“hist_rates_dict”,其中“键”是日期,“值”是费率。 How to deal with this exception.如何处理这个异常。 Thanks in advance.提前致谢。

ql.AUDLibor is probably not the index you're looking for. ql.AUDLibor可能不是您要查找的索引。 That's the BBA LIBOR index that was discontinued in 2013. It was based on the London calendar...那是 2013 年停止使用的 BBA LIBOR 指数。它基于伦敦日历......

>>> import QuantLib as ql
>>> libor = ql.AUDLibor(ql.Period(3,ql.Months))
>>> print(libor.fixingCalendar())
London stock exchange calendar

...and May 6, 2019 is bank holiday in UK... ...而 2019 年 5 月 6 日是英国的银行假期...

>>> print(ql.UnitedKingdom().isBusinessDay(ql.Date(6, ql.May, 2019)))
False

...so it wouldn't be a valid fixing date for AUD LIBOR, were it still alive. ...所以它不会是 AUD LIBOR 的有效定价日期,如果它仍然存在的话。

>>> libor.isValidFixingDate(ql.Date(6, ql.May, 2019))
False

You're probably trying to load fixing for some other AUD index that replaced the BBA LIBOR and that it's not provided by the library as a class of its own.您可能正在尝试为其他一些替代 BBA LIBOR 的 AUD 索引加载修复程序,并且它不是由库作为自己的类提供的。 Once you figure out its conventions (such as fixing calendar and such) you can create it as an instance of the generic Ibor class.一旦确定了它的约定(例如固定日历等),您就可以将其创建为通用Ibor类的实例。

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

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