我遇到了從具有發言權的債券產生現金流的問題。使用QuantLib爲地板FloatingRateBonds計算現金流
我最初有一個問題,因爲我忽視了設置定價。我已經設置瞭如下價格。
ql_bond = QuantLib.FloatingRateBond(settlement_days, #settlementDays
face_amount, # faceAmount
ql_schedule,
ql_index,
QuantLib.Thirty360(),
gearings = [],
spreads = [libor_spread],
caps = [],
floors = [libor_floor]
)
volatility = 0
vol = QuantLib.ConstantOptionletVolatility(settlement_days,
QuantLib.UnitedKingdom(),
QuantLib.Unadjusted,
volatility,
QuantLib.Thirty360())
pricer = QuantLib.BlackIborCouponPricer(QuantLib.OptionletVolatilityStructureHandle(vol))
QuantLib.setCouponPricer(ql_bond.cashflows(), pricer)
在某些現金流量上,我能夠產生一個合理的現金流量。其他時間,但我遇到一個錯誤。給定的值(-.0225)等於libor_floor - libor_spread。我很確定我在這裏犯了一個明顯的錯誤,但不知道從哪裏開始。如果有人更熟悉QuantLib有任何建議,他們將不勝感激。
Traceback (most recent call last):
File "C:\Users\Ryan\git\optimizer\src\calcs\cashflow_calcs.py", line 161, in generate_cashflow
cashflows.append(utils.cashflow.InterestCashflow(cf_date, cf.amount(), cf_fixing_date, c.indexFixing(), c.accrualDays()))
File "C:\Users\Ryan\Anaconda3\lib\site-packages\QuantLib\QuantLib.py", line 8844, in amount
return _QuantLib.CashFlow_amount(self)
RuntimeError: strike + displacement (-0.0225 + 0) must be non-negative
這涉及到一個較早的文章中,我提出 Using QuantLib to compute cash flows for FloatingRateBond with Floor