How Day-Count Conventions Affect Discount Curve Queries
Summary
The document explains why querying a QuantLib discount curve at a time of two years may not return the discount factor supplied for a date two calendar years after the curve’s reference date. The curve is constructed from dates and discount factors using the Actual/Actual day-count convention, while the query uses a numeric time. These inputs do not necessarily represent the same year fraction: the elapsed time between the example dates is slightly greater than two under that convention.
To align the query with the curve’s date-based input, the answer recommends using the corresponding year fraction, or using a 30/360 convention when a two-year interval is intended to map to exactly two. The example demonstrates the source of a small discrepancy and notes that it can grow across longer date lists. The key lesson is to match the time basis used in curve construction and discount queries. The explanation is specific to the stated dates and conventions; other dates and day-count rules can produce different year fractions.
Key ideas
- A numeric curve time and a calendar-date interval can represent different year fractions.
- Under Actual/Actual, the example’s two-calendar-year interval is slightly longer than two years.
- Querying with the matching year fraction aligns the discount lookup with the date-based curve input.
- A 30/360 convention maps the example interval to two years, but convention choice should match the intended calculation.
Tags
Full text
# Understanding DiscountCurve in quantlib # Understanding DiscountCurve in quantlib I want to create a TermStructureHandle handle in python using quantlib. I use the `DiscountCurve` class and enter the list of dates and discount factors as follows: ``` dates = [ql.Date(9,4,2018), ql.Date(9,4,2019), ql.Date(9,4,2020)] discfactors = [1, 0.9, 0.8] dayCount = ql.ActualActual() disc_curve = ql.DiscountCurve(dates, discfactors, dayCount) term_structure = ql.YieldTermStructureHandle(disc_curve) ``` The discount factor derived from this termstructure for two years should be 0.8 but in fact I get ``` print(abs(discfactors[2]-term_strcuture.discount(2))) 0.00018797232855949364 ``` What is the reason for this? When I insert longer lists of dates and corresponding discount factors the difference keeps increasing. ## Answer by Phil-ZXX (score 0, accepted) https://quant.stackexchange.com/a/39193 Note that the DCF between ql.Date(9,4,2018) and ql.Date(9,4,2020) is not 2 under Act/Act, it is 2.0019987. So you could either use ``` term_strcuture.discount(2.0019987) ``` or set your DayCountConvention to 30/360, under which the DCF is in fact 2.
Shown in full with attribution under the source's licence. Licence: CC BY-SA 4.0 (Stack Exchange)
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.