|
From: Sumit S. <su...@mo...> - 2021-06-11 10:13:00
|
Hi all,
I have the following script that I am using to match the Treasury
2yr contract yield.
The yield is close to 0.17%. I am getting a yield of around 0.14%
One of the issues (I think) is not being able to use the accrued
interest into the calculation.
The underlying Ctd has a coupon on 30th June, 2021 and also the
settlement date assumed(based on mkt convention) is 30th Sept, 2021.
Is there a way I can incorporate this accrued into the yield calculation?
Also, does anyone see any issues with the script below that I am
using (seems to be working fine for most of the other contracts)
Regards
Sumit
===============================================================================
import QuantLib as ql
accrued_int = 0.655
price = 110.355
conv_factor = 0.9447
face_value = 100
end_of_month = False
calendar = ql.UnitedStates()
settlement_days = 84
coupon_rate = 2.625
maturity_date = ql.Date(30, 6, 2023)
issue_date = ql.Date(2, 7, 2018)
# 1. Create security
schedule = ql.Schedule(
ql.Date(2, 6, 2021),
maturity_date,
ql.Period('6M'),
calendar,
ql.ModifiedFollowing,
ql.ModifiedFollowing,
ql.DateGeneration.Backward,
end_of_month
)
day_count = ql.ActualActual(ql.ActualActual.Bond, schedule)
security = ql.FixedRateBond(
settlement_days,
face_value,
schedule,
[coupon_rate/100],
day_count
)
yld = security.bondYield(
price * conv_factor,
day_count,
ql.Compounded,
ql.Semiannual
)
print(f"yield = {yld * 100}")
--
Mosaic Smart Data
mobile +44 (0)7961839363
su...@mo...
25 Finsbury Circus ▫ EC2M 7EE ▫ London ▫ United Kingdom
www.mosaicsmartdata.com
|