0
$\begingroup$

I am completely new to python/coding so apologies in advance if the question is too basic but I could not find the answer elsewhere.

I am trying to calculate the daycount fraction from the settlement date to the end of the ith period using a bond’s daycount convention

Please see the code below. When changing the valuation_date 1 day forward for example, then the results stay the same.

Someone suggested that "bond day counts consider fractions of a year as opposed to multi-year stretches" hence thats why I have t=t1+t2

Many thanks!!

from QuantLib import *
issue_date = Date(3, 7, 2019)
valuation_date = Date(8, 12, 2022)
Settings.instance().evaluationDate = valuation_date
maturity_date = Date(3, 7, 2024)

t1 = ActualActual(ActualActual.ISMA).yearFraction(valuation_date, Date(3, 7, 2023))
t2 = ActualActual(ActualActual.ISMA).yearFraction(Date(3, 7, 2023), maturity_date)
t3 = ActualActual(ActualActual.ISMA).yearFraction(valuation_date, maturity_date)

t = t1 + t2
print(t)
print(t1)
print(t3)
```
$\endgroup$

1 Answer 1

1
$\begingroup$

After looking a bit further at the DayCounter class at http://quantlib.org/reference and to further websites I found that for the ISMA variant of the Actual/Actual day counter I have to specify the "Date &refDateStart and Date &refDateEnd" in the yearFraction method in my code. I think that does the trick as the I arrive to different results

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.