|
From: Sumit S. <su...@mo...> - 2021-03-01 11:36:24
|
Hi,
I have the following code to calculate the yield of a Treasury bond.
The issue I have is the code gives a yield of 0.17% - which is much higher
than the expected 0.13%
Looking at the cashflows, it gives me the below....
Date Amount Expected
Date(15,6,2021) 0.5031
Date(15,12,2021) 0.8147 0.8125
Date(15,6,2022) 0.8103 0.8125
Date(15,12,2022) 0.8147 0.8125
Date(15,12,2022) 100
Any thoughts?
Thanks,
Sumit
calc_date = ql.Date(22,2,2021)
ql.Settings.instance().evaluationDate = calc_date
day_count = ql.ActualActual()
calendar = ql.UnitedStates()
bussiness_convention = ql.ModifiedFollowing
end_of_month = True
settlement_days = 1
face_amount = 100
coupon_frequency = ql.Period(ql.Semiannual)
price = 102.625
coupon = 1.625/100
maturity_date = ql.Date(15, 12, 2022)
# issue_date = ql.Date(1, 2, 2021)
coupon_frequency = ql.Period(6, ql.Months)
schedule = ql.Schedule(calc_date,
maturity_date,
coupon_frequency,
calendar,
bussiness_convention,
bussiness_convention,
ql.DateGeneration.Backward,
end_of_month)
fixedRateBond = ql.FixedRateBond(
settlement_days,
face_amount,
schedule,
[coupon],
ql.ActualActual()
)
yld = fixedRateBond.bondYield(price, ql.ActualActual(),ql.Compounded,
ql.Semiannual)
yld * 100
[x.amount()for x in fixedRateBond.cashflows()]
--
Mosaic Smart Data
mobile +44 (0)7961839363
su...@mo...
25 Finsbury Circus ▫ EC2M 7EE ▫ London ▫ United Kingdom
www.mosaicsmartdata.com
|