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)
```