QuantLib:建立关键利率风险 [英] QuantLib: Building Key Rate Risks

查看:245
本文介绍了QuantLib:建立关键利率风险的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我能够为国库券市场建立折扣曲线.但是,我希望以此来查找单个债券(以及最终债券组合)的关键利率风险.

I was able to build a discount curve for the Treasury market. However, I'm looking to use this to find the key rate risks of an individual bond (and eventually a portfolio of bonds).

我要寻找的关键利率风险是,如果我有一个30年期债券,而我们将用于折现该债券的1年期利率转移了,同时保持其他利率不变,那么该债券的价格变化了多少? ?对期限(例如2Y,5Y,7Y等)重复此操作,并对结果求和,可以使您了解债券的总期限,但可以更好地了解风险敞口如何分解.

The key rate risk I'm looking for is if I have a 30Y bond and we shift the 1y rate that was used to discount the bond, while holding the other rates constant, how much does the price of the bond change by? Repeating this for the tenors (eg. 2Y, 5Y, 7Y, etc) and summing the result should get you to the overall duration of the bond, but provides a better view of how the risk exposure breaks down.

http://www.investinganswers.com/financial -dictionary/bonds/key-rate-duration-6725

有人知道任何演示该操作方法的文档吗?谢谢你.

Is anyone aware of any documentation that demonstrates how to do this? Thank you.

推荐答案

鉴于您已经建立了债券和贴现曲线,并且已将它们链接起来,类似于:

Given that you have already built the bond and the discount curve, and you have linked them in some way similar to:

discount_handle = RelinkableYieldTermStructureHandle(discount_curve)

bond.setPricingEngine(DiscountingBondEngine(discount_handle))

您可以先在现有折现曲线上添加一个价差,然后使用修改后的曲线对债券定价.像这样:

you can first add a spread over the existing discount curve and then use the modified curve to price the bond. Something like:

nodes = [ 1, 2, 5, 7, 10 ]  # the durations
dates = [ today + Period(n, Years) for n in nodes ]
spreads = [ SimpleQuote(0.0) for n in nodes ] # null spreads to begin

new_curve = SpreadedLinearZeroInterpolatedTermStructure(
    YieldTermStructureHandle(discount_curve),
    [ QuoteHandle(q) for q in spreads ],
    dates)

将为您提供一条新的曲线,其初始点差都为0(以及可怕的类别名称),您可以使用它代替原始的折扣曲线:

will give you a new curve with initial spreads all at 0 (and a horrible class name) that you can use instead of the original discount curve:

discount_handle.linkTo(new_curve)

在上述情况之后,债券应仍返回相同的价格(因为点差全为空).

After the above, the bond should still return the same price (since the spreads are all null).

当您要计算特定的键率持续时间时,可以移动相应的报价:例如,如果要更改5年报价(上面列表中的第三个),请执行

When you want to calculate a particular key-rate duration, you can move the corresponding quote: for instance, if you want to bump the 5-years quote (the third in the list above), execute

spreads[2].setValue(0.001)   # 10 bps

曲线将相应更新,债券价格应发生变化.

the curve will update accordingly, and the bond price should change.

注意:以上内容将在点差之间进行插值,因此,如果将5年点移动10个基点,而保持2年点不变,则3年左右的利率将移动大约3个基点.为了缓解这种情况(如果这不是您想要的),可以向曲线添加更多点并限制变化的范围.例如,如果您在5年减去一个月加上一个点,再在5年加上1个月加上一个点,那么移动5年点只会影响围绕它的两个月.

A note: the above will interpolate between spreads, so if you move the 5-years points by 10 bps and you leave the 2-years point unchanged, then a rate around 3 years would move by about 3 bps. To mitigate this (in case that's not what you want), you can add more points to the curve and restrict the range that varies. For instance, if you add a point at 5 years minus one month and another at 5 years plus 1 month, then moving the 5-years point will only affect the two months around it.

这篇关于QuantLib:建立关键利率风险的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆