债券标的为170005,我的python代码如下:
1 import QuantLib as ql 2 3 faceAmount = 100.0 4 redemption = 100.0 5 issueDate = ql.Date(20, 2, 2017) 6 maturity = ql.Date(20, 2, 2047) 7 couponRate = 0.0377 8 coupons = [couponRate] 9 ytm = 0.0424510 calendar = ql.China(ql.China.IB)11 frequency = ql.Semiannual12 compounce = ql.Compounded13 dayCounter = ql.ActualActual(ql.ActualActual.ISMA)14 15 accuracy=1.0e-816 maxNum = 50017 today = calendar.adjust(ql.Date(14, 9, 2018))18 ql.Settings.evaluationDate = today19 settlementDays = 020 settlementDate = calendar.advance(21 today,22 ql.Period(settlementDays, ql.Days))23 24 discountingTermStructure = ql.RelinkableYieldTermStructureHandle()25 flatTermStructure = ql.FlatForward(settlementDate,26 ytm,27 dayCounter,28 compounce,29 frequency)30 31 discountingTermStructure.linkTo(flatTermStructure)32 bondEngin = ql.DiscountingBondEngine(discountingTermStructure)33 34 schedule = ql.Schedule(issueDate,35 maturity,36 ql.Period(frequency),37 ql.China(ql.China.IB),38 ql.Following,39 ql.Following,40 ql.DateGeneration.Backward,41 False)42 fixedRateBond = ql.FixedRateBond(settlementDays,43 faceAmount,44 schedule,45 coupons,46 dayCounter,47 ql.Following,48 redemption,49 issueDate)50 fixedRateBond.setPricingEngine(bondEngin)51 52 print(fixedRateBond.cleanPrice())53 print(fixedRateBond.cleanPrice(0.04245,dayCounter,compounce,frequency,ql.Date(14,9,2018)))54 print(fixedRateBond.dirtyPrice(0.04245,dayCounter,compounce,frequency))55 print(fixedRateBond.bondYield(95,dayCounter,compounce,frequency,ql.Date(14,9,2018),accuracy,maxNum))56 print(flatTermStructure.zeroRate(ql.Date(14,9,2018),dayCounter,compounce, frequency).rate())
输出结果为:
92.25734945596061
92.1975285022507892.453642632685560.040682117938995360.04245000000085631、两种pricevalue的计算结果不一样,是我理解错了嘛?
2、NPV和cleanprice的区别是啥?