I'm encountering an issue generating cash flows from bonds with a floor.
I initially had an issue because I neglected to set a pricer. I've since set a pricer as below.
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)
On certain cash flows, I am able to generate a reasonable amount for the cashflow. Other times however I encounter an error. The value given for the strike (-.0225) equals libor_floor - libor_spread. I'm pretty sure I'm making an obvious mistake here but not sure where to start. If anyone more familiar with QuantLib has any suggestions they would be greatly appreciated.
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
This is related to an earlier post I made Using QuantLib to compute cash flows for FloatingRateBond with Floor