固定收益

Quantlib 將清潔價格與 bbg 清潔價格匹配

  • November 4, 2021

我正在嘗試將 QL 清潔價格與 2021 年 10 月 15 日定價的 POLGB 2.75 10/25/29 1029 的 BBG 清潔價格相匹配,收益率為 2.5%。我不確定我的債券設置是否錯誤,或者計算精度是否存在問題。

import QuantLib as ql

todaysDate= ql.Date(15,10,2021)

ql.Settings.instance().setEvaluationDate(todaysDate)

issueDate = ql.Date(11, 2, 2019)
maturityDate = ql.Date(25, 10, 2029)
tenor = ql.Period(ql.Annual)
calendar = ql.Poland()
bussinessConvention = ql.Following
dateGeneration = ql.DateGeneration.Backward
monthEnd = False
schedule = ql.Schedule (ql.Date(25,10,2018), maturityDate, tenor, calendar, ql.Unadjusted,
                           ql.Unadjusted , dateGeneration, monthEnd)

dayCount = ql.ActualActual(ql.ActualActual.ISMA)
couponRate = .0275
coupons = [couponRate]

settlementDays = 0
faceValue = 100
fixedRateBond = ql.FixedRateBond(settlementDays, faceValue, schedule, coupons, dayCount)

print(round(fixedRateBond.cleanPrice(0.025,ql.ActualActual(ql.ActualActual.ISMA),ql.CompoundedThenSimple,ql.Annual),6))

QuantLib 淨價 = 101.796832

BBG 淨價 = 101.796834

BBG 在計算 NPV 時不會調整日期。要在 QuantLib 中獲得相同的結果,我們需要將 ql.Unadjusted 添加到 FixedRateBond 參數。此外,為了獲得完全相同的淨價,我們需要計算臟價並減去四捨五入的應計金額。

fixedRateBond = ql.FixedRateBond(settlementDays, faceValue, schedule, coupons, dayCount, ql.Unadjusted)

print(round(fixedRateBond.dirtyPrice(0.025,ql.ActualActual(ql.ActualActual.ISMA),
ql.Compounded,ql.Annual),6)-round(fixedRateBond.accruedAmount(ql.Date(15,10,2021)),3))

Quantlib 清潔價格 = 101.796834

引用自:https://quant.stackexchange.com/questions/68450