Using QuantLib to compute cash flows for FloatingRateBond with Floor

女生的网名这么多〃 提交于 2019-12-04 14:57:55

The theory first: when pricing the coupon with a floor, you can't just take the expected LIBOR rate from your forecast curve and take the minimum between that and the floor. Instead, you need to take the expected value of the minimum between the rate and the floor, and unfortunately E[min(R,F)] is not the same as min(E[R],F). So no, the floor doesn't just provide a minimum; you need a different formula to estimate the expected payoff.

The implication for QuantLib is that simple floating-rate coupons can be (and are) set a default pricer that just reads the rate off the forecast curve, but coupons with caps or floors need the user to specify what pricer to use and to provide it with any additional needed data; in your case, this means at least a volatility term structure, although more optional data can be specified; see the constructor of the BlackIborCouponPricer class for details.

Usually, the volatility is bootstrapped on market quotes for caps and floors, but the procedure to create it is kind of complex (see these tests for an example in C++), I'm not sure that all the needed classes are exported to Python, and you'll be better off asking about it on the QuantLib mailing list.

If you want to verify that the coupons can works, you can use a constant volatility, as in:

volatility = 0.10;
vol = QuantLib.ConstantOptionletVolatility(settlement_days,
                                           calendar,
                                           QuantLib.ModifiedFollowing,
                                           volatility,
                                           day_count)

pricer = QuantLib.BlackIborCouponPricer(
    QuantLib.OptionletVolatilityStructureHandle(vol))
QuantLib.setCouponPricer(ql_bond.cashflows(), pricer)

The above should enable you to get a result; but of course I pulled the 15% volatility out of a hat, and it won't give you actual market values...

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!