A year is not 1.0
Worked examples
Read the claim, then run it and check the machine agrees. One at a time — nothing here is taken on trust.
import QuantLib as ql
d1, d2 = ql.Date(31, 1, 2026), ql.Date(31, 7, 2026)
for dc in (ql.Actual360(), ql.Actual365Fixed(), ql.Thirty360(ql.Thirty360.European)):
tau = dc.yearFraction(d1, d2)
print(f"{dc.name():24} tau = {tau:.6f} interest on $100M at 5% = ${100e6 * 0.05 * tau:,.0f}")
Same dates — 31 January to 31 July — three different answers, and a $34,437 spread between the largest and smallest interest amount. 30E/360 lands on exactly 0.5 because it defines months as 30 days; the ACT conventions count the actual 181 days and divide by different constants.
import QuantLib as ql
dc = ql.Actual365Fixed()
print("2026 -> 2027:", dc.yearFraction(ql.Date(9, 7, 2026), ql.Date(9, 7, 2027)))
print("2027 -> 2028:", dc.yearFraction(ql.Date(9, 7, 2027), ql.Date(9, 7, 2028)))
July-to-July is exactly 1.0 the first time and 366/365 ≈ 1.00274 the second — the 2027→2028 span swallows 29 February 2028, and ACT counts it while the F in 365F refuses to grow the denominator. One span of "a year" is worth 0.27% more interest than the other.
Check the concept
One question at a time. Unsure? Revisit the lecture, then answer.
The challenge
Pass the quiz to unlock the challenge — your code will still be waiting here.