QUANTLIB固定曲置与Excel产量()
我目前正在尝试使用Quantlib库来计算Python中国库券的产量。作为参考,我使用了Excel屈服功能,但是我对相同的输入值获得了不同的结果。
我不明白为什么我会得到不同的结果,而我不明白这种差异的来源。
我使用两个列使用收益函数,YTM列和一个实际产量列。我将从ytm开始。
我知道已经存在类似的问题,例如接下来的两个链接,但这并不能解决我的问题。
ytm
在Excel I中使用以下值:
=YIELD(valuedate, maturitydate, rate, price, redemption, coupons, 3)
- proditaludate = 26/11/11/11/11/ 2021年
- 截止日期= 26/01/2026
- 速率= 0.000%
- 价格= 45.340
- 赎回= 100
- 优惠券= 1
- daycount = 3 = 3 =实际365,
使用这些值,我得到了 ytm的20.903%。
为了在Python中复制这一点,我使用了此代码:。
#Dates
start = 26/11/2021
maturity = 26/01/2026
#Yield Params
redemption = 100
coup = 1
price = 45.340
couponRate = 0.000%
rate = [couponRate]
calendar = ql.NullCalendar()
settlementDays = 0
tenor = ql.Period(ql.Annual)
fixedRateBond = ql.FixedRateBond(settlementDays, calendar, redemption, start, maturity, tenor, rate, ql.Actual365Fixed())
fixedRateBond.bondYield(price,
ql.Actual365Fixed(),
ql.SimpleThenCompounded, #SimpleThenCompounded gives best result yet
ql.Annual,
start,
1.0e-16,
100
)
使用Quantlib,使用与Excel产量相同的值,我获得了 20.827%的产率,这是 0.075%的小差异。
但,当查看实际产量时,使用与YTM相同的参数会获得更大的差异。
因此,在试用和错误的同样心态下,我使用了略有不同的参数,这些参数返回了我能获得的最佳结果。
实际收益率
excel值:(
=YIELD(quotationdate+3, maturitydate, rate, quotationprice, redemption, coupons, 3)
注意:我们这样做+3,因为计算的兴趣是在结算中计算的)
- QuordationDate = 2/3/2022
- MaturityDate = 16/10/2049
- 速率= 3.897%
- Quoleprice = 3.897 % 15
- 赎回= 100
- 票票= 1
- 日倒= 3 =
的
365
ql.Settings.instance().evaluationDate = 2/3/2022
start = 2/3/2022
maturity = 16/10/2049
coup = 1
price = 15
couponRate = 3.897%
rate = [couponRate]
settlementDays = 3
calendar = ql.NullCalendar()
businessConvention = ql.Unadjusted
dateGeneration = ql.DateGeneration.Backward
monthEnd = False
redemption = 100
tenor = ql.Period(ql.Annual)
schedule = ql.Schedule(start,
maturity,
tenor,
calendar,
businessConvention,
businessConvention,
dateGeneration,
monthEnd)
bond = ql.FixedRateBond(settlementDays, redemption, schedule, rate, ql.Actual365Fixed())
bond.bondYield(price,
ql.Actual365Fixed(),
ql.Compounded,
ql.Annual)
实际 0.324%
我想强调我没有财务背景。我通过其他类似的Stackoverflow问题以及大量的反复试验获得了这些参数。
使用Quantlib中相同的参数以获得与YTM中使用的实际产率相比,结果比这些参数更差。
有人可以向我解释我应该使用哪些参数来复制Excel targe()函数,以及为什么我在Quantlib和Excel之间存在差异?
另外,Excel功能是否正确正确?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
从Excel的文档中,尚不清楚他们对ACT/365的定义是什么,但通常是ACT/365实际上是ACT/ACT ISDA,它与ACT/365F完全不同。
可能存在许多不同的实现(请参阅Rates Lib vs Quantlib的源代码):
wikipedia> wikipedia
=“ https://github.com/attack68/rateslib/blob/main/main/python/rateslib/calendars.py” rel =“ nofollow noreferrer”> rateslib python
noroflow noreferrer“> pontlib c ++ </
a发行的管辖权(b)和贸易场所。此外,大型国际公司(货币中心银行)可能还依靠标准化的AIBD公约,这可能与国内标准略有不同。
不幸的是,全球债券收益率计算中没有市场标准化。
我对这个问题的回答是使用最常见的实现 - 在YAS屏幕中提供BBG的帮助 - 大多数FI交易者将其用作其“黄金标准”。这就是我要复制的。
las,债券交易的约定差额应为80-120。但是,$ 45的某种交易的国库肯定是垃圾,而在任何场所的任何合理的出价/报价中,8bps的约定都将很好,而且我不会为此投入过多的精力。约定套利的概率接近零。
From Excel's documentation it is not clear what their definition of ACT/365 is, but commonly ACT/365 is in fact ACT/ACT ISDA, which is quite different than ACT/365F.
There may exist many different implementations (see source code of RatesLib vs Quantlib):
wikipedia
rateslib python
quantlib c++
Generally, IMHO, YTM calculation bases are subjective based on (a) jurisdiction of issuance, (b) and venue of trade. Further, large international firms (money center banks) may additionally rely on standardized AIBD conventions which may be different slightly from domestic standards.
Unfortunately there is no market standardization in bond yield calculations globally.
My answer to this question would be to use the most common implementation -- HELP in BBG in YAS screen--as most FI traders use that as their 'gold standard'. This is what I would replicate.
Alas, the convention difference on a bond trading 80-120 should be <1bp. But a treasury of some kind trading at $45 is certainly junk, and 8bps of convention would be well within any reasonable bid/offer on any venue, and I wouldn't put too much energy into it. Probability of convention arbitrage is near zero.