bootstrapping - 使用债券投资组合在 QuantLib 中引导收益率曲线
问题描述
我正在尝试使用 2021 年、2022 年、2023 年等到期的债券批次在 Quantlib 中引导政府债券收益率曲线,但收益率曲线引导通常会失败,并显示“根不括号”消息,即使捆绑中的单个债券似乎被市场合理定价。我还注意到,例如,Quantlib 将我的第一个捆绑包(大约 2021 年到期债券)的 YTM 计算为大约 3%,即使其中没有一个超过 YTM 0.5%。
这是我创建债券投资组合/捆绑的代码:
for i, row in rows.iterrows():
newMaturityDate = parse_date(row["MaturityDate"])
date = parse_date(row["CouponPeriodEndDate"])
if date == newMaturityDate and date != maturityDate:
if date in amortizingPayments:
amortizingPayments[date] += 100.0
else:
amortizingPayments[date] = 100.0
notional += 100.0
elif date == maturityDate:
notionalAtMaturity += 100.0
notional += 100.0
for d in amortizingPayments:
p = amortizingPayments[d]
cashflows += [ql.AmortizingPayment(p, d)]
for i, row in rows.iterrows():
rate = parse_perc_float(row["couponrate"])
startDate = parse_date(row["CouponPeriodStartDate"])
date = parse_date(row["CouponPeriodEndDate"])
cashflows += [ql.FixedRateCoupon(date, 100.0, rate, dayCounter,
startDate, date,
startDate, date,
date)]
cashflows += [ql.Redemption(notionalAtMaturity, maturityDate)]
bundle = ql.Bond(3, ql.TARGET(), notional, maturityDate, issueDate, cashflows)
在进行引导时,我将捆绑的净价格等于单个债券的净价格的平均值。
有什么方法可以在 QuantLib 中完成我想要实现的目标,还是有一些基本/技术原因没有?
解决方案
推荐阅读
- pytorch - 如何在 Coral 开发板中安装 PyTorch
- python - 如果需要太长时间,如何在 python 中终止 exec() 函数?
- c++ - isalpha() 函数不适用于字符串中的空格
- wordpress - 您如何使用 WordPress 为每个用户注册创建帐户仪表板?
- mysql - 在 Rails 中存储连接模型数据
- git - 我可以在 Visual Studio 中运行 Git 命令吗?
- r - R data.table:通过分组有效地访问和更新 j 表达式中的变量列名
- discord - 使用不和谐机器人向用户发送消息
- ios - 使用 Storyboard 自动将行项目添加到 TableView 的任何快捷方式?
- java - 带有链式方法的 JMockit