简体   繁体   中英

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',).

This date is from the 'hist_rates_dict' where the 'key' are the Dates and 'values' are the Rates. How to deal with this exception. Thanks in advance.

ql.AUDLibor is probably not the index you're looking for. That's the BBA LIBOR index that was discontinued in 2013. It was based on the London calendar...

>>> 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...

>>> 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.

>>> 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. Once you figure out its conventions (such as fixing calendar and such) you can create it as an instance of the generic Ibor class.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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